當前位置: 首頁>>代碼示例>>Java>>正文


Java SlidingWindowSumBolt類代碼示例

本文整理匯總了Java中org.apache.storm.starter.bolt.SlidingWindowSumBolt的典型用法代碼示例。如果您正苦於以下問題:Java SlidingWindowSumBolt類的具體用法?Java SlidingWindowSumBolt怎麽用?Java SlidingWindowSumBolt使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SlidingWindowSumBolt類屬於org.apache.storm.starter.bolt包,在下文中一共展示了SlidingWindowSumBolt類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.apache.storm.starter.bolt.SlidingWindowSumBolt; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    BaseWindowedBolt bolt = new SlidingWindowSumBolt()
            .withWindow(new Duration(5, TimeUnit.SECONDS), new Duration(3, TimeUnit.SECONDS))
            .withTimestampField("ts")
            .withLag(new Duration(5, TimeUnit.SECONDS));
    builder.setSpout("integer", new RandomIntegerSpout(), 1);
    builder.setBolt("slidingsum", bolt, 1).shuffleGrouping("integer");
    builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("slidingsum");
    Config conf = new Config();
    conf.setDebug(true);

    if (args != null && args.length > 0) {
        conf.setNumWorkers(1);
        StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
    } else {
        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology("test", conf, builder.createTopology());
        Utils.sleep(40000);
        cluster.killTopology("test");
        cluster.shutdown();
    }
}
 
開發者ID:ziyunhx,項目名稱:storm-net-adapter,代碼行數:24,代碼來源:SlidingTupleTsTopology.java

示例2: main

import org.apache.storm.starter.bolt.SlidingWindowSumBolt; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("integer", new RandomIntegerSpout(), 1);
    builder.setBolt("slidingsum", new SlidingWindowSumBolt().withWindow(new Count(30), new Count(10)), 1)
            .shuffleGrouping("integer");
    builder.setBolt("tumblingavg", new TumblingWindowAvgBolt().withTumblingWindow(new Count(3)), 1)
            .shuffleGrouping("slidingsum");
    builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("tumblingavg");
    Config conf = new Config();
    conf.setDebug(true);
    if (args != null && args.length > 0) {
        conf.setNumWorkers(1);
        StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
    } else {
        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology("test", conf, builder.createTopology());
        Utils.sleep(40000);
        cluster.killTopology("test");
        cluster.shutdown();
    }
}
 
開發者ID:ziyunhx,項目名稱:storm-net-adapter,代碼行數:22,代碼來源:SlidingWindowTopology.java

示例3: test

import org.apache.storm.starter.bolt.SlidingWindowSumBolt; //導入依賴的package包/類
public static void test() {
    
    String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
    String topologyName = className[className.length - 1];
    
    try {
        TopologyBuilder builder = new TopologyBuilder();
        BaseWindowedBolt bolt = new SlidingWindowSumBolt()
                .withWindow(new Duration(5, TimeUnit.SECONDS), new Duration(3, TimeUnit.SECONDS))
                .withTimestampField("ts").withLag(new Duration(5, TimeUnit.SECONDS));
        builder.setSpout("integer", new RandomIntegerSpout(), 1);
        builder.setBolt("slidingsum", bolt, 1).shuffleGrouping("integer");
        builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("slidingsum");
        
        conf.setDebug(true);
        
        JStormHelper.runTopology(builder.createTopology(), topologyName, conf, 60,
                new JStormHelper.CheckAckedFail(conf), isLocal);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Assert.fail("Failed");
    }
}
 
開發者ID:alibaba,項目名稱:jstorm,代碼行數:25,代碼來源:SlidingTupleTsTopology.java

示例4: test

import org.apache.storm.starter.bolt.SlidingWindowSumBolt; //導入依賴的package包/類
public static void test() {
    
    String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
    String topologyName = className[className.length - 1];
    
    try {
        TopologyBuilder builder = new TopologyBuilder();
        builder.setSpout("integer", new RandomIntegerSpout(), 1);
        builder.setBolt("slidingsum", new SlidingWindowSumBolt().withWindow(new Count(30), new Count(10)), 1)
                .shuffleGrouping("integer");
        builder.setBolt("tumblingavg", new TumblingWindowAvgBolt().withTumblingWindow(new Count(3)), 1)
                .shuffleGrouping("slidingsum");
        builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("tumblingavg");
        
        conf.setDebug(true);
        
        JStormHelper.runTopology(builder.createTopology(), topologyName, conf, 60,
                new JStormHelper.CheckAckedFail(conf), isLocal);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.fillInStackTrace();
        Assert.fail("Failed to submit topology");
    }
}
 
開發者ID:alibaba,項目名稱:jstorm,代碼行數:25,代碼來源:SlidingWindowTopology.java


注:本文中的org.apache.storm.starter.bolt.SlidingWindowSumBolt類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。