backtype.storm.tuple.Tuple.getSourceStreamId()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(122)

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

Tuple.getSourceStreamId介绍

[英]Gets the id of the stream that this tuple was emitted to.
[中]

代码示例

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

public static boolean isCheckpoint(Tuple input) {
  return CHECKPOINT_STREAM_ID.equals(input.getSourceStreamId());
}

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

private BatchStatus getBatchStatus(Tuple tuple) {
  String streamId = tuple.getSourceStreamId();
  if (streamId.equals(BatchDef.PREPARE_STREAM_ID)) {
    return BatchStatus.PREPARE_COMMIT;
  } else if (streamId.equals(BatchDef.COMMIT_STREAM_ID)) {
    return BatchStatus.COMMIT;
  } else if (streamId.equals(BatchDef.REVERT_STREAM_ID)) {
    return BatchStatus.REVERT_COMMIT;
  } else if (streamId.equals(BatchDef.POST_STREAM_ID)) {
    return BatchStatus.POST_COMMIT;
  } else {
    return BatchStatus.COMPUTING;
  }
}

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

@Override
public void execute(Tuple input) {
  Object value = input.getValue(0);
  if (input.getSourceStreamId().equals(TopologyMaster.USER_DEFINED_STREAM)) {
    TMUdfMessage message = (TMUdfMessage) value;
    LOG.info("Received TM UDF message trigged by task-{}", message.spoutTaskId);
  } else {
    LOG.info("Received unkown message: {}", input);
  }
}

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

@Override
public void execute(Tuple input) {
  IKvState<K, V> state = null;
  if (fieldGrouping.containsKey(input.getSourceStreamId())) {
    state = getSpecifiedKeyRangeState(input, fieldGrouping.get(input.getSourceStreamId()));
  }
  execute(input, state);
}

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

@Override
public void execute(BatchInfo batchInfo, Tuple tuple) {
  String sourceStream = tuple.getSourceStreamId();
  InitialReceiver ir = _roots.get(sourceStream);
  if (ir == null) {
    throw new RuntimeException("Received unexpected tuple " + tuple.toString());
  }
  ir.receive((ProcessorContext) batchInfo.state, tuple);
}

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

public static boolean isTickTuple(Tuple tuple) {
    return tuple.getSourceComponent().equals(Constants.SYSTEM_COMPONENT_ID) &&
        tuple.getSourceStreamId().equals(Constants.SYSTEM_TICK_STREAM_ID);
  }
}

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

public static boolean isTick(Tuple tuple) {
  return tuple != null && Constants.SYSTEM_COMPONENT_ID.equals(tuple.getSourceComponent())
      && Constants.SYSTEM_TICK_STREAM_ID.equals(tuple.getSourceStreamId());
}

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

private TupleType getTupleType(Tuple tuple) {
  if (_idStreamSpec != null && tuple.getSourceGlobalStreamid().equals(_idStreamSpec._id)) {
    return TupleType.ID;
  } else if (!_sourceArgs.isEmpty() && tuple.getSourceStreamId().equals(Constants.COORDINATED_STREAM_ID)) {
    return TupleType.COORD;
  } else {
    return TupleType.REGULAR;
  }
}

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

private TupleType getTupleType(Tuple tuple, TrackedBatch batch) {
  CoordCondition cond = batch.condition;
  if (cond.commitStream != null
      && tuple.getSourceGlobalStreamid().equals(cond.commitStream)) {
    return TupleType.COMMIT;
  } else if (cond.expectedTaskReports > 0
      && tuple.getSourceStreamId().startsWith(COORD_STREAM_PREFIX)) {
    return TupleType.COORD;
  } else {
    return TupleType.REGULAR;
  }
}

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

public void execute(Tuple input) {
  String component = input.getSourceComponent();
  Map<String, List<FixedTuple>> captured = emitted_tuples.get(_name);
  if (!captured.containsKey(component)) {
    captured.put(component, new ArrayList<FixedTuple>());
  }
  captured.get(component).add(new FixedTuple(input.getSourceStreamId(), input.getValues()));
  _collector.ack(input);
}

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

@Override
public void execute(Tuple input) {
  TMHandler tmHandler = handlers.get(input.getSourceStreamId());
  if (tmHandler == null) {
    LOG.error("No handler of " + input.getSourceStreamId());
    tmContext.getCollector().fail(input);
    return;
  }
  TMEvent event = new TMEvent(tmHandler, input);
  threadPools.submit(event);
  tmContext.getCollector().ack(input);
}

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

/**
 * Gets the names of the fields in this tuple.
 */
public Fields getFields() {
  return context.getComponentOutputFields(getSourceComponent(), getSourceStreamId());
}

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

