Package backtype.storm.transactional

Examples of backtype.storm.transactional.TransactionalTopologyBuilder


  public static void main(String[] args) throws InterruptedException {
    // Add transactional spout
    MemoryTransactionalSpout spout = new MemoryTransactionalSpout(values,
        new Fields("shortid", "url", "user", "date"), 3);

    TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder(
        "shorturl-count", "spout", spout, 2);

    // Build TupleTableConifg
    TupleTableConfig ttConfig = new TupleTableConfig("shorturl", "shortid");
    ttConfig.setBatch(false);
    ttConfig.addColumn("data", "clicks");
    ttConfig.addColumn("daily", "date");

    builder.setBolt("hbase-counters", new HBaseCountersBatchBolt(ttConfig), 2)
        .fieldsGrouping("spout", new Fields("shortid"));

    LocalCluster cluster = new LocalCluster();

    Config stormConfig = new Config();
    stormConfig.setDebug(true);
    stormConfig.setMaxSpoutPending(3);

    cluster.submitTopology("hbase-example", stormConfig,
        builder.buildTopology());

    Thread.sleep(10000);
    cluster.shutdown();
  }
View Full Code Here


    }
  }

  public static void main(String[] args) throws Exception {
    MemoryTransactionalSpout spout = new MemoryTransactionalSpout(DATA, new Fields("word"), PARTITION_TAKE_PER_BATCH);
    TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("global-count", "spout", spout, 3);
    builder.setBolt("partial-count", new BatchCount(), 5).noneGrouping("spout");
    builder.setBolt("sum", new UpdateGlobalCount()).globalGrouping("partial-count");

    LocalCluster cluster = new LocalCluster();

    Config config = new Config();
    config.setDebug(true);
    config.setMaxSpoutPending(3);

    cluster.submitTopology("global-count-topology", config, builder.buildTopology());

    Thread.sleep(3000);
    cluster.shutdown();
  }
View Full Code Here

    }
  }

  public static void main(String[] args) throws Exception {
    MemoryTransactionalSpout spout = new MemoryTransactionalSpout(DATA, new Fields("word"), PARTITION_TAKE_PER_BATCH);
    TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("top-n-words", "spout", spout, 2);
    builder.setBolt("count", new KeyedCountUpdater(), 5).fieldsGrouping("spout", new Fields("word"));
    builder.setBolt("bucketize", new Bucketize()).noneGrouping("count");
    builder.setBolt("buckets", new BucketCountUpdater(), 5).fieldsGrouping("bucketize", new Fields("bucket"));


    LocalCluster cluster = new LocalCluster();

    Config config = new Config();
    config.setDebug(true);
    config.setMaxSpoutPending(3);

    cluster.submitTopology("top-n-topology", config, builder.buildTopology());

    Thread.sleep(3000);
    cluster.shutdown();
  }
View Full Code Here

    }
  }

  public static void main(String[] args) throws Exception {
    MemoryTransactionalSpout spout = new MemoryTransactionalSpout(DATA, new Fields("word"), PARTITION_TAKE_PER_BATCH);
    TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("top-n-words", "spout", spout, 2);
    builder.setBolt("count", new KeyedCountUpdater(), 5).fieldsGrouping("spout", new Fields("word"));
    builder.setBolt("bucketize", new Bucketize()).noneGrouping("count");
    builder.setBolt("buckets", new BucketCountUpdater(), 5).fieldsGrouping("bucketize", new Fields("bucket"));


    LocalCluster cluster = new LocalCluster();

    Config config = new Config();
    config.setDebug(true);
    config.setMaxSpoutPending(3);

    cluster.submitTopology("top-n-topology", config, builder.buildTopology());

    Thread.sleep(3000);
    cluster.shutdown();
  }
View Full Code Here

    }
  }

  public static void main(String[] args) throws Exception {
    MemoryTransactionalSpout spout = new MemoryTransactionalSpout(DATA, new Fields("word"), PARTITION_TAKE_PER_BATCH);
    TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("global-count", "spout", spout, 3);
    builder.setBolt("partial-count", new BatchCount(), 5).noneGrouping("spout");
    builder.setBolt("sum", new UpdateGlobalCount()).globalGrouping("partial-count");

    LocalCluster cluster = new LocalCluster();

    Config config = new Config();
    config.setDebug(true);
    config.setMaxSpoutPending(3);

    cluster.submitTopology("global-count-topology", config, builder.buildTopology());

    Thread.sleep(3000);
    cluster.shutdown();
  }
View Full Code Here

        }       
    }
   
    public static void main(String[] args) throws Exception {
        MemoryTransactionalSpout spout = new MemoryTransactionalSpout(DATA, new Fields("word"), PARTITION_TAKE_PER_BATCH);
        TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("top-n-words", "spout", spout, 2);
        builder.setBolt("count", new KeyedCountUpdater(), 5)
                .fieldsGrouping("spout", new Fields("word"));
        builder.setBolt("bucketize", new Bucketize())
                .noneGrouping("count");
        builder.setBolt("buckets", new BucketCountUpdater(), 5)
                .fieldsGrouping("bucketize", new Fields("bucket"));
       
       
        LocalCluster cluster = new LocalCluster();
       
        Config config = new Config();
        config.setDebug(true);
        config.setMaxSpoutPending(3);
       
        cluster.submitTopology("top-n-topology", config, builder.buildTopology());
       
        Thread.sleep(3000);
        cluster.shutdown();
    }
View Full Code Here

        }       
    }
   
    public static void main(String[] args) throws Exception {
        MemoryTransactionalSpout spout = new MemoryTransactionalSpout(DATA, new Fields("word"), PARTITION_TAKE_PER_BATCH);
        TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("global-count", "spout", spout, 3);
        builder.setBolt("partial-count", new BatchCount(), 5)
                .noneGrouping("spout");
        builder.setBolt("sum", new UpdateGlobalCount())
                .globalGrouping("partial-count");
       
        LocalCluster cluster = new LocalCluster();
       
        Config config = new Config();
        config.setDebug(true);
        config.setMaxSpoutPending(3);
       
        cluster.submitTopology("global-count-topology", config, builder.buildTopology());
       
        Thread.sleep(3000);
        cluster.shutdown();
    }
View Full Code Here

      }
    }

    public static void main(String[] args) throws Exception {
      MemoryTransactionalSpout spout = new MemoryTransactionalSpout(DATA, new Fields("word"), PARTITION_TAKE_PER_BATCH);
      TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("global-count", "spout", spout, 2);
      builder.setBolt("partial-count", new BatchCount(), 3).noneGrouping("spout");
      builder.setBolt("sum", new UpdateGlobalCount(), 1).globalGrouping("partial-count");

//      LocalCluster cluster = new LocalCluster();

      Config config = new Config();
      config.setDebug(true);
      config.setMaxSpoutPending(3);
      config.put(Config.TOPOLOGY_WORKERS, 9);
      Config.setNumAckers(config, 0);
     
      StormSubmitter.submitTopology("global-count-topology", config, builder.buildTopology());

//      Thread.sleep(3000);
//      cluster.shutdown();
    }
View Full Code Here

TOP

Related Classes of backtype.storm.transactional.TransactionalTopologyBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.