use of org.apache.storm.task.OutputCollector in project storm by apache.
the class KafkaBoltTest method generateDefaultSerializerBolt.
private KafkaBolt generateDefaultSerializerBolt(boolean async, boolean fireAndForget, KafkaProducer<?, ?> mockProducer) {
Properties props = new Properties();
props.put("acks", "1");
props.put("bootstrap.servers", broker.getBrokerConnectionString());
props.put("key.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
props.put("metadata.fetch.timeout.ms", 1000);
props.put("linger.ms", 0);
KafkaBolt bolt = new KafkaBolt().withProducerProperties(props);
bolt.prepare(config, null, new OutputCollector(collector));
bolt.setAsync(async);
bolt.setFireAndForget(fireAndForget);
if (mockProducer != null) {
Whitebox.setInternalState(bolt, "producer", mockProducer);
}
return bolt;
}
use of org.apache.storm.task.OutputCollector in project storm by apache.
the class KafkaBoltTest method defaultSerializerBoltWithSpecifiedProperties.
private KafkaBolt defaultSerializerBoltWithSpecifiedProperties(boolean async, boolean fireAndForget) {
Properties props = new Properties();
props.put("acks", "1");
props.put("bootstrap.servers", broker.getBrokerConnectionString());
props.put("key.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
props.put("metadata.fetch.timeout.ms", 1000);
props.put("linger.ms", 0);
KafkaBolt bolt = new KafkaBolt().withProducerProperties(props);
bolt.prepare(config, null, new OutputCollector(collector));
bolt.setAsync(async);
bolt.setFireAndForget(fireAndForget);
return bolt;
}
use of org.apache.storm.task.OutputCollector in project storm by apache.
the class CoordinatedBolt method prepare.
public void prepare(Map config, TopologyContext context, OutputCollector collector) {
TimeCacheMap.ExpiredCallback<Object, TrackingInfo> callback = null;
if (_delegate instanceof TimeoutCallback) {
callback = new TimeoutItems();
}
_tracked = new TimeCacheMap<>(context.maxTopologyMessageTimeout(), callback);
_collector = collector;
_delegate.prepare(config, context, new OutputCollector(new CoordinatedOutputCollector(collector)));
for (String component : Utils.get(context.getThisTargets(), Constants.COORDINATED_STREAM_ID, new HashMap<String, Grouping>()).keySet()) {
for (Integer task : context.getComponentTasks(component)) {
_countOutTasks.add(task);
}
}
if (!_sourceArgs.isEmpty()) {
_numSourceReports = 0;
for (Entry<String, SourceArgs> entry : _sourceArgs.entrySet()) {
if (entry.getValue().singleCount) {
_numSourceReports += 1;
} else {
_numSourceReports += context.getComponentTasks(entry.getKey()).size();
}
}
}
}
use of org.apache.storm.task.OutputCollector in project flink by apache.
the class BoltWrapper method open.
@Override
public void open() throws Exception {
super.open();
this.flinkCollector = new TimestampedCollector<>(this.output);
GlobalJobParameters config = getExecutionConfig().getGlobalJobParameters();
StormConfig stormConfig = new StormConfig();
if (config != null) {
if (config instanceof StormConfig) {
stormConfig = (StormConfig) config;
} else {
stormConfig.putAll(config.toMap());
}
}
this.topologyContext = WrapperSetupHelper.createTopologyContext(getRuntimeContext(), this.bolt, this.name, this.stormTopology, stormConfig);
final OutputCollector stormCollector = new OutputCollector(new BoltCollector<OUT>(this.numberOfAttributes, this.topologyContext.getThisTaskId(), this.flinkCollector));
if (this.stormTopology != null) {
Map<GlobalStreamId, Grouping> inputs = this.topologyContext.getThisSources();
for (GlobalStreamId inputStream : inputs.keySet()) {
for (Integer tid : this.topologyContext.getComponentTasks(inputStream.get_componentId())) {
this.inputComponentIds.put(tid, inputStream.get_componentId());
this.inputStreamIds.put(tid, inputStream.get_streamId());
this.inputSchemas.put(tid, this.topologyContext.getComponentOutputFields(inputStream));
}
}
}
this.bolt.prepare(stormConfig, this.topologyContext, stormCollector);
}
use of org.apache.storm.task.OutputCollector in project open-kilda by telstra.
the class OFELinkBoltTest method before.
@Before
public void before() throws CmdLineException, ConfigurationException {
OFEventWFMTopology manager = new OFEventWFMTopology(AbstractStormTest.makeLaunchEnvironment());
config = manager.getConfig();
bolt = new OFELinkBolt(config);
context = Mockito.mock(TopologyContext.class);
Mockito.when(context.getComponentId(TASK_ID_BOLT)).thenReturn(COMPONENT_ID_SOURCE);
Mockito.when(context.getComponentOutputFields(COMPONENT_ID_SOURCE, STREAM_ID_INPUT)).thenReturn(KafkaMessage.FORMAT);
outputDelegate = Mockito.spy(new OutputCollectorMock());
OutputCollector output = new OutputCollector(outputDelegate);
bolt.prepare(stormConfig(), context, output);
bolt.initState(new InMemoryKeyValueState<>());
}
Aggregations