gpt4 book ai didi

java - Apache Storm 无效拓扑异常

转载 作者:行者123 更新时间:2023-12-02 03:48:22 27 4
gpt4 key购买 nike

我在 MainTopology 类运行时遇到错误,它在第 1 行显示错误。 24 我一直无法理解。这是主要的类: 封装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/:?]

非常感谢任何帮助

最佳答案

您的发射 bolt (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
}

关于java - Apache Storm 无效拓扑异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36124546/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com