org.apache.storm.task.TopologyContext.getThisComponentId()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(93)

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

TopologyContext.getThisComponentId介绍

暂无

代码示例

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

@Override
public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) {
  componentId = context.getThisComponentId();
  this.collector = collector;
}

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

@Override
public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) {
  componentId = context.getThisComponentId();
  this.collector = collector;
}

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

@Override
public void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector) {
  componentId = context.getThisComponentId();
  this.collector = collector;
}

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

@Override
public void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector) {
  componentId = context.getThisComponentId();
  this.collector = collector;
}

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

/**
 * Gets the set of streams declared for the component of this task.
 */
public Set<String> getThisStreams() {
  return getComponentStreams(getThisComponentId());
}

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

/**
 * Gets the declared output fields for the specified stream id for the component this task is a part of.
 */
public Fields getThisOutputFields(String streamId) {
  return getComponentOutputFields(getThisComponentId(), streamId);
}

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

/**
 * Gets the declared inputs to this component.
 *
 * @return A map from subscribed component/stream to the grouping subscribed with.
 */
public Map<GlobalStreamId, Grouping> getThisSources() {
  return getSources(getThisComponentId());
}

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

@Override
public void prepare(Map<String, Object> conf, TopologyContext topologyContext) {
  this.componentId = topologyContext.getThisComponentId();
  this.taskId = topologyContext.getThisTaskId();
}

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

/**
 * Gets information about who is consuming the outputs of this component, and how.
 *
 * @return Map from stream id to component id to the Grouping used.
 */
public Map<String, Map<String, Grouping>> getThisTargets() {
  return getTargets(getThisComponentId());
}

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

@Override
  public Set<TopicPartition> getPartitionsForThisTask(List<TopicPartition> allPartitionsSorted, TopologyContext context) {
    int thisTaskIndex = context.getThisTaskIndex();
    int totalTaskCount = context.getComponentTasks(context.getThisComponentId()).size();
    Set<TopicPartition> myPartitions = new HashSet<>(allPartitionsSorted.size() / totalTaskCount + 1);
    for (int i = thisTaskIndex; i < allPartitionsSorted.size(); i += totalTaskCount) {
      myPartitions.add(allPartitionsSorted.get(i));
    }
    return myPartitions;
  }
}

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

public void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector) {
  _collector = collector;
  this.source = context.getThisTaskId();
  long taskCount = context.getComponentTasks(context.getThisComponentId()).size();
  myCount = totalCount / taskCount;
}

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

@SuppressWarnings("unchecked")
@Override
public void prepare(Map<String, Object> conf, TopologyContext topologyContext) {
  this.componentId = topologyContext.getThisComponentId();
  this.taskId = topologyContext.getThisTaskId();
  try {
    this.host = Utils.localHostname();
  } catch (UnknownHostException e) {
    throw new RuntimeException(e);
  }
}

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

/**
 * {@inheritDoc}
 */
@Override
public void prepare(Map<String, Object> topoConfig, TopologyContext topologyContext, OutputCollector outputCollector) {
  super.prepare(topoConfig, topologyContext, outputCollector);
  this.componentID = topologyContext.getThisComponentId();
  this.queue = new LinkedBlockingQueue<>(batchMaxSize);
  this.lastModifiedTimesMillis = now();
}

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

@Override
public void prepare(Map<String, Object> conf, TopologyContext context, OutputCollector collector) {
  this.collector = collector;
  this.topologyName = (String) conf.get(Config.TOPOLOGY_NAME);
  this.publisher = new MqttPublisher(this.options, this.keyStoreLoader, this.retain);
  try {
    this.publisher.connectMqtt(this.topologyName + "-" + context.getThisComponentId() + "-" + context.getThisTaskId());
  } catch (Exception e) {
    LOG.error("Unable to connect to MQTT Broker.", e);
    throw new RuntimeException("Unable to connect to MQTT Broker.", e);
  }
}

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

@Override
public BatchCoordinator<Map<Integer, List<List<Object>>>> getCoordinator(String txStateId, Map<String, Object> conf,
                                     TopologyContext context) {
  int numTasks = context.getComponentTasks(
    TridentTopologyBuilder.spoutIdFromCoordinatorId(
      context.getThisComponentId()))
             .size();
  return new FeederCoordinator(numTasks);
}

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

public Emitter(String txStateId, Map<String, Object> conf, TopologyContext context) {
  _emitter = _spout.getEmitter(conf, context);
  _index = context.getThisTaskIndex();
  _numTasks = context.getComponentTasks(context.getThisComponentId()).size();
  _state = TransactionalState.newUserState(conf, txStateId);
  LOG.debug("Created {}", this);
}

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

@Override
public void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector) {
  this.collector = collector;
  kinesisRecordsManager = new KinesisRecordsManager(kinesisConfig);
  kinesisRecordsManager.initialize(context.getThisTaskIndex(), context.getComponentTasks(context.getThisComponentId()).size());
}

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

public Emitter(String txStateId, Map<String, Object> conf, TopologyContext context) {
  _emitter = _spout.getEmitter(conf, context);
  _state = TransactionalState.newUserState(conf, txStateId);
  _index = context.getThisTaskIndex();
  _numTasks = context.getComponentTasks(context.getThisComponentId()).size();
}

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

@Override
public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) {
  // get the last successfully committed state from state store
  String namespace = context.getThisComponentId() + "-" + context.getThisTaskId();
  prepare(topoConf, context, collector, StateFactory.getState(namespace, topoConf, context));
}

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

@Before
public void setUp() throws Exception {
  mockTopologyContext = Mockito.mock(TopologyContext.class);
  Mockito.when(mockTopologyContext.getThisComponentId()).thenReturn("test");
  Mockito.when(mockTopologyContext.getThisTaskId()).thenReturn(1);
  mockOutputCollector = Mockito.mock(SpoutOutputCollector.class);
}

相关文章

微信公众号

最新文章

更多