本文整理汇总了Java中backtype.storm.tuple.MessageId类的典型用法代码示例。如果您正苦于以下问题:Java MessageId类的具体用法?Java MessageId怎么用?Java MessageId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageId类属于backtype.storm.tuple包,在下文中一共展示了MessageId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}