backtype.storm.utils.Utils.secureRandomLong()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中backtype.storm.utils.Utils.secureRandomLong()方法的一些代码示例,展示了Utils.secureRandomLong()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.secureRandomLong()方法的具体详情如下:
包路径:backtype.storm.utils.Utils
类名称:Utils
方法名:secureRandomLong

Utils.secureRandomLong介绍

暂无

代码示例

代码示例来源:origin: alibaba/jstorm

@Deprecated
public static long generateId() {
  return Utils.secureRandomLong();
}

代码示例来源:origin: alibaba/jstorm

@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);
}

代码示例来源:origin: alibaba/jstorm

@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());
}

代码示例来源:origin: alibaba/jstorm

random.setSeed(System.currentTimeMillis());
idGenerate = new Random(Utils.secureRandomLong());

代码示例来源:origin: alibaba/jstorm

@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();
}

代码示例来源:origin: alibaba/jstorm

@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);
}

代码示例来源:origin: alibaba/jstorm

@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());
}

代码示例来源:origin: alibaba/jstorm

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());
}

代码示例来源:origin: alibaba/jstorm

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);
}

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

@Deprecated
public static long generateId() {
  return Utils.secureRandomLong();
}

代码示例来源:origin: com.n3twork.storm/storm-core

@Override
public void execute(Tuple input, BasicOutputCollector collector) {
  long id = Utils.secureRandomLong();
  List<Object> toEmit = new ArrayList<Object>();
  toEmit.add(id);
  toEmit.addAll(input.getValues());
  collector.emit(toEmit);
}

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

@Override
public void execute(Tuple input, BasicOutputCollector collector) {
  long id = Utils.secureRandomLong();
  List<Object> toEmit = new ArrayList<Object>();
  toEmit.add(id);
  toEmit.addAll(input.getValues());
  collector.emit(toEmit);
}

代码示例来源:origin: com.n3twork.storm/storm-core

@Override
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
  _delegate.open(conf, context, new SpoutOutputCollector(new StreamOverrideCollector(collector)));
  _outputTasks = new ArrayList<Integer>();
  for(String component: Utils.get(context.getThisTargets(),
                  _coordStream,
                  new HashMap<String, Grouping>()).keySet()) {
    _outputTasks.addAll(context.getComponentTasks(component));
  }
  _rand = new Random(Utils.secureRandomLong());
}

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

@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());
}

代码示例来源:origin: com.n3twork.storm/storm-core

@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();
}

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

@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();
}

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

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());
/*        random.setSeed(System.currentTimeMillis());*/

    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);
  }

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

public BoltCollector(Task task, RotatingMap<Tuple, Long> tuple_start_times, int message_timeout_secs) {

    this.rotateTime = 1000L * message_timeout_secs / (Acker.TIMEOUT_BUCKET_NUM - 1);
    this.reportError = task.getReportErrorDie();
    this.sendTargets = task.getTaskSendTargets();
    this.storm_conf = task.getStormConf();
    this.taskTransfer = task.getTaskTransfer();
    this.topologyContext = task.getTopologyContext();
    this.task_id = task.getTaskId();
    this.task_stats = task.getTaskStats();

    this.pending_acks = new RotatingMap<Tuple, Long>(Acker.TIMEOUT_BUCKET_NUM);
    // this.pending_acks = new TimeCacheMap<Tuple,
    // Long>(message_timeout_secs,
    // Acker.TIMEOUT_BUCKET_NUM);
    this.tuple_start_times = tuple_start_times;

    this.ackerNum = JStormUtils.parseInt(storm_conf.get(Config.TOPOLOGY_ACKER_EXECUTORS));

    String componentId = topologyContext.getThisComponentId();
    this.emitTimer = (AsmHistogram) JStormMetrics.registerTaskMetric(MetricUtils.taskMetricName(
            topologyContext.getTopologyId(), componentId, task_id, MetricDef.COLLECTOR_EMIT_TIME, MetricType.HISTOGRAM),
        new AsmHistogram());
    this.emitTimer.setEnabled(false);
    //this.emitTimer.setTimeUnit(TimeUnit.NANOSECONDS);

    random = new Random(Utils.secureRandomLong());
/*        random.setSeed(System.currentTimeMillis());*/
  }

相关文章