Example #1
0
 public static LinearDRPCTopologyBuilder construct() {
   LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder(TOPOLOGY_NAME);
   builder.addBolt(new GetTweeters(), 1);
   builder.addBolt(new GetFollowers(), 1).shuffleGrouping();
   builder.addBolt(new PartialUniquer(), 1).fieldsGrouping(new Fields("id", "follower"));
   builder.addBolt(new CountAggregator(), 1).fieldsGrouping(new Fields("id"));
   return builder;
 }
  public static void SetDPRCTopology() throws AlreadyAliveException, InvalidTopologyException {
    LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder("exclamation");

    builder.addBolt(new TotalCount(), 3);

    Config conf = new Config();

    conf.setNumWorkers(3);
    StormSubmitter.submitTopology("rpc", conf, builder.createRemoteTopology());
  }
Example #3
0
  public static void main(String[] args) throws Exception {

    LinearDRPCTopologyBuilder builder = construct();

    Config conf = new Config();
    conf.setNumWorkers(6);
    if (args.length != 0) {

      try {
        Map yamlConf = LoadConf.LoadYaml(args[0]);
        if (yamlConf != null) {
          conf.putAll(yamlConf);
        }
      } catch (Exception e) {
        System.out.println("Input " + args[0] + " isn't one yaml ");
      }

      StormSubmitter.submitTopology(TOPOLOGY_NAME, conf, builder.createRemoteTopology());
    } else {

      conf.setMaxTaskParallelism(3);
      LocalDRPC drpc = new LocalDRPC();
      LocalCluster cluster = new LocalCluster();
      cluster.submitTopology(TOPOLOGY_NAME, conf, builder.createLocalTopology(drpc));

      JStormUtils.sleepMs(50000);

      String[] urlsToTry =
          new String[] {"foo.com/blog/1", "engineering.twitter.com/blog/5", "notaurl.com"};
      for (String url : urlsToTry) {
        System.out.println("Reach of " + url + ": " + drpc.execute(TOPOLOGY_NAME, url));
      }

      cluster.shutdown();
      drpc.shutdown();
    }
  }