Java Code Examples for storm.starter.bolt.SingleJoinBolt

The following are top voted examples for showing how to use storm.starter.bolt.SingleJoinBolt. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: big-data-system   File: SingleJoinExample.java   Source Code and License 5 votes vote down vote up
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";
    }
    else {
      gender = "female";
    }
    genderSpout.feed(new Values(i, gender));
  }

  for (int i = 9; i >= 0; i--) {
    ageSpout.feed(new Values(i, i + 20));
  }

  Utils.sleep(2000);
  cluster.shutdown();
}
 
Example 2
Project: cdh-storm   File: SingleJoinExample.java   Source Code and License 5 votes vote down vote up
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";
    }
    else {
      gender = "female";
    }
    genderSpout.feed(new Values(i, gender));
  }

  for (int i = 9; i >= 0; i--) {
    ageSpout.feed(new Values(i, i + 20));
  }

  Utils.sleep(2000);
  cluster.shutdown();
}
 
Example 3
Project: incubator-storm   File: SingleJoinExample.java   Source Code and License 5 votes vote down vote up
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";
    }
    else {
      gender = "female";
    }
    genderSpout.feed(new Values(i, gender));
  }

  for (int i = 9; i >= 0; i--) {
    ageSpout.feed(new Values(i, i + 20));
  }

  Utils.sleep(2000);
  cluster.shutdown();
}
 
Example 4
Project: sentweet   File: SingleJoinExample.java   Source Code and License 5 votes vote down vote up
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";
        } else {
            gender = "female";
        }
        genderSpout.feed(new Values(i, gender));
    }
    
    for(int i=9; i>=0; i--) {            
        ageSpout.feed(new Values(i, i+20));
    }
    
    Utils.sleep(2000);
    cluster.shutdown();
}
 
Example 5
Project: CadalWorkspace   File: SingleJoinExample.java   Source Code and License 5 votes vote down vote up
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";
        } else {
            gender = "female";
        }
        genderSpout.feed(new Values(i, gender));
    }
    
    for(int i=9; i>=0; i--) {            
        ageSpout.feed(new Values(i, i+20));
    }
    
    Utils.sleep(2000);
    cluster.shutdown();
}
 
Example 6
Project: big-data-system   File: Q2Stream.java   Source Code and License 4 votes vote down vote up
public static void main(String[] args) {
        String consumerKey = "42NRnxnkuqrghnolDWSqbiFyv"; 
        String consumerSecret = "zmwC0g6z1FOBBQigW8w2lrnLYncuH4p3QX25RUCNa8aU1QSCC5"; 
        String accessToken = "2809571326-fyBz1ITFXf4yjuqZvHKgGyy0QcQfNVr8y2OGYq6"; 
        String accessTokenSecret = "MAnEtUccHXheXf0z2pauV75oj2XOm6ag4hiLvbUOh6n6B";
        int interval = 2000;
        
        String[] keyWords = new String[]{"cat", "car", "Stockholm", "snow", "data", "system", "Trump", "Palantir", "blue", "badger",
        		"NFL", "apple", "google", "facebook", "perks", "spg", "cajun", "banana", "taco", "whatever", "weareone", "packers", "green",
        		"NBA", "mlb", "dog", "kitten", "blueberry", "romance", "princess", "phone", "nuts", "sheldon", "mad", "talk", "nasty",
        		"procrastination", "cook", "college", "patriots", "dumnass", "dough", "winter", "game", "thrones", "halloween", "warcraft",
        		"hiking", "intern", "park", "sweater", "epic", "dota", "year", "wrath", "waste", "Blake", "street", "toyota", "arrow", 
        		"warning", "travel", "flight", "reject", "karaoke", "bless", "empire", "survivor", "bank", "dating", "restaurant", "tinder",
        		"shopping", "win", "cold", "recap", "cop", "astronaut", "crime", "book", "http", "injured", "china", "awards", "join", 
        		"ugly", "birthday", "friend", "weather", "shirt", "student", "mail", "sleep", "pet", "sea", "dream", "chritmas", "thanksgiving",
        		"vacation", "california", "church", "love", "fuck", "vote", "election", "bernie", "parade", "disney", "today", "city",
        		"marathon", "trade", "cash", "miles", "fun", "work", "free", "photo", "hard", "water", "god", "speech", "gang", "bear", 
        		"stop", "luck", "vegas", "shame", "food", "fool", "weight", "football", "tennis", "concert", "cancer", "stock", "crazy",
        		"ticket", "play", "project", "russia", "cast", "star", "trailer", "yelp", "video", "hawaii", "law", "rage", "comic", "meme",
        		"swag", "snack", "drink", "alcohol", "peace", "swift", "maroon", "xbox", "surface", "flower", "sport", "music", "traffic", "family",
        		"autograph", "selfie", "fans"}; 
        
        TopologyBuilder builder = new TopologyBuilder();
        
        builder.setSpout("friendsCount", new Q2RandomFriendsCountSpout(interval));
        builder.setSpout("hashtags", new Q2RandomHashtagSpout(interval, 100));
        builder.setSpout("tweets", new Q2SeqTwitterSpout(consumerKey, consumerSecret, accessToken, accessTokenSecret, keyWords));
        builder.setBolt("join1", new SingleJoinBolt(new Fields("seq", "friendsCount", "hashtags")))
        	.fieldsGrouping("friendsCount", new Fields("seq"))
        	.fieldsGrouping("hashtags", new Fields("seq"));
        builder.setBolt("join", new SingleJoinBolt(new Fields("friendsCount", "hashtags", "tweetinfolist")))
        	.fieldsGrouping("join1", new Fields("seq"))
        	.fieldsGrouping("tweets", new Fields("seq"));
        builder.setBolt("filter", new Q2FilterTweetBolt())
        	.shuffleGrouping("join");
//        builder.setBolt("printFiltered", new Q2PrintTweetBolt())
//    		.shuffleGrouping("filter");
//        builder.setBolt("cleanWord", new CleanWordsBolt())
//        	.shuffleGrouping("filter", "filterStream");
        builder.setBolt("splitWord", new SplitWordBolt())
        	.shuffleGrouping("filter");
        builder.setBolt("wordCount", new WordCountBolt(), 12)
        	.fieldsGrouping("splitWord", new Fields("word"));
        builder.setBolt("intermediateRanking", new IntermediateRankingsBolt())
        	.shuffleGrouping("wordCount");
        builder.setBolt("totalRanking",  new TotalRankingsBolt())
        	.globalGrouping("intermediateRanking");
        builder.setBolt("printFinal", new Q2PrintTweetBolt())
        	.shuffleGrouping("totalRanking");

                
        Config conf = new Config();
        conf.setDebug(true);
        
        final LocalCluster cluster = new LocalCluster();
        StormTopology topo = builder.createTopology();
        cluster.submitTopology("Q2", conf, topo);
        
        //Utils.sleep(interval * 100);
		Runtime.getRuntime().addShutdownHook(new Thread() {
			@Override
			public void run() {
				cluster.killTopology("Q2");
				cluster.shutdown();
			}
		});
        //cluster.shutdown();
    }