本文整理了Java中backtype.storm.task.TopologyContext.getComponentId()
方法的一些代码示例,展示了TopologyContext.getComponentId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TopologyContext.getComponentId()
方法的具体详情如下:
包路径:backtype.storm.task.TopologyContext
类名称:TopologyContext
方法名:getComponentId
[英]Gets the component id for the specified task id. The component id maps to a component id specified for a Spout or Bolt in the topology definition.
[中]获取指定任务id的组件id。该组件id映射到拓扑定义中为喷口或螺栓指定的组件id。
代码示例来源:origin: alibaba/jstorm
/**
* Gets the component id for this task. The component id maps to a component id specified for a Spout or Bolt
* in the topology definition.
*/
public String getThisComponentId() {
return getComponentId(_taskId);
}
代码示例来源:origin: alibaba/mdrill
/**
* Gets the id of the component that created this tuple.
*/
public String getSourceComponent() {
return context.getComponentId(taskId);
}
代码示例来源:origin: alibaba/mdrill
/**
* Gets the component id for this task. The component id maps
* to a component id specified for a Spout or Bolt in the topology definition.
* @return
*/
public String getThisComponentId() {
return getComponentId(_taskId);
}
代码示例来源:origin: alibaba/jstorm
private TransactionState getLastestCommittedState(int taskId) {
TransactionState ret = null;
String componentId = context.getComponentId(taskId);
TreeSet<Long> batchIds = new TreeSet<Long>(inprogressSnapshots.keySet());
Long batchId = null;
while ((batchId = batchIds.pollLast()) != null) {
BatchStateTracker tracker = inprogressSnapshots.get(batchId);
Map<Integer, TransactionState> states = tracker.getComponentStates(componentId);
if (states != null && (ret = states.get(taskId)) != null)
break;
}
return ret;
}
代码示例来源:origin: alibaba/mdrill
public Tuple(TopologyContext context, List<Object> values, int taskId, String streamId, MessageId id) {
super();
this.values = values;
this.taskId = taskId;
this.streamId = streamId;
this.id = id;
this.context = context;
String componentId = context.getComponentId(taskId);
Fields schema = context.getComponentOutputFields(componentId, streamId);
if(values.size()!=schema.size()) {
throw new IllegalArgumentException(
"Tuple created with wrong number of fields. " +
"Expected " + schema.size() + " fields but got " +
values.size() + " fields");
}
}
代码示例来源:origin: alibaba/mdrill
public java.util.Set<Integer> get(Integer out_task_id, String stream, List<Object> tuple) {
if (stormConf.get(Config.TOPOLOGY_DEBUG).equals(Boolean.TRUE)) {
LOG.info("Emitting direct: " + out_task_id + "; " + taskReadableName + " " + stream );
}
String target_component = topologyContext.getComponentId(out_task_id);
Map<String, MkGrouper> component_prouping = streamComponentgrouper.get(stream);
MkGrouper grouping = component_prouping.get(target_component);
if (grouping != null && !GrouperType.direct.equals(grouping.gettype())) {
throw new IllegalArgumentException("Cannot emitDirect to a task expecting a regular grouping");
}
// ͳ
if (emitSampler.getResult()) {
Stats.emitted_tuple(taskStats, stream);
if (out_task_id != null) {
Stats.transferred_tuples(taskStats, stream, 1);
}
}
java.util.Set<Integer> out_tasks = new HashSet<Integer>();
out_tasks.add(out_task_id);
return out_tasks;
}
代码示例来源:origin: alibaba/mdrill
public Tuple deserialize(byte[] ser) {
try {
ByteArrayInputStream bin = new ByteArrayInputStream(ser);
DataInputStream in = new DataInputStream(bin);
int taskId = WritableUtils.readVInt(in);
int streamId = WritableUtils.readVInt(in);
String componentName = _context.getComponentId(taskId);
String streamName = _ids.getStreamName(componentName, streamId);
MessageId id = MessageId.deserialize(in);
List<Object> values = _kryo.deserializeFrom(bin);
return new Tuple(_context, values, taskId, streamName, id);
} catch(IOException e) {
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: alibaba/jstorm
CustomStreamGrouping g = Thrift.instantiateJavaObject(jobj);
int myTaskId = topologyContext.getThisTaskId();
String componentId = topologyContext.getComponentId(myTaskId);
GlobalStreamId stream = new GlobalStreamId(componentId, streamId);
customGrouper = new MkCustomGrouper(topologyContext, g, stream, outTasks, myTaskId);
CustomStreamGrouping g = (CustomStreamGrouping) Utils.javaDeserialize(obj);
int myTaskId = topologyContext.getThisTaskId();
String componentId = topologyContext.getComponentId(myTaskId);
GlobalStreamId stream = new GlobalStreamId(componentId, streamId);
customGrouper = new MkCustomGrouper(topologyContext, g, stream, outTasks, myTaskId);
代码示例来源:origin: com.alibaba.jstorm/jstorm-core
/**
* Gets the component id for this task. The component id maps to a component id specified for a Spout or Bolt in the topology definition.
*
* @return
*/
public String getThisComponentId() {
return getComponentId(_taskId);
}
代码示例来源:origin: com.n3twork.storm/storm-core
/**
* Gets the component id for this task. The component id maps
* to a component id specified for a Spout or Bolt in the topology definition.
* @return
*/
public String getThisComponentId() {
return getComponentId(_taskId);
}
代码示例来源:origin: apache/eagle
private int calculatePartitionId(TopologyContext context) {
int thisGlobalTaskId = context.getThisTaskId();
String componentName = context.getComponentId(thisGlobalTaskId);
List<Integer> globalTaskIds = context.getComponentTasks(componentName);
numTotalPartitions = globalTaskIds.size();
int index = 0;
for (Integer id : globalTaskIds) {
if (id == thisGlobalTaskId) {
return index;
}
index++;
}
throw new IllegalStateException();
}
代码示例来源:origin: apache/eagle
private int calculatePartitionId(TopologyContext context) {
int thisGlobalTaskId = context.getThisTaskId();
String componentName = context.getComponentId(thisGlobalTaskId);
List<Integer> globalTaskIds = context.getComponentTasks(componentName);
int index = 0;
for (Integer id : globalTaskIds) {
if (id == thisGlobalTaskId) {
return index;
}
index++;
}
throw new IllegalStateException();
}
代码示例来源:origin: org.apache.eagle/eagle-storm-jobrunning-spout
/**
* TODO: just copy this part from jobHistorySpout, need to move it to a common place
* @param context
* @return
*/
private int calculatePartitionId(TopologyContext context){
int thisGlobalTaskId = context.getThisTaskId();
String componentName = context.getComponentId(thisGlobalTaskId);
List<Integer> globalTaskIds = context.getComponentTasks(componentName);
int index = 0;
for(Integer id : globalTaskIds){
if(id == thisGlobalTaskId){
return index;
}
index++;
}
throw new IllegalStateException();
}
代码示例来源:origin: com.alibaba.jstorm/jstorm-core
CustomStreamGrouping g = Thrift.instantiateJavaObject(jobj);
int myTaskId = topology_context.getThisTaskId();
String componentId = topology_context.getComponentId(myTaskId);
GlobalStreamId stream = new GlobalStreamId(componentId, streamId);
custom_grouper = new MkCustomGrouper(topology_context, g, stream, out_tasks, myTaskId);
CustomStreamGrouping g = (CustomStreamGrouping) Utils.javaDeserialize(obj);
int myTaskId = topology_context.getThisTaskId();
String componentId = topology_context.getComponentId(myTaskId);
GlobalStreamId stream = new GlobalStreamId(componentId, streamId);
custom_grouper = new MkCustomGrouper(topology_context, g, stream, out_tasks, myTaskId);
内容来源于网络,如有侵权,请联系作者删除!