Search in sources :

Example 1 with WindowConfig

use of storm.trident.windowing.config.WindowConfig in project jstorm by alibaba.

the class TridentWindowingInmemoryStoreTopology method test.

public static void test() {
    String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
    String topologyName = className[className.length - 1];
    try {
        WindowsStoreFactory mapState = new InMemoryWindowsStoreFactory();
        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) {
            LocalCluster cluster = new LocalCluster();
            cluster.submitTopology("wordCounter", conf, buildTopology(mapState, windowConfig));
            Utils.sleep(60 * 1000);
            cluster.shutdown();
        }
        for (WindowConfig windowConfig : list) {
            String name = topologyName + "." + windowConfig.getWindowLength() + "." + windowConfig.getSlidingLength();
            JStormHelper.runTopology(buildTopology(mapState, windowConfig), name, conf, 60, new JStormHelper.CheckAckedFail(conf), isLocal);
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Assert.fail("Failed");
    }
}
Also used : WindowConfig(storm.trident.windowing.config.WindowConfig) LocalCluster(backtype.storm.LocalCluster) JStormHelper(com.alibaba.starter.utils.JStormHelper) InMemoryWindowsStoreFactory(storm.trident.windowing.InMemoryWindowsStoreFactory) WindowsStoreFactory(storm.trident.windowing.WindowsStoreFactory) InMemoryWindowsStoreFactory(storm.trident.windowing.InMemoryWindowsStoreFactory)

Aggregations

LocalCluster (backtype.storm.LocalCluster)1 JStormHelper (com.alibaba.starter.utils.JStormHelper)1 InMemoryWindowsStoreFactory (storm.trident.windowing.InMemoryWindowsStoreFactory)1 WindowsStoreFactory (storm.trident.windowing.WindowsStoreFactory)1 WindowConfig (storm.trident.windowing.config.WindowConfig)1