Esempio n. 1
0
 @Override
 public Event fromBytes(byte[] bytes) {
   Kryo kryo = pool.borrow();
   try (Input in = new Input(bytes)) {
     return (Event) kryo.readClassAndObject(in);
   } finally {
     pool.release(kryo);
   }
 }
Esempio n. 2
0
 @Override
 public byte[] toBytes(Event event) {
   Kryo kryo = pool.borrow();
   try (Output out = new Output(new java.io.ByteArrayOutputStream())) {
     kryo.writeClassAndObject(out, event);
     return out.toBytes();
   } finally {
     pool.release(kryo);
   }
 }
 /**
  * Release kryo instance back to the pool.
  *
  * @param kryo - kryo instance to be released
  */
 public static void releaseKryo(Kryo kryo) {
   kryoPool.release(kryo);
 }