private StormTopology mkValidateTopology() { Map<String, SpoutDetails> spoutMap = Collections.singletonMap("1", Thrift.prepareSpoutDetails(new TestWordSpout(true), 3)); Map<String, BoltDetails> boltMap = Collections.singletonMap("2", Thrift.prepareBoltDetails( Collections.singletonMap( Utils.getGlobalStreamId("1", null), Thrift.prepareFieldsGrouping(Collections.singletonList("word"))), new TestWordCounter(), 4)); return Thrift.buildTopology(spoutMap, boltMap); }
public void execute(Tuple input, BasicOutputCollector collector) { String word = getTupleValue(input, 0); int count = 0; if (_counts.containsKey(word)) { count = _counts.get(word); } count++; _counts.put(word, count); collector.emit(tuple(word, count)); }
private StormTopology mkInvalidateTopology2() { Map<String, SpoutDetails> spoutMap = Collections.singletonMap("1", Thrift.prepareSpoutDetails(new TestWordSpout(true), 3)); Map<String, BoltDetails> boltMap = Collections.singletonMap("2", Thrift.prepareBoltDetails( Collections.singletonMap( Utils.getGlobalStreamId("1", null), Thrift.prepareFieldsGrouping(Collections.singletonList("non-exists-field"))), new TestWordCounter(), 4)); return Thrift.buildTopology(spoutMap, boltMap); }
public void execute(Tuple input, BasicOutputCollector collector) { String word = getTupleValue(input, 0); int count = 0; if(_counts.containsKey(word)) { count = _counts.get(word); } count++; _counts.put(word, count); collector.emit(tuple(word, count)); }
private StormTopology mkInvalidateTopology1() { Map<String, SpoutDetails> spoutMap = Collections.singletonMap("1", Thrift.prepareSpoutDetails(new TestWordSpout(true), 3)); Map<String, BoltDetails> boltMap = Collections.singletonMap("2", Thrift.prepareBoltDetails( Collections.singletonMap( Utils.getGlobalStreamId("3", null), Thrift.prepareFieldsGrouping(Collections.singletonList("word"))), new TestWordCounter(), 4)); return Thrift.buildTopology(spoutMap, boltMap); }
private StormTopology mkInvalidateTopology3() { Map<String, SpoutDetails> spoutMap = Collections.singletonMap("1", Thrift.prepareSpoutDetails(new TestWordSpout(true), 3)); Map<String, BoltDetails> boltMap = Collections.singletonMap("2", Thrift.prepareBoltDetails( Collections.singletonMap( Utils.getGlobalStreamId("1", "non-exists-stream"), Thrift.prepareFieldsGrouping(Collections.singletonList("word"))), new TestWordCounter(), 4)); return Thrift.buildTopology(spoutMap, boltMap); }
builder1.setBolt("wordCountBolt", new TestWordCounter(), 1).shuffleGrouping("wordSpout").setCPULoad(100.0) .setMemoryLoad(500.0, 100.0); StormTopology stormTopology1 = builder1.createTopology();
Utils.getGlobalStreamId("1", null), Thrift.prepareFieldsGrouping(Collections.singletonList("word"))), new TestWordCounter(), 4)); boltMap.put("3", Thrift.prepareBoltDetails(
builder1.setSpout("wordSpout1", new TestWordSpout(), 1); builder1.setSpout("wordSpout2", new TestWordSpout(), 1); builder1.setBolt("wordCountBolt1", new TestWordCounter(), 1).shuffleGrouping("wordSpout1").shuffleGrouping("wordSpout2"); builder1.setBolt("wordCountBolt2", new TestWordCounter(), 1).shuffleGrouping("wordCountBolt1"); builder1.setBolt("wordCountBolt3", new TestWordCounter(), 1).shuffleGrouping("wordCountBolt1"); builder1.setBolt("wordCountBolt4", new TestWordCounter(), 1).shuffleGrouping("wordCountBolt2"); builder1.setBolt("wordCountBolt5", new TestWordCounter(), 1).shuffleGrouping("wordSpout2"); StormTopology stormTopology1 = builder1.createTopology();
builder1.setBolt("wordCountBolt", new TestWordCounter(), 1).shuffleGrouping("wordSpout").setCPULoad(20.0).setMemoryLoad(200.0); StormTopology stormTopology1 = builder1.createTopology();
public static StormTopology createTestTopology() { TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("words", new TestWordSpout(), generateParallelismHint()); builder.setBolt("count", new TestWordCounter(), generateParallelismHint()).shuffleGrouping("words"); builder.setBolt("globalCount", new TestGlobalCount(), generateParallelismHint()).shuffleGrouping("count"); return builder.createTopology(); }