@Override
public void ack(Tuple input) {
  if (input.getMessageId() != null) {
    if (!sendAckTuple(input)) {
      pendingAckQueue.add(input);
    }
  }
  Long latencyStart = (Long) tupleStartTimes.remove(input);
  taskStats.bolt_acked_tuple(input.getSourceComponent(), input.getSourceStreamId());
  if (latencyStart != null && JStormMetrics.enabled) {
    long endTime = System.currentTimeMillis();
    taskStats.update_bolt_acked_latency(input.getSourceComponent(), input.getSourceStreamId(), latencyStart, endTime);
  }
}

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

@Override
public void fail(Tuple input) {
  // if ackerNum == 0, we can just return
  if (input.getMessageId() != null) {
    pendingAcks.remove(input);
    for (Map.Entry<Long, Long> e : input.getMessageId().getAnchorsToIds().entrySet()) {
      List<Object> ackTuple = JStormUtils.mk_list((Object) e.getKey());
      sendBoltMsg(Acker.ACKER_FAIL_STREAM_ID, null, ackTuple, null, null);
    }
  }
  taskStats.bolt_failed_tuple(input.getSourceComponent(), input.getSourceStreamId());
}

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

public byte[] serialize(Tuple tuple) {
  try {
    _outputter.reset();
    WritableUtils.writeVInt(_dataOutputter, tuple.getSourceTask());
    WritableUtils.writeVInt(_dataOutputter, _ids.getStreamId(tuple.getSourceComponent(), tuple.getSourceStreamId()));
    tuple.getMessageId().serialize(_dataOutputter);
    _kryo.serializeInto(tuple.getValues(), _outputter);
    return _outputter.toByteArray();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

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

@Override
public void fail(Tuple input) {
  // if ackerNum == 0, we can just return
  if (input.getMessageId() != null) {
    pendingAcks.remove(input);
    for (Entry<Long, Long> e : input.getMessageId().getAnchorsToIds().entrySet()) {
      unanchoredSend(topologyContext, sendTargets, taskTransfer, Acker.ACKER_FAIL_STREAM_ID,
          JStormUtils.mk_list((Object) e.getKey()));
    }
  }
  tupleStartTimes.remove(input);
  taskStats.bolt_failed_tuple(input.getSourceComponent(), input.getSourceStreamId());
}

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

@Override
public void ack(Tuple input) {
  Pair<Long, Integer> pendingBatch = tracker.getPendingBatch(((TupleImplExt) input).getBatchId(), input.getSourceStreamId());
  if (pendingBatch != null) {
    long rootId = getRootId(input);
    if (rootId != 0)
      pendingBatch.setFirst(JStormUtils.bit_xor(pendingBatch.getFirst(), rootId));
  }
  delegate.ack(input);
}

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

private BoltMsg createBoltMessage(Tuple input, String genId) {
  BoltMsg boltMsg = new BoltMsg();
  boltMsg.setId(genId);
  boltMsg.setComp(input.getSourceComponent());
  boltMsg.setStream(input.getSourceStreamId());
  boltMsg.setTask(input.getSourceTask());
  boltMsg.setTuple(input.getValues());
  return boltMsg;
}

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

@Override
public void execute(Tuple tuple, BasicOutputCollector collector) {
  TransactionAttempt attempt = (TransactionAttempt) tuple.getValue(0);
  if (tuple.getSourceStreamId().equals(MasterBatchCoordinator.SUCCESS_STREAM_ID)) {
    _state.cleanupBefore(attempt.getTransactionId());
    _coord.success(attempt.getTransactionId());
  } else {
    long txid = attempt.getTransactionId();
    Object prevMeta = _state.getPreviousState(txid);
    Object meta = _coord.initializeTransaction(txid, prevMeta, _state.getState(txid));
    _state.overrideState(txid, meta);
    collector.emit(MasterBatchCoordinator.BATCH_STREAM_ID, new Values(attempt, meta));
  }
}

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

@Override
public void execute(Tuple input) {
  long rootId = getRootId(input);
  if (rootId != 0) {
    long batchId = ((TupleImplExt) input).getBatchId();
    String streamId = input.getSourceStreamId();
    Pair<Long, Integer> pendingBatch = batchXorTracker.getPendingBatch(batchId, streamId, true);
    if (pendingBatch == null) {
      pendingBatch = new Pair<>(0l, 0);
      batchXorTracker.putPendingBatch(batchId, streamId, pendingBatch);
    }
    pendingBatch.setFirst(JStormUtils.bit_xor(pendingBatch.getFirst(), rootId));
    int count = pendingBatch.getSecond();
    pendingBatch.setSecond(++count);
  }
  bolt.execute(input);
}

相关文章