예제 #1
0
  public static void main(String[] args) throws Exception {

    if (args.length < 4) {
      System.err.println(
          "Usage: PrintSampleStream <consumer-key> <consumer-secret> <access-token> <access-token-secret>");
      return;
    }

    String consumerKey = args[0];
    String consumerSecret = args[1];
    String accessToken = args[2];
    String accessTokenSecret = args[3];

    // keywords start with the 5th parameter
    String[] keyWords = Arrays.copyOfRange(args, 4, args.length);

    TopologyBuilder builder = new TopologyBuilder();

    builder.setSpout(
        "twitter",
        new TwitterSampleSpout(
            consumerKey, consumerSecret, accessToken, accessTokenSecret, keyWords));
    builder.setBolt("print", new PrinterBolt()).shuffleGrouping("twitter");

    Config conf = new Config();

    final FlinkLocalCluster cluster = FlinkLocalCluster.getLocalCluster();
    cluster.submitTopology("Print", conf, FlinkTopology.createTopology(builder));

    Utils.sleep(10 * 1000);

    cluster.shutdown();
  }
예제 #2
0
  public static void main(final String[] args) throws Exception {

    if (!ExclamationTopology.parseParameters(args)) {
      return;
    }

    // build Topology the Storm way
    final FlinkTopologyBuilder builder = ExclamationTopology.buildTopology();

    // execute program locally
    Config conf = new Config();
    conf.put(ExclamationBolt.EXCLAMATION_COUNT, ExclamationTopology.getExclamation());
    final FlinkLocalCluster cluster = FlinkLocalCluster.getLocalCluster();
    cluster.submitTopology(topologyId, conf, builder.createTopology());

    Utils.sleep(10 * 1000);
  }