本文整理汇总了Java中backtype.storm.tuple.MessageId类的典型用法代码示例。如果您正苦于以下问题:Java MessageId类的具体用法?Java MessageId怎么用?Java MessageId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageId类属于backtype.storm.tuple包,在下文中一共展示了MessageId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: deserialize
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
public Tuple deserialize(byte[] ser) {
try {
_kryoInput.setBuffer(ser);
int taskId = _kryoInput.readInt(true);
int streamId = _kryoInput.readInt(true);
String componentName = _context.getComponentId(taskId);
String streamName = _ids.getStreamName(componentName, streamId);
MessageId id = MessageId.deserialize(_kryoInput);
List<Object> values = _kryo.deserializeFrom(_kryoInput);
TupleImpl tuple = new TupleImpl(_context, values, taskId,
streamName, id);
long transferStartTime = _kryoInput.readLong(true);
if (transferStartTime != -1) {
tuple.setTransferSampleStartTime(transferStartTime);
}
return tuple;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:troyding,项目名称:storm-resa,代码行数:21,代码来源:KryoTupleDeserializer.java
示例2: sendAckTuple
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
private boolean sendAckTuple(Tuple input) {
boolean ret = false;
Integer pendingCount;
synchronized (pendingTuples) {
pendingCount = pendingTuples.get(input);
}
if (pendingCount == null || pendingCount <= 0) {
long ack_val = 0L;
Object pend_val = pendingAcks.remove(input);
if (pend_val != null) {
ack_val = (Long) (pend_val);
}
MessageId messageId = input.getMessageId();
if (messageId != null) {
for (Map.Entry<Long, Long> e : messageId.getAnchorsToIds().entrySet()) {
List<Object> ackTuple =
JStormUtils.mk_list((Object) e.getKey(), JStormUtils.bit_xor(e.getValue(), ack_val));
sendBoltMsg(Acker.ACKER_ACK_STREAM_ID, null, ackTuple, null, null);
}
}
ret = true;
}
return ret;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:26,代码来源:BoltBatchCollector.java
示例3: processTupleBatchEvent
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
private void processTupleBatchEvent(Tuple tuple) {
try {
if ((!isSystemBolt && tuple.getSourceStreamId().equals(Common.TOPOLOGY_MASTER_CONTROL_STREAM_ID)) ||
tuple.getSourceStreamId().equals(Common.TOPOLOGY_MASTER_REGISTER_METRICS_RESP_STREAM_ID)) {
if (tuple.getValues().get(0) instanceof Pair) {
for (Object value : tuple.getValues()) {
Pair<MessageId, List<Object>> val = (Pair<MessageId, List<Object>>) value;
TupleImplExt t = new TupleImplExt(
sysTopologyCtx, val.getSecond(), val.getFirst(), ((TupleImplExt) tuple));
processTupleEvent(t);
}
}
} else {
bolt.execute(tuple);
}
} catch (Throwable e) {
error = e;
LOG.error("bolt execute error ", e);
reportError.report(e);
}
}
开发者ID:alibaba,项目名称:jstorm,代码行数:22,代码来源:BoltExecutors.java
示例4: getRootId
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
protected Long getRootId(Object messageId) {
Boolean needAck = (messageId != null) && (ackerNum > 0);
// This change storm logic
// Storm can't make sure root_id is unique
// storm's logic is root_id = MessageId.generateId(random);
// when duplicate root_id, it will miss call ack/fail
Long rootId = null;
if (needAck) {
rootId = MessageId.generateId(random);
/* while (pending.containsKey(rootId)) {
rootId = MessageId.generateId(random);
}*/
}
return rootId;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:17,代码来源:SpoutCollector.java
示例5: getMessageId
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
protected MessageId getMessageId(SpoutMsgInfo msg, Map<Long, MsgInfo> ackBatch) {
MessageId msgId = null;
if (msg.rootId != null) {
Long as = MessageId.generateId(random);
msgId = MessageId.makeRootId(msg.rootId, as);
MsgInfo msgInfo = ackBatch.get(msg.rootId);
List<Object> ackerTuple;
if (msgInfo == null) {
TupleInfo info = TupleInfo.buildTupleInfo(msg.streamId, msg.messageId, msg.values, System.currentTimeMillis(), isCacheTuple);
pending.putHead(msg.rootId, info);
ackerTuple = JStormUtils.mk_list((Object) msg.rootId, JStormUtils.bit_xor_vals(as), task_id);
msgInfo = new SpoutMsgInfo(Acker.ACKER_INIT_STREAM_ID, ackerTuple, null, null, null, null);
ackBatch.put(msg.rootId, msgInfo);
} else {
ackerTuple = msgInfo.values;
ackerTuple.set(1, JStormUtils.bit_xor_vals(ackerTuple.get(1), as));
}
}
return msgId;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:25,代码来源:SpoutBatchCollector.java
示例6: getMessageId
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
protected MessageId getMessageId(Collection<Tuple> anchors) {
MessageId ret = null;
if (anchors != null && ackerNum > 0) {
Map<Long, Long> anchors_to_ids = new HashMap<>();
for (Tuple a : anchors) {
if (a.getMessageId() != null) {
Long edge_id = MessageId.generateId(random);
put_xor(pendingAcks, a, edge_id);
MessageId messageId = a.getMessageId();
if (messageId != null) {
for (Long root_id : messageId.getAnchorsToIds().keySet()) {
put_xor(anchors_to_ids, root_id, edge_id);
}
}
}
}
ret = MessageId.makeId(anchors_to_ids);
}
return ret;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:21,代码来源:BoltCollector.java
示例7: deserialize
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
@Override
public Tuple deserialize(byte[] ser) {
int targetTaskId = 0;
int taskId = 0;
int streamId = 0;
String componentName = null;
String streamName = null;
MessageId id = null;
try {
_kryoInput.setBuffer(ser);
targetTaskId = _kryoInput.readInt();
taskId = _kryoInput.readInt(true);
streamId = _kryoInput.readInt(true);
componentName = _context.getComponentId(taskId);
streamName = _ids.getStreamName(componentName, streamId);
id = MessageId.deserialize(_kryoInput);
List<Object> values = _kryo.deserializeFrom(_kryoInput);
TupleImplExt tuple = new TupleImplExt(_context, values, taskId,
streamName, id);
tuple.setTargetTaskId(targetTaskId);
return tuple;
} catch (Throwable e) {
StringBuilder sb = new StringBuilder();
sb.append("Deserialize error:");
sb.append("targetTaskId:").append(targetTaskId);
sb.append(",taskId:").append(taskId);
sb.append(",streamId:").append(streamId);
sb.append(",componentName:").append(componentName);
sb.append(",streamName:").append(streamName);
sb.append(",MessageId").append(id);
LOG.info(sb.toString(), e );
throw new RuntimeException(e);
}
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:41,代码来源:KryoTupleDeserializer.java
示例8: deserialize
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
public Tuple deserialize(byte[] ser) {
int targetTaskId = 0;
int taskId = 0;
int streamId = 0;
String componentName = null;
String streamName = null;
MessageId id = null;
try {
_kryoInput.setBuffer(ser);
targetTaskId = _kryoInput.readInt();
taskId = _kryoInput.readInt(true);
streamId = _kryoInput.readInt(true);
componentName = _context.getComponentId(taskId);
streamName = _ids.getStreamName(componentName, streamId);
id = MessageId.deserialize(_kryoInput);
List<Object> values = _kryo.deserializeFrom(_kryoInput);
TupleImplExt tuple = new TupleImplExt(_context, values, taskId,
streamName, id);
tuple.setTargetTaskId(targetTaskId);
return tuple;
} catch (Throwable e) {
StringBuilder sb = new StringBuilder();
sb.append("Deserialize error:");
sb.append("targetTaskId:").append(targetTaskId);
sb.append(",taskId:").append(taskId);
sb.append(",streamId:").append(streamId);
sb.append(",componentName:").append(componentName);
sb.append(",streamName:").append(streamName);
sb.append(",MessageId").append(id);
LOG.info(sb.toString(), e );
throw new RuntimeException(e);
}
}
开发者ID:songtk,项目名称:learn_jstorm,代码行数:40,代码来源:KryoTupleDeserializer.java
示例9: deserialize
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
public Tuple deserialize(Input input) {
int targetTaskId = 0;
long timeStamp = 0l;
int taskId = 0;
int streamId = 0;
String componentName = null;
String streamName = null;
MessageId id = null;
try {
targetTaskId = input.readInt();
timeStamp = input.readLong();
taskId = input.readInt(true);
streamId = input.readInt(true);
componentName = _context.getComponentId(taskId);
streamName = _ids.getStreamName(componentName, streamId);
id = MessageId.deserialize(input);
List<Object> values = _kryo.deserializeFrom(input);
TupleImplExt tuple = new TupleImplExt(_context, values, taskId, streamName, id);
tuple.setTargetTaskId(targetTaskId);
tuple.setCreationTimeStamp(timeStamp);
return tuple;
} catch (Throwable e) {
StringBuilder sb = new StringBuilder();
sb.append("Deserialize error:");
sb.append("targetTaskId:").append(targetTaskId);
sb.append(",creationTimeStamp:").append(timeStamp);
sb.append(",taskId:").append(taskId);
sb.append(",streamId:").append(streamId);
sb.append(",componentName:").append(componentName);
sb.append(",streamName:").append(streamName);
sb.append(",MessageId").append(id);
LOG.info(sb.toString(), e);
throw new RuntimeException(e);
}
}
开发者ID:kkllwww007,项目名称:jstrom,代码行数:39,代码来源:KryoTupleDeserializer.java
示例10: deserialize
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
public Tuple deserialize(byte[] ser) {
try {
_kryoInput.setBuffer(ser);
int taskId = _kryoInput.readInt(true);
int streamId = _kryoInput.readInt(true);
String componentName = _context.getComponentId(taskId);
String streamName = _ids.getStreamName(componentName, streamId);
MessageId id = MessageId.deserialize(_kryoInput);
List<Object> values = _kryo.deserializeFrom(_kryoInput);
return new TupleImpl(_context, values, taskId, streamName, id);
} catch(IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:metamx,项目名称:incubator-storm,代码行数:15,代码来源:KryoTupleDeserializer.java
示例11: getMessageId
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
@Override
protected MessageId getMessageId(Collection<Tuple> anchors) {
MessageId ret = null;
if (anchors != null) {
Map<Long, Long> anchors_to_ids = new HashMap<Long, Long>();
long now = System.currentTimeMillis();
if (now - lastRotate > rotateTime) {
pendingAcks.rotate();
synchronized (pendingTuples) {
pendingTuples.rotate();
}
lastRotate = now;
}
for (Tuple a : anchors) {
// Long edge_id = MessageId.generateId();
Long edge_id = MessageId.generateId(random);
synchronized (pendingAcks) {
put_xor(pendingAcks, a, edge_id);
}
MessageId messageId = a.getMessageId();
if (messageId != null) {
for (Long root_id : messageId.getAnchorsToIds().keySet()) {
put_xor(anchors_to_ids, root_id, edge_id);
}
}
}
ret = MessageId.makeId(anchors_to_ids);
}
return ret;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:31,代码来源:BoltBatchCollector.java
示例12: sendMsg
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
public List<Integer> sendMsg(String out_stream_id, List<Object> values, Object message_id,
Integer out_task_id, ICollectorCallback callback) {
final long startTime = emitTotalTimer.getTime();
try {
boolean needAck = (message_id != null) && (ackerNum > 0);
Long root_id = getRootId(message_id);
List<Integer> outTasks;
if (out_task_id != null) {
outTasks = sendTargets.get(out_task_id, out_stream_id, values, null, root_id);
} else {
outTasks = sendTargets.get(out_stream_id, values, null, root_id);
}
List<Long> ackSeq = new ArrayList<>();
for (Integer t : outTasks) {
MessageId msgId;
if (needAck) {
// Long as = MessageId.generateId();
Long as = MessageId.generateId(random);
msgId = MessageId.makeRootId(root_id, as);
ackSeq.add(as);
} else {
msgId = null;
}
TupleImplExt tp = new TupleImplExt(topology_context, values, task_id, out_stream_id, msgId);
tp.setTargetTaskId(t);
transfer_fn.transfer(tp);
}
sendMsgToAck(out_stream_id, values, message_id, root_id, ackSeq, needAck);
if (callback != null)
callback.execute(out_stream_id, outTasks, values);
return outTasks;
} finally {
emitTotalTimer.updateTime(startTime);
}
}
开发者ID:alibaba,项目名称:jstorm,代码行数:39,代码来源:SpoutCollector.java
示例13: sendCtrlMsg
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
protected List<Integer> sendCtrlMsg(String out_stream_id, List<Object> values, Object message_id, Integer out_task_id) {
final long startTime = emitTotalTimer.getTime();
try {
boolean needAck = (message_id != null) && (ackerNum > 0);
Long root_id = getRootId(message_id);
java.util.List<Integer> out_tasks;
if (out_task_id != null) {
out_tasks = sendTargets.get(out_task_id, out_stream_id, values, null, root_id);
} else {
out_tasks = sendTargets.get(out_stream_id, values, null, root_id);
}
List<Long> ackSeq = new ArrayList<>();
for (Integer t : out_tasks) {
MessageId msgId;
if (needAck) {
// Long as = MessageId.generateId();
Long as = MessageId.generateId(random);
msgId = MessageId.makeRootId(root_id, as);
ackSeq.add(as);
} else {
msgId = null;
}
TupleImplExt tp = new TupleImplExt(topology_context, values, task_id, out_stream_id, msgId);
tp.setTargetTaskId(t);
transferCtr(tp);
}
sendMsgToAck(out_stream_id, values, message_id, root_id, ackSeq, needAck);
return out_tasks;
} finally {
emitTotalTimer.updateTime(startTime);
}
}
开发者ID:alibaba,项目名称:jstorm,代码行数:36,代码来源:SpoutCollector.java
示例14: sendMsg
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
public List<Integer> sendMsg(String out_stream_id, List<Object> values, Collection<Tuple> anchors,
Integer out_task_id, ICollectorCallback callback) {
final long start = emitTimer.getTime();
List<Integer> outTasks = null;
try {
if (out_task_id != null) {
outTasks = sendTargets.get(out_task_id, out_stream_id, values, anchors, null);
} else {
outTasks = sendTargets.get(out_stream_id, values, anchors, null);
}
tryRotate();
for (Integer t : outTasks) {
MessageId msgId = getMessageId(anchors);
TupleImplExt tp = new TupleImplExt(topologyContext, values, taskId, out_stream_id, msgId);
tp.setTargetTaskId(t);
taskTransfer.transfer(tp);
}
} catch (Exception e) {
LOG.error("bolt emit error:", e);
} finally {
if (outTasks == null) {
outTasks = new ArrayList<>();
}
if (callback != null)
callback.execute(out_stream_id, outTasks, values);
emitTimer.updateTime(start);
}
return outTasks;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:31,代码来源:BoltCollector.java
示例15: sendCtrlMsg
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
protected List<Integer> sendCtrlMsg(String out_stream_id, List<Object> values,
Collection<Tuple> anchors, Integer out_task_id) {
final long start = emitTimer.getTime();
java.util.List<Integer> out_tasks = null;
try {
if (out_task_id != null) {
out_tasks = sendTargets.get(out_task_id, out_stream_id, values, anchors, null);
} else {
out_tasks = sendTargets.get(out_stream_id, values, anchors, null);
}
tryRotate();
for (Integer t : out_tasks) {
MessageId msgId = getMessageId(anchors);
TupleImplExt tp = new TupleImplExt(topologyContext, values, taskId, out_stream_id, msgId);
tp.setTargetTaskId(t);
transferCtr(tp);
}
} catch (Exception e) {
LOG.error("bolt emit error:", e);
} finally {
emitTimer.updateTime(start);
}
return out_tasks;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:28,代码来源:BoltCollector.java
示例16: boltEmit
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
private List<Integer> boltEmit(String out_stream_id,
Collection<Tuple> anchors, List<Object> values, Integer out_task_id) {
timer.start();
try {
java.util.List<Integer> out_tasks = null;
if (out_task_id != null) {
out_tasks = sendTargets.get(out_task_id, out_stream_id, values);
} else {
out_tasks = sendTargets.get(out_stream_id, values);
}
for (Integer t : out_tasks) {
Map<Long, Long> anchors_to_ids = new HashMap<Long, Long>();
if (anchors != null) {
for (Tuple a : anchors) {
//Long edge_id = MessageId.generateId();
Long edge_id = MessageId.generateId(random);
long now = System.currentTimeMillis();
if (now - lastRotate > rotateTime) {
pending_acks.rotate();
lastRotate = now;
}
put_xor(pending_acks, a, edge_id);
for (Long root_id : a.getMessageId().getAnchorsToIds()
.keySet()) {
put_xor(anchors_to_ids, root_id, edge_id);
}
}
}
MessageId msgid = MessageId.makeId(anchors_to_ids);
TupleImplExt tupleExt = new TupleImplExt(topologyContext,
values, task_id, out_stream_id, msgid);
tupleExt.setTargetTaskId(t);
taskTransfer.transfer(tupleExt);
}
return out_tasks;
} catch (Exception e) {
LOG.error("bolt emit", e);
}finally {
timer.stop();
}
return new ArrayList<Integer>();
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:46,代码来源:BoltCollector.java
示例17: boltEmit
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
private List<Integer> boltEmit(String out_stream_id, Collection<Tuple> anchors, List<Object> values, Integer out_task_id) {
final long start = System.nanoTime();
try {
List<Integer> out_tasks;
if (out_task_id != null) {
out_tasks = sendTargets.get(out_task_id, out_stream_id, values);
} else {
out_tasks = sendTargets.get(out_stream_id, values);
}
for (Integer t : out_tasks) {
Map<Long, Long> anchors_to_ids = new HashMap<Long, Long>();
if (anchors != null) {
for (Tuple a : anchors) {
// Long edge_id = MessageId.generateId();
Long edge_id = MessageId.generateId(random);
long now = System.currentTimeMillis();
if (now - lastRotate > rotateTime) {
pending_acks.rotate();
lastRotate = now;
}
put_xor(pending_acks, a, edge_id);
for (Long root_id : a.getMessageId().getAnchorsToIds().keySet()) {
put_xor(anchors_to_ids, root_id, edge_id);
}
}
}
MessageId msgid = MessageId.makeId(anchors_to_ids);
TupleImplExt tupleExt = new TupleImplExt(topologyContext, values, task_id, out_stream_id, msgid);
tupleExt.setTargetTaskId(t);
taskTransfer.transfer(tupleExt);
}
return out_tasks;
} catch (Exception e) {
LOG.error("bolt emit", e);
} finally {
long end = System.nanoTime();
timer.update((end - start) / TimeUtils.NS_PER_US);
}
return new ArrayList<Integer>();
}
开发者ID:kkllwww007,项目名称:jstrom,代码行数:43,代码来源:BoltCollector.java
示例18: getMessageId
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
@Override
public MessageId getMessageId() {
// TODO Auto-generated method stub
return null;
}
开发者ID:IntersysConsulting,项目名称:ingestive,代码行数:6,代码来源:MockedTuple.java
示例19: isDebugRecv
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
public static boolean isDebugRecv(MessageId msgId) {
return msgId != null && isDebugRecv(msgId.getAnchors());
}
开发者ID:alibaba,项目名称:jstorm,代码行数:4,代码来源:JStormDebugger.java
示例20: onEvent
import backtype.storm.tuple.MessageId; //导入依赖的package包/类
@Override
public void onEvent(Object event, long sequence, boolean endOfBatch) throws Exception {
if (event == null) {
return;
}
if (event instanceof Tuple) {
Tuple tuple = (Tuple) event;
int tupleNum = 1;
Long startTime = System.currentTimeMillis();
long lifeCycleStart = ((TupleExt) tuple).getCreationTimeStamp();
if (((TupleExt) tuple).isBatchTuple()) {
List<Object> values = ((Tuple) event).getValues();
tupleNum = values.size();
if (bolt instanceof IRichBatchBolt) {
processTupleBatchEvent(tuple);
} else {
for (Object value : values) {
Pair<MessageId, List<Object>> val = (Pair<MessageId, List<Object>>) value;
TupleImplExt t = new TupleImplExt(
sysTopologyCtx, val.getSecond(), val.getFirst(), ((TupleImplExt) event));
processTupleEvent(t);
}
}
} else {
processTupleEvent(tuple);
}
taskStats.tupleLifeCycle(tuple.getSourceComponent(), tuple.getSourceStreamId(), lifeCycleStart, startTime, tupleNum);
taskStats.recv_tuple(tuple.getSourceComponent(), tuple.getSourceStreamId(), tupleNum);
if (ackerNum == 0) {
// only when acker is disabled
// get tuple process latency
if (JStormMetrics.enabled) {
long endTime = System.currentTimeMillis();
taskStats.update_bolt_acked_latency(
tuple.getSourceComponent(), tuple.getSourceStreamId(), startTime, endTime, tupleNum);
}
}
} else if (event instanceof TimerTrigger.TimerEvent) {
processTimerEvent((TimerTrigger.TimerEvent) event);
} else {
LOG.warn("Bolt executor received an unknown message");
}
}
开发者ID:alibaba,项目名称:jstorm,代码行数:46,代码来源:BoltExecutors.java
注:本文中的backtype.storm.tuple.MessageId类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论