use of com.esotericsoftware.kryo.io.Output in project apex-core by apache.
the class Journal method setOutputStream.
public void setOutputStream(@Nullable final OutputStream out) throws IOException {
final Output output;
if (out != null) {
output = new Output(4096, -1) {
@Override
public void flush() throws KryoException {
super.flush();
// Kryo does not flush internal output stream during flush. We need to flush it explicitly.
try {
getOutputStream().flush();
} catch (IOException e) {
throw new KryoException(e);
}
}
};
output.setOutputStream(out);
} else {
output = null;
}
final Output oldOut = this.output.getAndSet(output);
if (oldOut != null && oldOut.getOutputStream() != out) {
synchronized (oldOut) {
oldOut.close();
}
}
}
use of com.esotericsoftware.kryo.io.Output in project apex-core by apache.
the class FSStorageAgent method store.
public static void store(OutputStream stream, Object operator) {
synchronized (kryo) {
Output output = new Output(4096, Integer.MAX_VALUE);
output.setOutputStream(stream);
kryo.writeClassAndObject(output, operator);
output.flush();
}
}
use of com.esotericsoftware.kryo.io.Output in project ignite by apache.
the class KryoSerializer method serialize.
/** {@inheritDoc} */
@Override
public ByteBuffer serialize(Object obj) {
if (obj == null)
return null;
ByteArrayOutputStream stream = null;
Output out = null;
try {
stream = new ByteArrayOutputStream(DFLT_BUFFER_SIZE);
out = new Output(stream);
kryos.get().writeClassAndObject(out, obj);
out.flush();
return ByteBuffer.wrap(stream.toByteArray());
} catch (Throwable e) {
throw new IllegalStateException("Failed to serialize object of the class '" + obj.getClass().getName() + "'", e);
} finally {
U.closeQuiet(out);
U.closeQuiet(stream);
}
}
use of com.esotericsoftware.kryo.io.Output in project heron by twitter.
the class HeronPluggableSerializerDelegate method initialize.
@Override
@SuppressWarnings("rawtypes")
public void initialize(Map config) {
kryo = SerializationFactory.getKryo(config);
kryoOut = new Output(2000, 2000000000);
kryoIn = new Input(1);
}
use of com.esotericsoftware.kryo.io.Output in project intellij-community by JetBrains.
the class ExternalProjectSerializer method save.
public void save(@NotNull ExternalProject externalProject) {
Output output = null;
try {
final File externalProjectDir = externalProject.getProjectDir();
final File configurationFile = getProjectConfigurationFile(new ProjectSystemId(externalProject.getExternalSystemId()), externalProjectDir);
if (!FileUtil.createParentDirs(configurationFile))
return;
output = new Output(new FileOutputStream(configurationFile));
myKryo.writeObject(output, externalProject);
LOG.debug("Data saved for imported project from: " + externalProjectDir.getPath());
} catch (FileNotFoundException e) {
LOG.error(e);
} finally {
StreamUtil.closeStream(output);
}
}
Aggregations