@Override public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) { componentId = context.getThisComponentId(); this.collector = collector; }
@Override public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) { componentId = context.getThisComponentId(); this.collector = collector; }
@Override public void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector) { componentId = context.getThisComponentId(); this.collector = collector; }
@Override public void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector) { componentId = context.getThisComponentId(); this.collector = collector; }
/** * Gets the set of streams declared for the component of this task. */ public Set<String> getThisStreams() { return getComponentStreams(getThisComponentId()); }
/** * 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); }
/** * 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()); }
@Override public void prepare(Map<String, Object> conf, TopologyContext topologyContext) { this.componentId = topologyContext.getThisComponentId(); this.taskId = topologyContext.getThisTaskId(); }
/** * 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()); }
@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; } }
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; }
@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); } }
/** * {@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(); }
@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); } }
@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); }
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); }
@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()); }
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(); }
@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)); }
@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); }