Apache Storm InvalidTopologyException
Posted
技术标签:
【中文标题】Apache Storm InvalidTopologyException【英文标题】: 【发布时间】:2016-03-21 06:34:12 【问题描述】:我在 MainTopology 类的运行时遇到错误,它在第 1 行显示错误。 24 我无法理解。 这是主要课程: 包流PostsCount;
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.topology.TopologyBuilder;
import backtype.storm.tuple.Fields;
public class MainTopology
public static void main(String[] args) throws Exception
//Create config instance for cluster configuration
Config config = new Config();
config.setDebug(true);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("post-reader-spout", new StreamReaderSpout());
builder.setBolt("split-post-bolt", new PostSplitterBolt()).shuffleGrouping("post-reader-spout");
builder.setBolt("update-posts-bolt", new PostsUpdateBolt())
.fieldsGrouping("split-post-bolt", new Fields("posts-by-user"));
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("PostsCount", config, builder.createTopology());
Thread.sleep(10000);
//Stop the topology
cluster.shutdown();
这是我得到的错误:
3049 [main-EventThread] INFO o.a.s.s.o.a.c.f.s.ConnectionStateManager - State change: CONNECTED
3066 [main] INFO b.s.d.supervisor - Starting supervisor with id 1a6399fb-360b-4f8f-bd4d-b09711fbcb24 at host mdh160
3074 [main] INFO b.s.d.nimbus - [req 1] Access from: principal: op:submitTopology
3099 [main] WARN b.s.d.nimbus - Topology submission exception. (topology name='PostsCount') #<InvalidTopologyException InvalidTopologyException(msg:Component: [update-posts-bolt] subscribes from stream: [default] of component [split-post-bolt] with non-existent fields: #"posts-by-user")>
3099 [main] ERROR o.a.s.s.o.a.z.s.NioserverCnxnFactory - Thread Thread[main,5,main] died
backtype.storm.generated.InvalidTopologyException
at backtype.storm.daemon.common$validate_structure_BANG_.invoke(common.clj:169) ~[storm-core-0.10.0.jar:0.10.0]
at backtype.storm.daemon.common$system_topology_BANG_.invoke(common.clj:299) ~[storm-core-0.10.0.jar:0.10.0]
at backtype.storm.daemon.nimbus$fn__6583$exec_fn__1236__auto__$reify__6598.submitTopologyWithOpts(nimbus.clj:1091) ~[storm-core-0.10.0.jar:0.10.0]
at backtype.storm.daemon.nimbus$fn__6583$exec_fn__1236__auto__$reify__6598.submitTopology(nimbus.clj:1119) ~[storm-core-0.10.0.jar:0.10.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_72]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_72]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_72]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_72]
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93) ~[clojure-1.6.0.jar:?]
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28) ~[clojure-1.6.0.jar:?]
at backtype.storm.testing$submit_local_topology.invoke(testing.clj:276) ~[storm-core-0.10.0.jar:0.10.0]
at backtype.storm.LocalCluster$_submitTopology.invoke(LocalCluster.clj:43) ~[storm-core-0.10.0.jar:0.10.0]
at backtype.storm.LocalCluster.submitTopology(Unknown Source) ~[storm-core-0.10.0.jar:0.10.0]
at streamPostsCount.MainTopology.main(MainTopology.java:24) ~[StreamLayer/:?]
非常感谢任何帮助
【问题讨论】:
请勿发布屏幕截图。复制/粘贴 COMPLETE 堆栈跟踪,包括所有“由”部分作为文本和格式作为代码(缩进 4 个空格)。 是的,按照你的建议做了。我希望现在很清楚。 【参考方案1】:您的发射螺栓(split-post-bolt)还需要实现 declareOutputFields():
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer)
declarer.declare(new Fields("posts-by-user","field2","field3")); // list the fields you'll emit
【讨论】:
【参考方案2】:每当你从bolt发射时,你需要覆盖方法
public void declareOutputFields(OutputFieldsDeclarer declarer);
并提及您发出的字段。 Storm 明确表示没有声明为 posts-by-user
的字段从 Bolt split-post-bolt
发出
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer)
declarer.declare(new Fields("posts-by-user"));
【讨论】:
以上是关于Apache Storm InvalidTopologyException的主要内容,如果未能解决你的问题,请参考以下文章