use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class ExclamationTopology method getStormTopology.
public static StormTopology getStormTopology() {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(WORD, new FixedOrderWordSpout(), SPOUT_EXECUTORS);
builder.setBolt(EXCLAIM_1, new ExclamationTopology.ExclamationBolt(), 3).shuffleGrouping(WORD);
builder.setBolt(EXCLAIM_2, new ExclamationTopology.ExclamationBolt(), EXCLAIM_2_EXECUTORS).shuffleGrouping(EXCLAIM_1);
return builder.createTopology();
}
use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class SlidingTimeCorrectness method newTopology.
@Override
public StormTopology newTopology() {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(getSpoutName(), new TimeDataIncrementingSpout(), spoutExecutors);
builder.setBolt(getBoltName(), new TimeDataVerificationBolt().withWindow(new BaseWindowedBolt.Duration(windowSec, TimeUnit.SECONDS), new BaseWindowedBolt.Duration(slideSec, TimeUnit.SECONDS)).withTimestampField(TimeData.getTimestampFieldName()).withLag(new BaseWindowedBolt.Duration(10, TimeUnit.SECONDS)), boltExecutors).globalGrouping(getSpoutName());
return builder.createTopology();
}
use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class TumblingTimeCorrectness method newTopology.
@Override
public StormTopology newTopology() {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(getSpoutName(), new TimeDataIncrementingSpout(), spoutExecutors);
builder.setBolt(getBoltName(), new TimeDataVerificationBolt().withTumblingWindow(new BaseWindowedBolt.Duration(tumbleSec, TimeUnit.SECONDS)).withLag(new BaseWindowedBolt.Duration(10, TimeUnit.SECONDS)).withTimestampField(TimeData.getTimestampFieldName()), boltExecutors).globalGrouping(getSpoutName());
return builder.createTopology();
}
use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class StreamBuilder method build.
/**
* Builds a new {@link StormTopology} for the computation expressed via the stream api.
*
* @return the storm topology
*/
public StormTopology build() {
nodeGroupingInfo.clear();
windowInfo.clear();
curGroup.clear();
TopologicalOrderIterator<Node, Edge> iterator = new TopologicalOrderIterator<>(graph, queue());
TopologyBuilder topologyBuilder = new TopologyBuilder();
while (iterator.hasNext()) {
Node node = iterator.next();
if (node instanceof SpoutNode) {
addSpout(topologyBuilder, (SpoutNode) node);
} else if (node instanceof ProcessorNode) {
handleProcessorNode((ProcessorNode) node, topologyBuilder);
} else if (node instanceof PartitionNode) {
updateNodeGroupingInfo((PartitionNode) node);
processCurGroup(topologyBuilder);
} else if (node instanceof WindowNode) {
updateWindowInfo((WindowNode) node);
processCurGroup(topologyBuilder);
} else if (node instanceof SinkNode) {
processCurGroup(topologyBuilder);
addSink(topologyBuilder, (SinkNode) node);
}
}
processCurGroup(topologyBuilder);
mayBeAddTsField();
return topologyBuilder.createTopology();
}
use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class TopologyIntegrationTest method testTimeout.
@Test
public void testTimeout() throws Exception {
try (LocalCluster cluster = new LocalCluster.Builder().withSimulatedTime().withSupervisors(4).withDaemonConf(Collections.singletonMap(Config.TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS, true)).build()) {
FeederSpout feeder = new FeederSpout(new Fields("field1"));
AckFailMapTracker tracker = new AckFailMapTracker();
feeder.setAckFailDelegate(tracker);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("1", feeder);
builder.setBolt("2", new AckEveryOtherBolt()).globalGrouping("1");
StormTopology topology = builder.createTopology();
cluster.submitTopology("timeout-tester", Collections.singletonMap(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 10), topology);
cluster.advanceClusterTime(11);
feeder.feed(new Values("a"), 1);
feeder.feed(new Values("b"), 2);
feeder.feed(new Values("c"), 3);
cluster.advanceClusterTime(9);
assertAcked(tracker, 1, 3);
assertThat(tracker.isFailed(2), is(false));
cluster.advanceClusterTime(12);
assertFailed(tracker, 2);
}
}
Aggregations