You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metron.apache.org by Muhammed Irshad <ir...@gmail.com> on 2018/10/05 06:52:19 UTC

Custom parser using Jackson instead of json-simple

Hi All,

Is it not possible to use any Json library other than json-simple
<https://code.google.com/archive/p/json-simple/> while writing custom
parsers ? I could see we should implement custom parser interface
MessageParser<JsonObject> in document. What if I need to use Jackson
instead of json-simple ? I see Jackson performs better than json-simple in
few aspects in some of the benchmark studies. I tried writing a custom
parser implementing MessageParser<JsonNode> ( Jackson's JsonNode ). No
compiler errors. I am getting below error when I deploy and run this parser
in HCP.

2018-10-05 04:42:09.829 o.a.s.d.executor Thread-12-parserBolt-executor[5 5]
[ERROR]
java.lang.ClassCastException: org.codehaus.jackson.node.ObjectNode cannot
be cast to org.json.simple.JSONObject
at org.apache.metron.parsers.bolt.ParserBolt.execute(ParserBolt.java:187)
[stormjar.jar:?
]
at
org.apache.storm.daemon.executor$fn__10252$tuple_action_fn__10254.invoke(executor.clj:735)
[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at
org.apache.storm.daemon.executor$mk_task_receiver$fn__10171.invoke(executor.clj:466)
[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at
org.apache.storm.disruptor$clojure_handler$reify__9685.onEvent(disruptor.clj:40)
[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at
org.apache.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:472)
[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at
org.apache.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:451)
[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at
org.apache.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:73)
[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at
org.apache.storm.daemon.executor$fn__10252$fn__10265$fn__10320.invoke(executor.clj:855)
[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at org.apache.storm.util$async_loop$fn__553.invoke(util.clj:484)
[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at clojure.lang.AFn.run(AFn.java:22) [clojure-1.7.0.jar:?
]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_112]
2018-10-05 04:42:09.850 o.a.s.d.executor Thread-12-parserBolt-executor[5 5]
[ERROR]


-- 
Muhammed Irshad K T
Senior Software Engineer
+919447946359
irshadkt.mec@gmail.com
Skype : muhammed.irshad.k.t

Re: Custom parser using Jackson instead of json-simple

Posted by Otto Fowler <ot...@gmail.com>.
The ParserBolt is written to JSON simple, so although the interface is <T>
in practice it is <JSONObject>.  The answer is no right now.

Feel free to open a jira.


On October 5, 2018 at 02:52:37, Muhammed Irshad (irshadkt.mec@gmail.com)
wrote:

Hi All,

Is it not possible to use any Json library other than json-simple
<https://code.google.com/archive/p/json-simple/> while writing custom
parsers ? I could see we should implement custom parser interface
MessageParser<JsonObject> in document. What if I need to use Jackson
instead of json-simple ? I see Jackson performs better than json-simple in
few aspects in some of the benchmark studies. I tried writing a custom
parser implementing MessageParser<JsonNode> ( Jackson's JsonNode ). No
compiler errors. I am getting below error when I deploy and run this parser
in HCP.

2018-10-05 04:42:09.829 o.a.s.d.executor Thread-12-parserBolt-executor[5 5]
[ERROR]
java.lang.ClassCastException: org.codehaus.jackson.node.ObjectNode cannot
be cast to org.json.simple.JSONObject
at org.apache.metron.parsers.bolt.ParserBolt.execute(ParserBolt.java:187)
[stormjar.jar:?
]
at
org.apache.storm.daemon.executor$fn__10252$tuple_action_fn__10254.invoke(executor.clj:735)

[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at
org.apache.storm.daemon.executor$mk_task_receiver$fn__10171.invoke(executor.clj:466)

[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at
org.apache.storm.disruptor$clojure_handler$reify__9685.onEvent(disruptor.clj:40)

[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at
org.apache.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:472)

[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at
org.apache.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:451)

[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at
org.apache.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:73)

[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at
org.apache.storm.daemon.executor$fn__10252$fn__10265$fn__10320.invoke(executor.clj:855)

[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at org.apache.storm.util$async_loop$fn__553.invoke(util.clj:484)
[storm-core-1.1.0.2.6.5.0-292.jar:1.1.0.2.6.5.0-292]
at clojure.lang.AFn.run(AFn.java:22) [clojure-1.7.0.jar:?
]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_112]
2018-10-05 04:42:09.850 o.a.s.d.executor Thread-12-parserBolt-executor[5 5]
[ERROR]


-- 
Muhammed Irshad K T
Senior Software Engineer
+919447946359
irshadkt.mec@gmail.com
Skype : muhammed.irshad.k.t