我在MainTopology类的运行时遇到错误,它在行号中显示错误。 24我无法理解。 这是主要类: package streamPostsCount;
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/:?]
非常感谢任何帮助
答案 0 :(得分:1)
你的发射螺栓(分裂后螺栓)也需要实现declareOutputFields():
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
declarer.declare(new Fields("posts-by-user","field2","field3")); // list the fields you'll emit
}
答案 1 :(得分:1)
每当你从螺栓发射时,你需要覆盖方法
public void declareOutputFields(OutputFieldsDeclarer declarer);
并提到你正在发射的领域。暴风雨显然是说没有声明posts-by-user
的字段从螺栓split-post-bolt
发出
@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
declarer.declare(new Fields("posts-by-user"));
}