org.apache.storm.tuple.Tuple.getSourceTask()方法的使用及代码示例

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

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

Tuple.getSourceTask介绍

[英]Gets the id of the task that created this tuple.
[中]获取创建此元组的任务的id。

代码示例

代码示例来源:origin: apache/storm

static TaskStream fromTuple(Tuple input) {
  return new TaskStream(input.getSourceTask(), input.getSourceGlobalStreamId());
}

代码示例来源:origin: apache/storm

@Override
public void execute(Tuple tuple) {
  Object obj = tuple.getValue(0);
  long count = tuple.getLong(1);
  int source = tuple.getSourceTask();
  Map<Integer, Long> subCounts = counts.get(obj);
  if (subCounts == null) {
    subCounts = new HashMap<Integer, Long>();
    counts.put(obj, subCounts);
  }
  //Update the current count for this object
  subCounts.put(source, count);
  //Output the sum of all the known counts so for this key
  long sum = 0;
  for (Long val : subCounts.values()) {
    sum += val;
  }
  collector.emit(new Values(obj, sum));
}

代码示例来源:origin: apache/storm

@Override
public void recv(List<TaskMessage> batch) {
  KryoTupleDeserializer des = _des.get();
  ArrayList<AddressedTuple> ret = new ArrayList<>(batch.size());
  for (TaskMessage message : batch) {
    Tuple tuple = des.deserialize(message.message());
    AddressedTuple addrTuple = new AddressedTuple(message.task(), tuple);
    updateMetrics(tuple.getSourceTask(), message);
    ret.add(addrTuple);
  }
  cb.transfer(ret);
}

代码示例来源:origin: apache/storm

private List<Tuple> getMockTuples(int count) {
    List<Tuple> mockTuples = new ArrayList<>();
    for (long i = 0; i < count; i++) {
      Tuple mockTuple = Mockito.mock(Tuple.class);
      Mockito.when(mockTuple.getLongByField("msgid")).thenReturn(i);
      Mockito.when(mockTuple.getSourceTask()).thenReturn(1);
      Mockito.when(mockTuple.getSourceGlobalStreamId()).thenReturn(new GlobalStreamId("a", "s"));
      mockTuples.add(mockTuple);
    }
    return mockTuples;
  }
}

代码示例来源:origin: apache/storm

@Override
public void execute(Tuple input) {
  LOG.debug("** EventLoggerBolt got tuple from sourceComponent {}, with values {}", input.getSourceComponent(), input.getValues());
  Object msgId = input.getValueByField(FIELD_MESSAGE_ID);
  EventInfo eventInfo = new EventInfo(input.getLongByField(FIELD_TS), input.getSourceComponent(),
                    input.getSourceTask(), msgId, (List<Object>) input.getValueByField(FIELD_VALUES));
  for (IEventLogger eventLogger : eventLoggers) {
    eventLogger.log(eventInfo);
  }
}

代码示例来源:origin: apache/storm

public TupleImpl(Tuple t) {
  this.values = t.getValues();
  this.taskId = t.getSourceTask();
  this.streamId = t.getSourceStreamId();
  this.id = t.getMessageId();
  this.context = t.getContext();
  this.srcComponent = t.getSourceComponent();
  try {
    TupleImpl ti = (TupleImpl) t;
    this._processSampleStartTime = ti._processSampleStartTime;
    this._executeSampleStartTime = ti._executeSampleStartTime;
    this._outAckVal = ti._outAckVal;
  } catch (ClassCastException e) {
    // ignore ... if t is not a TupleImpl type .. faster than checking and then casting
  }
}

代码示例来源:origin: apache/storm

public byte[] serialize(Tuple tuple) {
  try {
    _kryoOut.clear();
    _kryoOut.writeInt(tuple.getSourceTask(), true);
    _kryoOut.writeInt(_ids.getStreamId(tuple.getSourceComponent(), tuple.getSourceStreamId()), true);
    tuple.getMessageId().serialize(_kryoOut);
    _kryo.serializeInto(tuple.getValues(), _kryoOut);
    return _kryoOut.toBytes();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: apache/storm

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: apache/storm

return;
} else {
  LOG.warn("Unknown source stream {} from task-{}", streamId, input.getSourceTask());
  return;

代码示例来源:origin: org.apache.storm/storm-core

static TaskStream fromTuple(Tuple input) {
    return new TaskStream(input.getSourceTask(), input.getSourceGlobalStreamId());
  }
}

代码示例来源:origin: Paleozoic/storm_spring_boot_demo

@Override
public void execute(Tuple tuple) {
 Object obj = tuple.getValue(0);
 long count = tuple.getLong(1);
 int source = tuple.getSourceTask();
 Map<Integer, Long> subCounts = counts.get(obj);
 if (subCounts == null) {
  subCounts = new HashMap<Integer, Long>();
  counts.put(obj, subCounts);
 }
 //Update the current count for this object
 subCounts.put(source, count);
 //Output the sum of all the known counts so for this key
 long sum = 0;
 for (Long val: subCounts.values()) {
  sum += val;
 }
 collector.emit(new Values(obj, sum));
}

代码示例来源:origin: org.apache.storm/storm-core

@Override
public void execute(Tuple input) {
  LOG.debug("** EventLoggerBolt got tuple from sourceComponent {}, with values {}", input.getSourceComponent(), input.getValues());
  Object msgId = input.getValueByField(FIELD_MESSAGE_ID);
  EventInfo eventInfo = new EventInfo(input.getLongByField(FIELD_TS), input.getSourceComponent(),
                    input.getSourceTask(), msgId, (List<Object>) input.getValueByField(FIELD_VALUES));
  for (IEventLogger eventLogger : eventLoggers) {
    eventLogger.log(eventInfo);
  }
}

代码示例来源:origin: org.apache.storm/storm-core

public byte[] serialize(Tuple tuple) {
  try {
    
    _kryoOut.clear();
    _kryoOut.writeInt(tuple.getSourceTask(), true);
    _kryoOut.writeInt(_ids.getStreamId(tuple.getSourceComponent(), tuple.getSourceStreamId()), true);
    tuple.getMessageId().serialize(_kryoOut);
    _kryo.serializeInto(tuple.getValues(), _kryoOut);
    return _kryoOut.toBytes();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.apache.storm/storm-core

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

相关文章