use of storm.trident.testing.Split in project jstorm by alibaba.
the class TridentWindowingInmemoryStoreTopology method buildTopology.
public static StormTopology buildTopology(WindowsStoreFactory windowStore, WindowConfig windowConfig) throws Exception {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3, new Values("the cow jumped over the moon"), new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"), new Values("how many apples can you eat"), new Values("to be or not to be the person"));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout).parallelismHint(16).each(new Fields("sentence"), new Split(), new Fields("word")).window(windowConfig, windowStore, new Fields("word"), new CountAsAggregator(), new Fields("count")).peek(new Consumer() {
@Override
public void accept(TridentTuple input) {
LOG.info("Received tuple: [{}]", input);
}
});
return topology.build();
}
use of storm.trident.testing.Split in project jstorm by alibaba.
the class TridentTumblingCountWindowTest method testTridentTumblingCountWindow.
@Test
public void testTridentTumblingCountWindow() {
WindowsStoreFactory windowsStoreFactory = new InMemoryWindowsStoreFactory();
FixedLimitBatchSpout spout = new FixedLimitBatchSpout(SPOUT_LIMIT, new Fields("sentence"), SPOUT_BATCH_SIZE, new Values("the cow jumped over the moon"), new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"), new Values("how many apples can you eat"), new Values("to be or not to be the person"));
TridentTopology tridentTopology = new TridentTopology();
Stream stream = tridentTopology.newStream("spout1", spout).parallelismHint(16).each(new Fields("sentence"), new Split(), new Fields("word")).window(windowConfig, windowsStoreFactory, new Fields("word"), new CountAsAggregator(), new Fields("count")).peek(new ValidateConsumer());
Map config = new HashMap();
config.put(Config.TOPOLOGY_NAME, "TridentTumblingCountWindowTest");
JStormUnitTestRunner.submitTopology(tridentTopology.build(), null, 120, null);
}
use of storm.trident.testing.Split in project jstorm by alibaba.
the class TridentTumblingDurationWindowTest method testTridentTumblingDurationWindow.
@Test
public void testTridentTumblingDurationWindow() {
WindowsStoreFactory windowsStoreFactory = new InMemoryWindowsStoreFactory();
FixedLimitBatchSpout spout = new FixedLimitBatchSpout(SPOUT_LIMIT, new Fields("sentence"), SPOUT_BATCH_SIZE, new Values("the cow jumped over the moon"), new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"), new Values("how many apples can you eat"), new Values("to be or not to be the person"));
TridentTopology tridentTopology = new TridentTopology();
Stream stream = tridentTopology.newStream("spout1", spout).parallelismHint(16).each(new Fields("sentence"), new Split(), new Fields("word")).window(windowConfig, windowsStoreFactory, new Fields("word"), new CountAsAggregator(), new Fields("count")).peek(new ValidateConsumer());
Map config = new HashMap();
config.put(Config.TOPOLOGY_NAME, "TridentTumblingDurationWindowTest");
JStormUnitTestRunner.submitTopology(tridentTopology.build(), null, 120, null);
}
use of storm.trident.testing.Split in project jstorm by alibaba.
the class TridentSlidingCountWindowTest method testTridentSlidingCountWindow.
@Test
public void testTridentSlidingCountWindow() {
WindowsStoreFactory windowsStoreFactory = new InMemoryWindowsStoreFactory();
FixedLimitBatchSpout spout = new FixedLimitBatchSpout(SPOUT_LIMIT, new Fields("sentence"), SPOUT_BATCH_SIZE, new Values("the cow jumped over the moon"), new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"), new Values("how many apples can you eat"), new Values("to be or not to be the person"));
TridentTopology tridentTopology = new TridentTopology();
Stream stream = tridentTopology.newStream("spout1", spout).parallelismHint(16).each(new Fields("sentence"), new Split(), new Fields("word")).window(windowConfig, windowsStoreFactory, new Fields("word"), new CountAsAggregator(), new Fields("count")).peek(new ValidateConsumer());
Map config = new HashMap();
config.put(Config.TOPOLOGY_NAME, "TridentSlidingCountWindowTest");
JStormUnitTestRunner.submitTopology(tridentTopology.build(), null, 120, null);
}
use of storm.trident.testing.Split in project jstorm by alibaba.
the class TridentSlidingDurationWindowTest method testTridentSlidingDurationWindow.
@Test
public void testTridentSlidingDurationWindow() {
WindowsStoreFactory windowsStoreFactory = new InMemoryWindowsStoreFactory();
FixedLimitBatchSpout spout = new FixedLimitBatchSpout(SPOUT_LIMIT, new Fields("sentence"), SPOUT_BATCH_SIZE, new Values("the cow jumped over the moon"), new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"), new Values("how many apples can you eat"), new Values("to be or not to be the person"));
TridentTopology tridentTopology = new TridentTopology();
Stream stream = tridentTopology.newStream("spout1", spout).parallelismHint(16).each(new Fields("sentence"), new Split(), new Fields("word")).window(windowConfig, windowsStoreFactory, new Fields("word"), new CountAsAggregator(), new Fields("count")).peek(new ValidateConsumer());
Map config = new HashMap();
config.put(Config.TOPOLOGY_NAME, "TridentSlidingDurationWindowTest");
JStormUnitTestRunner.submitTopology(tridentTopology.build(), null, 120, null);
}
Aggregations