当前位置: 首页>>代码示例>>Java>>正文


Java MessageId.generateId方法代码示例

本文整理汇总了Java中backtype.storm.tuple.MessageId.generateId方法的典型用法代码示例。如果您正苦于以下问题:Java MessageId.generateId方法的具体用法?Java MessageId.generateId怎么用?Java MessageId.generateId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在backtype.storm.tuple.MessageId的用法示例。


在下文中一共展示了MessageId.generateId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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


注:本文中的backtype.storm.tuple.MessageId.generateId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。