Package backtype.storm.topology

Examples of backtype.storm.topology.TopologyBuilder


  private final String topologyName;
  private final Config topologyConfig;
  private final int runtimeInSeconds;

  public RollingTopWords() throws InterruptedException {
    builder = new TopologyBuilder();
    topologyName = "slidingWindowCounts";
    topologyConfig = createTopologyConfiguration();
    runtimeInSeconds = DEFAULT_RUNTIME_IN_SECONDS;

    wireTopology();
View Full Code Here


        String accessToken = args[2];
        String accessTokenSecret = args[3];
        String[] arguments = args.clone();
        String[] keyWords = Arrays.copyOfRange(arguments, 4, arguments.length);
       
        TopologyBuilder builder = new TopologyBuilder();
       
        builder.setSpout("spoutId", new TwitterSampleSpout(consumerKey, consumerSecret,
                                accessToken, accessTokenSecret, keyWords));
        builder.setBolt("print", new PrinterBolt())
                .shuffleGrouping("spout");
               
               
        Config conf = new Config();
       
       
        LocalCluster cluster = new LocalCluster();
       
        cluster.submitTopology("test", conf, builder.createTopology());
       
        Utils.sleep(10000);
        cluster.shutdown();
    }
View Full Code Here

        ConfigurableTopology.start(new CrawlTopology(), args);
    }

    @Override
    protected int run(String[] args) {
        TopologyBuilder builder = new TopologyBuilder();

        builder.setSpout("spout", new RandomURLSpout());

        builder.setBolt("partitioner", new URLPartitionerBolt())
                .shuffleGrouping("spout");

        builder.setBolt("fetch", new FetcherBolt()).fieldsGrouping(
                "partitioner", new Fields("key"));

        builder.setBolt("parse", new ParserBolt()).shuffleGrouping("fetch");

        builder.setBolt("index", new IndexerBolt()).shuffleGrouping("parse");

        conf.registerMetricsConsumer(DebugMetricConsumer.class);

        return submit("crawl", conf, builder);
    }
View Full Code Here

    }
  }

  public static void main(String[] args) throws Exception {

    TopologyBuilder builder = new TopologyBuilder();

    builder.setSpout("spout", new RandomSentenceSpout(), 5);

    builder.setBolt("split", new SplitSentence(), 8).shuffleGrouping("spout");
    builder.setBolt("count", new WordCount(), 12).fieldsGrouping("split", new Fields("word"));

    Config conf = new Config();
    conf.setDebug(true);


    if (args != null && args.length > 0) {
      conf.setNumWorkers(3);

      StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
    }
    else {
      conf.setMaxTaskParallelism(3);

      LocalCluster cluster = new LocalCluster();
      cluster.submitTopology("word-count", conf, builder.createTopology());

      Thread.sleep(10000);

      cluster.shutdown();
    }
View Full Code Here

    }

  }

  public static void main(String[] args) {
    TopologyBuilder builder = new TopologyBuilder();
    LocalDRPC drpc = new LocalDRPC();

    DRPCSpout spout = new DRPCSpout("exclamation", drpc);
    builder.setSpout("drpc", spout);
    builder.setBolt("exclaim", new ExclamationBolt(), 3).shuffleGrouping("drpc");
    builder.setBolt("return", new ReturnResults(), 3).shuffleGrouping("exclaim");

    LocalCluster cluster = new LocalCluster();
    Config conf = new Config();
    cluster.submitTopology("exclaim", conf, builder.createTopology());

    System.out.println(drpc.execute("exclamation", "aaa"));
    System.out.println(drpc.execute("exclamation", "bbb"));

  }
View Full Code Here

public class TestBasicKarmaTopology {

