Storm uses Kryo to serialize Tuples. Check this 
https://github.com/apache/storm/blob/master/storm-core/src/jvm/org/apache/storm/serialization/KryoTupleSerializer.java

 

Instead of serializing the entire tuple yourself may be you just want to 
serialize the relevant values within the tuple.

 

 

From: anshu shukla <anshushuk...@gmail.com>
Reply-To: "user@storm.apache.org" <user@storm.apache.org>
Date: Tuesday, March 21, 2017 at 8:40 AM
To: "user@storm.apache.org" <user@storm.apache.org>
Subject: Converting storm tuple to bytearray

 

Hello, 

 

1- Can anyone explain how to convert storm tuple to byte array. I have used the 
following code. 

 

private byte[] convertToBytes(Object object) throws IOException {

    try (ByteArrayOutputStream bos = new ByteArrayOutputStream();        
ObjectOutput out = new ObjectOutputStream(bos)) {   

     out.writeObject(object);

        return bos.toByteArray(); } }

 

Getting the following error :

java.io.NotSerializableException: org.apache.storm.tuple.TupleImpl

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1183)

at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)

at 
storm.starter.OurStatefulBoltByteArrayTuple.convertToBytes(OurStatefulBoltByteArrayTuple.java:200)

 

2- If the conversion can not be done like this then how does storm does 
serialization of tuple over the network. Can anyone point me out that code 
logic? 

Reply via email to