设置螺栓以从三叉戟拓扑中的其他螺栓的特定流中读取

时间:2018-03-22 13:01:10

标签: apache-storm trident apache-storm-topology

我正在尝试编写一个TridentTopology,它有多个螺栓。现在我想将一个螺栓注册到其他螺栓特定流,如下所示。

TridentTopologyBuilder tridentTopologyBuilder = new TridentTopologyBuilder();
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 2,
                                            new Values("the cow jumped over the moon"),
                                            new Values("the man went to the store and bought some candy"),
                                            new Values("four score and seven years ago"),
                                            new Values("how many apples can you eat"));

tridentTopologyBuilder.setSpout("tridentSpout", "spoutStream", "spoutId", spout, 2, "spoutBatch");
Map<String, String> batchGroups = new HashMap<>();
batchGroups.put("boltStream", "boltBatch");
tridentTopologyBuilder.setBolt("tridentBolt", new TridentTestBolt(), 1, Sets.newHashSet("spoutBatch"), batchGroups).shuffleGrouping("tridentSpout", "spoutStream");

tridentTopologyBuilder.setBolt("tridentBolt2", new TridentTestBolt2(), 1, new HashSet<>(), batchGroups).shuffleGrouping("tridentBolt", "boltStream");

LocalCluster cluster = new LocalCluster();
Config config = new Config();
config.setDebug(true);
cluster.submitTopology("TridentTopology", config, tridentTopologyBuilder.buildTopology(new HashMap<>()));

我遇到以下异常:

Error: InvalidTopologyException(msg:Component: [tridentBolt2] subscribes from non-existent stream: [$coord-boltBatch] of component [tridentBolt])

还使用OutputFieldsDeclarer

的declareStream方法声明了流
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
    declarer.declareStream("boltStream", new Fields("sentence"));
}

同样注册其他螺栓特定流在正常拓扑中工作。问题出在Trident拓扑上。我们应该为batchGroups传递什么。

0 个答案:

没有答案