Java Code Examples for backtype.storm.utils.Utils#secureRandomLong()
The following examples show how to use
backtype.storm.utils.Utils#secureRandomLong() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BoltCollector.java From jstorm with Apache License 2.0 | 6 votes |
public BoltCollector(Task task, RotatingMap<Tuple, Long> tupleStartTimes, int message_timeout_secs) { this.rotateTime = 1000L * message_timeout_secs / (Acker.TIMEOUT_BUCKET_NUM - 1); this.reportError = task.getReportErrorDie(); this.sendTargets = task.getTaskSendTargets(); this.stormConf = task.getStormConf(); this.taskTransfer = task.getTaskTransfer(); this.topologyContext = task.getTopologyContext(); this.taskId = task.getTaskId(); this.taskStats = task.getTaskStats(); this.pendingAcks = new RotatingMap<>(Acker.TIMEOUT_BUCKET_NUM); // this.pending_acks = new TimeCacheMap<Tuple, // Long>(messageTimeoutSecs, // Acker.TIMEOUT_BUCKET_NUM); this.tupleStartTimes = tupleStartTimes; this.ackerNum = JStormUtils.parseInt(stormConf.get(Config.TOPOLOGY_ACKER_EXECUTORS)); String componentId = topologyContext.getThisComponentId(); this.emitTimer = (AsmHistogram) JStormMetrics.registerTaskMetric(MetricUtils.taskMetricName( topologyContext.getTopologyId(), componentId, taskId, MetricDef.COLLECTOR_EMIT_TIME, MetricType.HISTOGRAM), new AsmHistogram()); this.emitTimer.setEnabled(false); this.random = new Random(Utils.secureRandomLong()); }
Example 2
Source File: TransactionalSpoutCoordinator.java From jstorm with Apache License 2.0 | 6 votes |
@Override public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { _rand = new Random(Utils.secureRandomLong()); _state = TransactionalState.newCoordinatorState(conf, (String) conf.get(Config.TOPOLOGY_TRANSACTIONAL_ID), _spout.getComponentConfiguration()); _coordinatorState = new RotatingTransactionalState(_state, META_DIR, true); _collector = collector; _coordinator = _spout.getCoordinator(conf, context); _currTransaction = getStoredCurrTransaction(_state); Object active = conf.get(Config.TOPOLOGY_MAX_SPOUT_PENDING); if (active == null) { _maxTransactionActive = 1; } else { _maxTransactionActive = Utils.getInt(active); } _initializer = new StateInitializer(); }
Example 3
Source File: SequenceSpout.java From jstorm with Apache License 2.0 | 5 votes |
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { this.collector = collector; if (conf.get("spout.max.sending.num") == null) { isLimited = false; } else { isLimited = true; SPOUT_MAX_SEND_NUM = JStormUtils.parseLong(conf.get("spout.max.sending.num")); } Boolean btrue = JStormUtils.parseBoolean(conf.get("spout.send.contrl.message")); if (btrue != null && btrue) { isSendCtrlMsg = true; } else { isSendCtrlMsg = false; } isFinished = false; tpsCounter = new TpsCounter(context.getThisComponentId() + ":" + context.getThisTaskId()); MetricClient metricClient = new MetricClient(context); this.tpCounter = metricClient.registerTopologyCounter("TpCounter"); MAX_PENDING_COUNTER = getMaxPending(conf); bufferLen = JStormUtils.parseInt(conf.get("byte.buffer.len"), 0); random = new Random(); random.setSeed(System.currentTimeMillis()); idGenerate = new Random(Utils.secureRandomLong()); JStormUtils.sleepMs(20 * 1000); LOG.info("Finish open, buffer Len:" + bufferLen); }
Example 4
Source File: AckTransactionBolt.java From jstorm with Apache License 2.0 | 5 votes |
@Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { this.batchXorTracker = new AckPendingBatchTracker<>(); this.ackOutputCollector = new AckOutputCollector(collector.getDelegate(), batchXorTracker); this.bolt.prepare(stormConf, context, new OutputCollector(ackOutputCollector)); this.componentId = context.getThisComponentId(); this.taskId = context.getThisTaskId(); this.taskStats = new TaskBaseMetric(context.getTopologyId(), componentId, taskId); this.batchTimeout = ConfigExtension.getTransactionBatchSnapshotTimeout(stormConf) * 1000; this.random = new Random(Utils.secureRandomLong()); LOG.info("batchTimeout: {}", batchTimeout); }
Example 5
Source File: AckTransactionSpout.java From jstorm with Apache License 2.0 | 5 votes |
@Override public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { SpoutOutputCollectorCb ackOutput = new AckSpoutOutputCollector(collector.getDelegate()); spoutExecutor.open(conf, context, new SpoutOutputCollector(ackOutput)); tracker = new AckPendingBatchTracker<>(); taskStats = new TaskBaseMetric(context.getTopologyId(), context.getThisComponentId(), context.getThisTaskId()); random = new Random(Utils.secureRandomLong()); }
Example 6
Source File: SpoutCollector.java From jstorm with Apache License 2.0 | 5 votes |
public SpoutCollector(Task task, TimeOutMap<Long, TupleInfo> pending, DisruptorQueue disruptorAckerQueue) { this.sendTargets = task.getTaskSendTargets(); this.storm_conf = task.getStormConf(); this.transfer_fn = task.getTaskTransfer(); this.pending = pending; this.topology_context = task.getTopologyContext(); this.disruptorAckerQueue = disruptorAckerQueue; this.task_stats = task.getTaskStats(); this.spout = (ISpout) task.getTaskObj(); this.task_id = task.getTaskId(); this.report_error = task.getReportErrorDie(); ackerNum = JStormUtils.parseInt(storm_conf.get(Config.TOPOLOGY_ACKER_EXECUTORS)); random = new Random(Utils.secureRandomLong()); if (spout instanceof IAckValueSpout || spout instanceof IFailValueSpout) isCacheTuple = true; else isCacheTuple = false; String componentId = topology_context.getThisComponentId(); emitTotalTimer = (AsmHistogram) JStormMetrics.registerTaskMetric(MetricUtils.taskMetricName( topology_context.getTopologyId(), componentId, task_id, MetricDef.COLLECTOR_EMIT_TIME, MetricType.HISTOGRAM), new AsmHistogram()); emitTotalTimer.setEnabled(false); }
Example 7
Source File: RichSpoutBatchTriggerer.java From jstorm with Apache License 2.0 | 5 votes |
@Override public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { _delegate.open(conf, context, new SpoutOutputCollector(new StreamOverrideCollector(collector))); _outputTasks = new ArrayList<>(); for(String component: Utils.get(context.getThisTargets(), _coordStream, new HashMap<String, Grouping>()).keySet()) { _outputTasks.addAll(context.getComponentTasks(component)); } _rand = new Random(Utils.secureRandomLong()); }
Example 8
Source File: PrepareBatchBolt.java From jstorm with Apache License 2.0 | 5 votes |
@Override public void execute(Tuple input, BasicOutputCollector collector) { long id = Utils.secureRandomLong(); List<Object> toEmit = new ArrayList<>(); toEmit.add(id); toEmit.addAll(input.getValues()); collector.emit(toEmit); }
Example 9
Source File: MessageId.java From jstorm with Apache License 2.0 | 4 votes |
@Deprecated public static long generateId() { return Utils.secureRandomLong(); }