Search in sources :

Example 26 with Output

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);
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Output(com.esotericsoftware.kryo.io.Output)

Example 27 with Output

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();
}
Also used : Output(com.esotericsoftware.kryo.io.Output) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Kryo(com.esotericsoftware.kryo.Kryo)

Example 28 with Output

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();
}
Also used : Output(com.esotericsoftware.kryo.io.Output)

Example 29 with Output

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();
        }
    }
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) FileOutputStream(java.io.FileOutputStream) Output(com.esotericsoftware.kryo.io.Output) IOException(java.io.IOException)

Example 30 with Output

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();
        }
    }
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) FileOutputStream(java.io.FileOutputStream) Output(com.esotericsoftware.kryo.io.Output) IOException(java.io.IOException)

Aggregations

Output (com.esotericsoftware.kryo.io.Output)51 Kryo (com.esotericsoftware.kryo.Kryo)29 ByteArrayOutputStream (java.io.ByteArrayOutputStream)22 Input (com.esotericsoftware.kryo.io.Input)21 ByteArrayInputStream (java.io.ByteArrayInputStream)12 Test (org.junit.Test)8 FileOutputStream (java.io.FileOutputStream)7 Test (org.testng.annotations.Test)6 IOException (java.io.IOException)5 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)5 KryoException (com.esotericsoftware.kryo.KryoException)4 StdInstantiatorStrategy (org.objenesis.strategy.StdInstantiatorStrategy)4 SAMFileHeader (htsjdk.samtools.SAMFileHeader)3 Schema (co.cask.cdap.api.data.schema.Schema)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 HashMap (java.util.HashMap)2 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)2 StructuredRecord (co.cask.cdap.api.data.format.StructuredRecord)1 ClassIdPair (com.datatorrent.stram.codec.DefaultStatefulStreamCodec.ClassIdPair)1