use of com.esotericsoftware.kryo.io.OutputChunked in project alluxio by Alluxio.
the class JournalUtils method writeToCheckpoint.
/**
* Writes a composite checkpoint for the given checkpointed components.
*
* This is the complement of {@link #restoreFromCheckpoint(CheckpointInputStream, List)}.
*
* @param output the stream to write to
* @param components the components to checkpoint
*/
public static void writeToCheckpoint(OutputStream output, List<? extends Checkpointed> components) throws IOException, InterruptedException {
OutputChunked chunked = new OutputChunked(new CheckpointOutputStream(output, CheckpointType.COMPOUND), 64 * Constants.KB);
for (Checkpointed component : components) {
chunked.writeString(component.getCheckpointName().toString());
component.writeToCheckpoint(chunked);
chunked.endChunks();
}
chunked.flush();
}
use of com.esotericsoftware.kryo.io.OutputChunked in project beam by apache.
the class KryoCoder method encode.
@Override
public void encode(T value, OutputStream outStream) throws IOException {
final KryoState kryoState = KryoState.get(this);
if (value == null) {
throw new CoderException("Cannot encode a null value.");
}
final OutputChunked outputChunked = kryoState.getOutputChunked();
outputChunked.setOutputStream(outStream);
try {
kryoState.getKryo().writeClassAndObject(outputChunked, value);
outputChunked.endChunks();
outputChunked.flush();
} catch (KryoException e) {
outputChunked.clear();
if (e.getCause() instanceof EOFException) {
throw (EOFException) e.getCause();
}
throw new CoderException("Cannot encode given object of type [" + value.getClass() + "].", e);
} catch (IllegalArgumentException e) {
String message = e.getMessage();
if (message != null) {
if (message.startsWith("Class is not registered")) {
throw new CoderException(message);
}
}
throw e;
}
}
Aggregations