Search in sources :

Example 1 with KryoTupleDeserializer

use of backtype.storm.serialization.KryoTupleDeserializer in project jstorm by alibaba.

the class WorkerData method updateKryoSerializer.

// create kryo serializer
public void updateKryoSerializer() {
    WorkerTopologyContext workerTopologyContext = contextMaker.makeWorkerTopologyContext(sysTopology);
    KryoTupleDeserializer kryoTupleDeserializer = new KryoTupleDeserializer(stormConf, workerTopologyContext, workerTopologyContext.getRawTopology());
    KryoTupleSerializer kryoTupleSerializer = new KryoTupleSerializer(stormConf, workerTopologyContext.getRawTopology());
    atomKryoDeserializer.getAndSet(kryoTupleDeserializer);
    atomKryoSerializer.getAndSet(kryoTupleSerializer);
}
Also used : WorkerTopologyContext(backtype.storm.task.WorkerTopologyContext) KryoTupleDeserializer(backtype.storm.serialization.KryoTupleDeserializer) KryoTupleSerializer(backtype.storm.serialization.KryoTupleSerializer)

Example 2 with KryoTupleDeserializer

use of backtype.storm.serialization.KryoTupleDeserializer in project jstorm by alibaba.

the class VirtualPortCtrlDispatch method deserialize.

protected Object deserialize(byte[] ser_msg, int taskId) {
    try {
        if (ser_msg == null) {
            return null;
        }
        if (ser_msg.length == 0) {
            return null;
        } else if (ser_msg.length == 1) {
            //ignore
            return null;
        }
        Tuple tuple = null;
        // ser_msg.length > 1
        KryoTupleDeserializer kryo = atomKryoDeserializer.get();
        if (kryo != null)
            tuple = kryo.deserialize(ser_msg);
        return tuple;
    } catch (Throwable e) {
        if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e))
            throw new RuntimeException(e);
        LOG.error(idStr + " recv thread error " + JStormUtils.toPrintableString(ser_msg) + "\n", e);
    }
    return null;
}
Also used : KryoException(com.esotericsoftware.kryo.KryoException) KryoTupleDeserializer(backtype.storm.serialization.KryoTupleDeserializer) Tuple(backtype.storm.tuple.Tuple)

Aggregations

KryoTupleDeserializer (backtype.storm.serialization.KryoTupleDeserializer)2 KryoTupleSerializer (backtype.storm.serialization.KryoTupleSerializer)1 WorkerTopologyContext (backtype.storm.task.WorkerTopologyContext)1 Tuple (backtype.storm.tuple.Tuple)1 KryoException (com.esotericsoftware.kryo.KryoException)1