  @Test
  public void testBasicTopology(){
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("karma-seq-spout", new KarmaSequenceFileSpout());
    Properties basicKarmaBoltProperties = new Properties();
    basicKarmaBoltProperties.setProperty("name", "Stormy");
    basicKarmaBoltProperties.setProperty("karma.input.type", "JSON");
    basicKarmaBoltProperties.setProperty("base.uri", "http://ex.com");
    String source = null;
    try {
      source = new File(this.getClass().getClassLoader().getResource("people-model.ttl").toURI()).getAbsolutePath().toString();
      basicKarmaBoltProperties.setProperty("model.file", source);
    } catch (URISyntaxException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    builder.setBolt("karma-generate-json", new KarmaBolt(basicKarmaBoltProperties)).shuffleGrouping("karma-seq-spout");
    SequenceFileBolt sequenceFileBolt = new SequenceFileBolt();
   
    KarmaSequenceFormat sequenceFormat = new KarmaSequenceFormat("id", "json");
    sequenceFileBolt.withSequenceFormat(sequenceFormat);
    DefaultFileNameFormat fileNameFormat = new DefaultFileNameFormat();
    fileNameFormat.withExtension(".seq");
    fileNameFormat.withPath("/tmp/storm");
    fileNameFormat.withPrefix("karma");
    sequenceFileBolt.withFileNameFormat(fileNameFormat);
    sequenceFileBolt.withFsUrl("file:///");
    sequenceFileBolt.withSyncPolicy(new CountSyncPolicy(1));
    sequenceFileBolt.withRotationPolicy(new FileSizeRotationPolicy(1, Units.KB));
    Set<String> sources = new HashSet<String>();
    sources.add(source);
    KarmaReducerBolt reducerBolt = new KarmaReducerBolt(sources);
    builder.setBolt("karma-reducer-json", reducerBolt).fieldsGrouping("karma-generate-json", new Fields("id"));
    builder.setBolt("karma-output-json", sequenceFileBolt).shuffleGrouping("karma-reducer-json");
    Config config = new Config();
    config.put("input.path", "/tmp/loaded_data/simpleloader.seq");
    config.setDebug(true);
    StormTopology topology = builder.createTopology();
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("karma-basic-topology",
         config,
         topology);
    Utils.sleep(60000);
View Full Code Here

public class SingleJoinExample {
  public static void main(String[] args) {
    FeederSpout genderSpout = new FeederSpout(new Fields("id", "gender"));
    FeederSpout ageSpout = new FeederSpout(new Fields("id", "age"));

    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("gender", genderSpout);
    builder.setSpout("age", ageSpout);
    builder.setBolt("join", new SingleJoinBolt(new Fields("gender", "age"))).fieldsGrouping("gender", new Fields("id"))
        .fieldsGrouping("age", new Fields("id"));

    Config conf = new Config();
    conf.setDebug(true);

    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("join-example", conf, builder.createTopology());

    for (int i = 0; i < 10; i++) {
      String gender;
      if (i % 2 == 0) {
        gender = "male";
View Full Code Here

  private final String topologyName;
  private final Config topologyConfig;
  private final int runtimeInSeconds;

  public RollingTopWords() throws InterruptedException {
    builder = new TopologyBuilder();
    topologyName = "slidingWindowCounts";
    topologyConfig = createTopologyConfiguration();
    runtimeInSeconds = DEFAULT_RUNTIME_IN_SECONDS;

    wireTopology();
View Full Code Here


  }

  public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();

    builder.setSpout("word", new TestWordSpout(), 10);
    builder.setBolt("exclaim1", new ExclamationBolt(), 3).shuffleGrouping("word");
    builder.setBolt("exclaim2", new ExclamationBolt(), 2).shuffleGrouping("exclaim1");

    Config conf = new Config();
    conf.setDebug(true);

    if (args != null && args.length > 0) {
      conf.setNumWorkers(3);

      StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
    }
    else {

      LocalCluster cluster = new LocalCluster();
      cluster.submitTopology("test", conf, builder.createTopology());
      Utils.sleep(10000);
      cluster.killTopology("test");
      cluster.shutdown();
    }
  }
View Full Code Here

public class JuggaloaderDummyTopology {


    public static void main(String[] args) throws Exception {
       
        TopologyBuilder builder = buildJuggaloaderTopology();

        Config conf = new Config();
        conf.setDebug(true);
       
        if(args!=null && args.length > 0) {
            conf.setNumWorkers(3);
            StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
        } else {       
            conf.setMaxTaskParallelism(3);
            LocalCluster cluster = new LocalCluster();
            cluster.submitTopology("Juggaloader-dummy", conf, builder.createTopology());
            Thread.sleep(10000);
            cluster.shutdown();
        }
    }
View Full Code Here

TOP

Related Classes of backtype.storm.topology.TopologyBuilder

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.