use of org.apache.storm.LocalCluster.Builder in project storm by apache.
the class NettyIntegrationTest method testIntegration.
@Test
public void testIntegration() throws Exception {
Map<String, Object> daemonConf = new HashMap<>();
daemonConf.put(Config.STORM_LOCAL_MODE_ZMQ, true);
daemonConf.put(Config.STORM_MESSAGING_TRANSPORT, "org.apache.storm.messaging.netty.Context");
daemonConf.put(Config.STORM_MESSAGING_NETTY_AUTHENTICATION, false);
daemonConf.put(Config.STORM_MESSAGING_NETTY_BUFFER_SIZE, 1024000);
daemonConf.put(Config.STORM_MESSAGING_NETTY_MIN_SLEEP_MS, 1000);
daemonConf.put(Config.STORM_MESSAGING_NETTY_MAX_SLEEP_MS, 5000);
daemonConf.put(Config.STORM_MESSAGING_NETTY_CLIENT_WORKER_THREADS, 1);
daemonConf.put(Config.STORM_MESSAGING_NETTY_SERVER_WORKER_THREADS, 1);
Builder builder = new Builder().withSimulatedTime().withSupervisors(4).withSupervisorSlotPortMin(6710).withDaemonConf(daemonConf);
try (LocalCluster cluster = builder.build()) {
TopologyBuilder topologyBuilder = new TopologyBuilder();
topologyBuilder.setSpout("1", new TestWordSpout(true), 4);
topologyBuilder.setBolt("2", new TestGlobalCount(), 6).shuffleGrouping("1");
StormTopology topology = topologyBuilder.createTopology();
// important for test that tuples = multiple of 4 and 6
List<FixedTuple> testTuples = Stream.of("a", "b", "a", "b", "a", "b", "a", "b", "a", "b", "a", "b", "a", "b", "a", "b", "a", "b", "a", "b", "a", "b", "a", "b").map(value -> new FixedTuple(new Values(value))).collect(Collectors.toList());
MockedSources mockedSources = new MockedSources(Collections.singletonMap("1", testTuples));
CompleteTopologyParam completeTopologyParams = new CompleteTopologyParam();
completeTopologyParams.setStormConf(Collections.singletonMap(Config.TOPOLOGY_WORKERS, 3));
completeTopologyParams.setMockedSources(mockedSources);
Map<String, List<FixedTuple>> results = Testing.completeTopology(cluster, topology, completeTopologyParams);
assertEquals(6 * 4, Testing.readTuples(results, "2").size());
}
}
Aggregations