Search in sources :

Example 1 with InMemoryWindowsStoreFactory

use of org.apache.storm.trident.windowing.InMemoryWindowsStoreFactory in project storm by apache.

the class TridentWindowingInmemoryStoreTopology method main.

public static void main(String[] args) throws Exception {
    Config conf = new Config();
    WindowsStoreFactory mapState = new InMemoryWindowsStoreFactory();
    if (args.length == 0) {
        List<? extends WindowConfig> list = Arrays.asList(SlidingCountWindow.of(1000, 100), TumblingCountWindow.of(1000), SlidingDurationWindow.of(new BaseWindowedBolt.Duration(6, TimeUnit.SECONDS), new BaseWindowedBolt.Duration(3, TimeUnit.SECONDS)), TumblingDurationWindow.of(new BaseWindowedBolt.Duration(3, TimeUnit.SECONDS)));
        for (WindowConfig windowConfig : list) {
            try (LocalCluster cluster = new LocalCluster();
                LocalTopology topo = cluster.submitTopology("wordCounter", conf, buildTopology(mapState, windowConfig))) {
                Utils.sleep(60 * 1000);
            }
        }
        System.exit(0);
    } else {
        conf.setNumWorkers(3);
        StormSubmitter.submitTopologyWithProgressBar(args[0], conf, buildTopology(mapState, SlidingCountWindow.of(1000, 100)));
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) Config(org.apache.storm.Config) InMemoryWindowsStoreFactory(org.apache.storm.trident.windowing.InMemoryWindowsStoreFactory) WindowsStoreFactory(org.apache.storm.trident.windowing.WindowsStoreFactory) InMemoryWindowsStoreFactory(org.apache.storm.trident.windowing.InMemoryWindowsStoreFactory) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Aggregations

Config (org.apache.storm.Config)1 LocalCluster (org.apache.storm.LocalCluster)1 LocalTopology (org.apache.storm.LocalCluster.LocalTopology)1 InMemoryWindowsStoreFactory (org.apache.storm.trident.windowing.InMemoryWindowsStoreFactory)1 WindowsStoreFactory (org.apache.storm.trident.windowing.WindowsStoreFactory)1