use of com.esotericsoftware.kryo.io.Output in project storm by apache.
the class HttpForwardingMetricsConsumer method handleDataPoints.
@Override
public void handleDataPoints(TaskInfo taskInfo, Collection<DataPoint> dataPoints) {
try {
HttpURLConnection con = (HttpURLConnection) _url.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
Output out = new Output(con.getOutputStream());
_serializer.serializeInto(Arrays.asList(taskInfo, dataPoints), out);
out.flush();
out.close();
//The connection is not sent unless a response is requested
int response = con.getResponseCode();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.esotericsoftware.kryo.io.Output in project hive by apache.
the class SerializationUtilities method serializeObjectToKryo.
private static byte[] serializeObjectToKryo(Serializable object) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Output output = new Output(baos);
Kryo kryo = borrowKryo();
try {
kryo.writeObject(output, object);
} finally {
releaseKryo(kryo);
}
output.close();
return baos.toByteArray();
}
use of com.esotericsoftware.kryo.io.Output in project hive by apache.
the class SerializationUtilities method serializeObjectByKryo.
/**
* @param plan Usually of type MapredWork, MapredLocalWork etc.
* @param out stream in which serialized plan is written into
*/
private static void serializeObjectByKryo(Kryo kryo, Object plan, OutputStream out) {
Output output = new Output(out);
kryo.setClassLoader(Utilities.getSessionSpecifiedClassLoader());
kryo.writeObject(output, plan);
output.close();
}
use of com.esotericsoftware.kryo.io.Output in project hive by apache.
the class KeyValueContainer method setupOutput.
private void setupOutput(String spillLocalDirs) throws IOException, HiveException {
FileOutputStream fos = null;
try {
if (parentDir == null) {
parentDir = FileUtils.createLocalDirsTempFile(spillLocalDirs, "key-value-container", "", true);
parentDir.deleteOnExit();
}
if (tmpFile == null || input != null) {
tmpFile = File.createTempFile("KeyValueContainer", ".tmp", parentDir);
LOG.info("KeyValueContainer created temp file " + tmpFile.getAbsolutePath());
tmpFile.deleteOnExit();
}
fos = new FileOutputStream(tmpFile);
output = new Output(fos);
} catch (IOException e) {
throw new HiveException(e);
} finally {
if (output == null && fos != null) {
fos.close();
}
}
}
use of com.esotericsoftware.kryo.io.Output in project hive by apache.
the class ObjectContainer method setupOutput.
private void setupOutput(String spillLocalDirs) throws IOException, HiveException {
FileOutputStream fos = null;
try {
if (parentDir == null) {
parentDir = FileUtils.createLocalDirsTempFile(spillLocalDirs, "object-container", "", true);
}
if (tmpFile == null || input != null) {
tmpFile = File.createTempFile("ObjectContainer", ".tmp", parentDir);
LOG.info("ObjectContainer created temp file " + tmpFile.getAbsolutePath());
tmpFile.deleteOnExit();
}
fos = new FileOutputStream(tmpFile);
output = new Output(fos);
} catch (IOException e) {
throw new HiveException(e);
} finally {
if (output == null && fos != null) {
fos.close();
}
}
}
Aggregations