Package backtype.storm

Examples of backtype.storm.Config


  public static void main(String[] args) throws Exception {
    LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder("exclamation");
    builder.addBolt(new ExclaimBolt(), 3);

    Config conf = new Config();

    if (args == null || args.length == 0) {
      LocalDRPC drpc = new LocalDRPC();
      LocalCluster cluster = new LocalCluster();

      cluster.submitTopology("drpc-demo", conf, builder.createLocalTopology(drpc));

      for (String word : new String[]{ "hello", "goodbye" }) {
        System.out.println("Result for \"" + word + "\": " + drpc.execute("exclamation", word));
      }

      cluster.shutdown();
      drpc.shutdown();
    }
    else {
      conf.setNumWorkers(3);
      StormSubmitter.submitTopology(args[0], conf, builder.createRemoteTopology());
    }
  }
View Full Code Here


        new FilterNull()).aggregate(new Fields("count"), new Sum(), new Fields("sum"));
    return topology.build();
  }

  public static void main(String[] args) throws Exception {
    Config conf = new Config();
    conf.setMaxSpoutPending(20);
    if (args.length == 0) {
      LocalDRPC drpc = new LocalDRPC();
      LocalCluster cluster = new LocalCluster();
      cluster.submitTopology("wordCounter", conf, buildTopology(drpc));
      for (int i = 0; i < 100; i++) {
        System.out.println("DRPC RESULT: " + drpc.execute("words", "cat the dog jumped"));
        Thread.sleep(1000);
      }
    }
    else {
      conf.setNumWorkers(3);
      StormSubmitter.submitTopology(args[0], conf, buildTopology(null));
    }
  }
View Full Code Here

  }

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

    Config conf = new Config();
    LocalCluster cluster = new LocalCluster();

    cluster.submitTopology("reach", conf, buildTopology(drpc));

    Thread.sleep(2000);
View Full Code Here

    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 {
View Full Code Here

    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

        if (!(mode.equals(CLUSTER_LOCAL) || mode.equals(CLUSTER_PRODUCTION))) {
            throw new RuntimeException("Unknown cluster type of " + mode);
        }

        JuggaloaderTopology juggaloaderTopology = new JuggaloaderTopology();
        Config config = new Config();
        config.registerSerialization(LinkedHashMap.class);
        config.setFallBackOnJavaSerialization(false);

        if (mode.equals(CLUSTER_LOCAL)) {
            config.setDebug(true);
            LocalCluster cluster = new LocalCluster();
            cluster.submitTopology(TOPOLOGY_NAME, config, juggaloaderTopology.createJuggaloaderTopology());
            logger.info("Start Storm Local Cluster");
        }

        if (mode.equals(CLUSTER_PRODUCTION)) {
            config.setNumAckers(5);
            try {
                StormSubmitter.submitTopology(TOPOLOGY_NAME, config, juggaloaderTopology.createJuggaloaderTopology());
            } catch (AlreadyAliveException | InvalidTopologyException e) {
                logger.error(e.getMessage(), e);
            }
View Full Code Here

      // Classification stream
      toppology.newDRPCStream("classify", localDRPC)
        // Query classifier with text instance
        .each(new Fields("args"), new TwitterSentimentClassifier(), new Fields("sentiment")).project(new Fields("sentiment"));

      cluster.submitTopology(this.getClass().getSimpleName(), new Config(), toppology.build());
      Thread.sleep(4000);

      // Query with DRPC
      test(false, "RT @JazminBianca: I hate Windows 8. I hate Windows 8. I hate Windows 8.", localDRPC);
      test(false, "I don't like Windows 8, I think it's overrated =))", localDRPC);
View Full Code Here

          .each(new Fields("args"), new TextInstanceCreator<Integer>(false), new Fields("instance"))

          // Query classifier with text instance
          .stateQuery(classifierState, new Fields("instance"), new ClassifyTextQuery<Integer>("newsClassifier"), new Fields("prediction")).project(new Fields("prediction"));

      cluster.submitTopology(this.getClass().getSimpleName(), new Config(), toppology.build());
      Thread.sleep(4000);

      // Query with DRPC
      for (Integer realClass : ReutersBatchSpout.REUTEURS_EVAL_SAMPLES.keySet()) {
        Integer prediction = extractPrediction(localDRPC.execute("classify", ReutersBatchSpout.REUTEURS_EVAL_SAMPLES.get(realClass)));
View Full Code Here

        // Query kmeans to classify instance
        .stateQuery(kmeansState, new Fields("instance"), new ClusterQuery("kmeans"), new Fields("prediction"))
         
        .project(new Fields("prediction"));

      cluster.submitTopology(this.getClass().getSimpleName(), new Config(), toppology.build());

      Thread.sleep(10000);

      Integer result11 = extractPrediction(localDRPC.execute("predict", "1.0 1.0 1.0"));
      Integer result12 = extractPrediction(localDRPC.execute("predict", "0.8 1.1 0.9"));
View Full Code Here

      // Evaluation stream
      toppology.newDRPCStream("evaluate", localDRPC) //
          .stateQuery(perceptronEvaluation, new EvaluationQuery<Boolean>(), new Fields("eval")) //
          .project(new Fields("eval"));

      cluster.submitTopology(this.getClass().getSimpleName(), new Config(), toppology.build());
      Thread.sleep(4000);

      assertEquals(Boolean.TRUE, extractPrediction(localDRPC.execute("predict", "1.0 0.0 0.0")));
      assertEquals(Boolean.TRUE, extractPrediction(localDRPC.execute("predict", "1.0 0.0 1.0")));
      assertEquals(Boolean.TRUE, extractPrediction(localDRPC.execute("predict", "1.0 1.0 0.0")));
View Full Code Here

TOP

Related Classes of backtype.storm.Config

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.