当前位置: 首页>>代码示例>>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;未经允许,请勿转载。