/** * Get the object represented by the given serialized bytes. * * @param in * the bytes to deserialize * @return the resulting object */ @Override public ConcurrentMap<String, Object> deserializeAttributes(final byte[] in ) { final ByteArrayInputStream bis = new ByteArrayInputStream( in ); try { @SuppressWarnings( "unchecked" ) final ConcurrentMap<String, Object> result = (ConcurrentMap<String, Object>) _xstream.fromXML( bis ); return result; } catch ( final RuntimeException e ) { LOG.warn( "Caught Exception decoding "+ in.length +" bytes of data", e ); throw new TranscoderDeserializationException(e); } finally { closeSilently( bis ); } }
/** * Return the deserialized map * * @param in bytes to deserialize * @return map of deserialized objects */ @Override public ConcurrentMap<String, Object> deserializeAttributes(final byte[] in) { final InputStreamReader inputStream = new InputStreamReader( new ByteArrayInputStream( in ) ); if (LOG.isDebugEnabled()) { LOG.debug("deserialize the stream"); } try { return deserializer.deserializeInto(inputStream, new ConcurrentHashMap<String, Object>()); } catch( final RuntimeException e) { LOG.warn("Caught Exception deserializing JSON "+e); throw new TranscoderDeserializationException(e); } }
} catch ( final ClassNotFoundException e ) { LOG.warn( "Caught CNFE decoding "+ in.length +" bytes of data", e ); throw new TranscoderDeserializationException( "Caught CNFE decoding data", e ); } catch ( final IOException e ) { LOG.warn( "Caught IOException decoding "+ in.length +" bytes of data", e ); throw new TranscoderDeserializationException( "Caught IOException decoding data", e ); } finally { closeSilently( bis );
/** * {@inheritDoc} */ @SuppressWarnings( "unchecked" ) @Override public ConcurrentMap<String, Object> deserializeAttributes(final byte[] data ) { final Kryo kryo = _kryoPool.borrow(); Input in = null; try { in = kryo.getStreamFactory().getInput(data); return kryo.readObject(in, ConcurrentHashMap.class); } catch ( final RuntimeException e ) { throw new TranscoderDeserializationException( e ); } finally { closeSilently(in); kryo.reset(); // to be safe _kryoPool.release(kryo); } }
/** * {@inheritDoc} */ @Override public byte[] serializeAttributes( final MemcachedBackupSession session, final ConcurrentMap<String, Object> attributes ) { final Kryo kryo = _kryoPool.borrow(); Output out = null; try { /** * Creates an ObjectStream with an initial buffer size of 50KB and a maximum size of 1000KB. */ out = kryo.getStreamFactory().getOutput(_initialBufferSize, _maxBufferSize); kryo.writeObject(out, attributes); return out.toBytes(); } catch ( final RuntimeException e ) { throw new TranscoderDeserializationException( e ); } finally { closeSilently(out); kryo.reset(); // to be safe _kryoPool.release(kryo); } }
} catch ( final ClassNotFoundException e ) { LOG.warn( "Caught CNFE decoding "+ in.length +" bytes of data", e ); throw new TranscoderDeserializationException( "Caught CNFE decoding data", e ); } catch ( final IOException e ) { LOG.warn( "Caught IOException decoding "+ in.length +" bytes of data", e ); throw new TranscoderDeserializationException( "Caught IOException decoding data", e ); } finally { closeSilently( bis );