use of org.apache.storm.task.TopologyContext in project heron by twitter.
the class CustomStreamGroupingDelegate method prepare.
@Override
public void prepare(com.twitter.heron.api.topology.TopologyContext context, String component, String streamId, List<Integer> targetTasks) {
TopologyContext c = new TopologyContext(context);
GlobalStreamId g = new GlobalStreamId(component, streamId);
delegate.prepare(c, g, targetTasks);
}
use of org.apache.storm.task.TopologyContext in project nifi by apache.
the class TestNiFiBolt method testTickTupleWhenNotExceedingBatchInterval.
@Test
public void testTickTupleWhenNotExceedingBatchInterval() {
final NiFiBolt bolt = new TestableNiFiBolt(siteToSiteClientConfig, niFiDataPacketBuilder, tickFrequency);
// prepare the bolt
Map conf = mock(Map.class);
TopologyContext context = mock(TopologyContext.class);
OutputCollector collector = mock(OutputCollector.class);
bolt.prepare(conf, context, collector);
// process a regular tuple
Tuple dataTuple = MockTupleHelpers.mockTuple("nifi", "nifi");
bolt.execute(dataTuple);
// process a tick tuple
Tuple tickTuple = MockTupleHelpers.mockTickTuple();
bolt.execute(tickTuple);
// should not have produced any NiFiDataPackets
verifyZeroInteractions(niFiDataPacketBuilder);
}
use of org.apache.storm.task.TopologyContext in project metron by apache.
the class ParserBoltTest method testBatchOfFive.
@Test
public void testBatchOfFive() throws Exception {
String sensorType = "yaf";
ParserBolt parserBolt = new ParserBolt("zookeeperUrl", sensorType, parser, new WriterHandler(batchWriter)) {
@Override
protected ConfigurationsUpdater<ParserConfigurations> createUpdater() {
return ParserBoltTest.createUpdater();
}
};
parserBolt.setCuratorFramework(client);
parserBolt.setZKCache(cache);
parserBolt.prepare(new HashMap(), topologyContext, outputCollector);
verify(parser, times(1)).init();
verify(batchWriter, times(1)).init(any(), any(), any());
when(parser.validate(any())).thenReturn(true);
when(parser.parseOptional(any())).thenReturn(Optional.of(ImmutableList.of(new JSONObject())));
when(filter.emitTuple(any(), any(Context.class))).thenReturn(true);
Set<Tuple> tuples = Stream.of(t1, t2, t3, t4, t5).collect(Collectors.toSet());
BulkWriterResponse response = new BulkWriterResponse();
response.addAllSuccesses(tuples);
when(batchWriter.write(eq(sensorType), any(WriterConfiguration.class), eq(tuples), any())).thenReturn(response);
parserBolt.withMessageFilter(filter);
writeNonBatch(outputCollector, parserBolt, t1);
writeNonBatch(outputCollector, parserBolt, t2);
writeNonBatch(outputCollector, parserBolt, t3);
writeNonBatch(outputCollector, parserBolt, t4);
parserBolt.execute(t5);
verify(outputCollector, times(1)).ack(t1);
verify(outputCollector, times(1)).ack(t2);
verify(outputCollector, times(1)).ack(t3);
verify(outputCollector, times(1)).ack(t4);
verify(outputCollector, times(1)).ack(t5);
}
use of org.apache.storm.task.TopologyContext in project metron by apache.
the class ParserBoltTest method testImplicitBatchOfOne.
@Test
public void testImplicitBatchOfOne() throws Exception {
String sensorType = "yaf";
ParserBolt parserBolt = new ParserBolt("zookeeperUrl", sensorType, parser, new WriterHandler(batchWriter)) {
@Override
protected ConfigurationsUpdater<ParserConfigurations> createUpdater() {
return ParserBoltTest.createUpdater();
}
};
parserBolt.setCuratorFramework(client);
parserBolt.setZKCache(cache);
parserBolt.prepare(new HashMap(), topologyContext, outputCollector);
verify(parser, times(1)).init();
verify(batchWriter, times(1)).init(any(), any(), any());
when(parser.validate(any())).thenReturn(true);
when(parser.parseOptional(any())).thenReturn(Optional.of(ImmutableList.of(new JSONObject())));
when(filter.emitTuple(any(), any(Context.class))).thenReturn(true);
BulkWriterResponse response = new BulkWriterResponse();
response.addSuccess(t1);
when(batchWriter.write(eq(sensorType), any(WriterConfiguration.class), eq(Collections.singleton(t1)), any())).thenReturn(response);
parserBolt.withMessageFilter(filter);
parserBolt.execute(t1);
verify(outputCollector, times(1)).ack(t1);
}
use of org.apache.storm.task.TopologyContext in project incubator-heron by apache.
the class IRichBoltDelegate method prepare.
@Override
@SuppressWarnings("rawtypes")
public void prepare(Map<String, Object> conf, com.twitter.heron.api.topology.TopologyContext context, com.twitter.heron.api.bolt.OutputCollector collector) {
topologyContextImpl = new TopologyContext(context);
outputCollectorImpl = new OutputCollectorImpl(collector);
delegate.prepare(conf, topologyContextImpl, outputCollectorImpl);
}
Aggregations