new Fields是干啥的 declare的时候,new Fields(“A”,”B”) emit的时候,new Value(“a”,”b”)declare的fields的size要和value的size相等否则会报错 这个是对应的 所以接收的时候tuple.getString(index)这个index就代表着ab的位置 返回的tuple中获得的是这个地方的数据
同时,可以通过getStringByField这个方法获得指定field的值
Message ID这个又是干啥的 这个值可填可不填 当not null时,ack和fail的回调会执行,被storm监控,所以可以在这两个回调函数里记录状态写到日志里,这样排错的时候就能定位了 当msgid为null时,可以理解为虽然任务执行了,但是这个事件丢失了,没有人知道他,他是个没身份证的人,不受到storm的监控,也就自然没法对他定位了
开发遇到的报错问题 Local模式
一点运行马上报这个错
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 java.lang.NoClassDefFoundError: org/apache/storm/generated/AlreadyAliveException at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.privateGetMethodRecursive(Class.java:3048) at java.lang.Class.getMethod0(Class.java:3018) at java.lang.Class.getMethod(Class.java:1784) at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526) Caused by: java.lang.ClassNotFoundException: org.apache.storm.generated.AlreadyAliveException at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 7 more Error: A JNI error has occurred, please check your installation and try again Exception in thread "main"
90%的原因出在pom文件上 scope在本地调试的时候不要用provided的方式,不写或者用compile,问题可解决
仔细,不贴报错信息了Topology submission exception 请注意红框和蓝框的位置,因为第一次写,蒙蒙叨叨的把grouping时的红蓝框写反了。导致报错啊
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 26605 [main] WARN o.a.s.d.nimbus - Topology submission exception. (topology name='word-count-local') #error { :cause nil :via [{:type org.apache.storm.generated.InvalidTopologyException :message nil :at [org.apache.storm.daemon.common$validate_structure_BANG_ invoke common.clj 178]}] :trace [[org.apache.storm.daemon.common$validate_structure_BANG_ invoke common.clj 178] [org.apache.storm.daemon.common$system_topology_BANG_ invoke common.clj 374] [org.apache.storm.daemon.nimbus$mk_reified_nimbus$reify__10781 submitTopologyWithOpts nimbus.clj 1727] [org.apache.storm.daemon.nimbus$mk_reified_nimbus$reify__10781 submitTopology nimbus.clj 1761] [sun.reflect.NativeMethodAccessorImpl invoke0 NativeMethodAccessorImpl.java -2] [sun.reflect.NativeMethodAccessorImpl invoke NativeMethodAccessorImpl.java 62] [sun.reflect.DelegatingMethodAccessorImpl invoke DelegatingMethodAccessorImpl.java 43] [java.lang.reflect.Method invoke Method.java 498] [clojure.lang.Reflector invokeMatchingMethod Reflector.java 93] [clojure.lang.Reflector invokeInstanceMethod Reflector.java 28] [org.apache.storm.testing$submit_local_topology invoke testing.clj 310] [org.apache.storm.LocalCluster$_submitTopology invoke LocalCluster.clj 49] [org.apache.storm.LocalCluster submitTopology nil -1] [Start main Start.java 28]]} 26606 [main] ERROR o.a.s.s.o.a.z.s.NIOServerCnxnFactory - Thread Thread[main,5,main] died org.apache.storm.generated.InvalidTopologyException: null at org.apache.storm.daemon.common$validate_structure_BANG_.invoke(common.clj:178) ~[storm-core-1.1.2.jar:1.1.2] at org.apache.storm.daemon.common$system_topology_BANG_.invoke(common.clj:374) ~[storm-core-1.1.2.jar:1.1.2] at org.apache.storm.daemon.nimbus$mk_reified_nimbus$reify__10781.submitTopologyWithOpts(nimbus.clj:1727) ~[storm-core-1.1.2.jar:1.1.2] at org.apache.storm.daemon.nimbus$mk_reified_nimbus$reify__10781.submitTopology(nimbus.clj:1761) ~[storm-core-1.1.2.jar:1.1.2] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_161] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_161] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_161] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_161] at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93) ~[clojure-1.7.0.jar:?] at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28) ~[clojure-1.7.0.jar:?] at org.apache.storm.testing$submit_local_topology.invoke(testing.clj:310) ~[storm-core-1.1.2.jar:1.1.2] at org.apache.storm.LocalCluster$_submitTopology.invoke(LocalCluster.clj:49) ~[storm-core-1.1.2.jar:1.1.2] at org.apache.storm.LocalCluster.submitTopology(Unknown Source) ~[storm-core-1.1.2.jar:1.1.2] at Start.main(Start.java:28) ~[classes/:?]