Search in sources :

Example 1 with OutputArchive

use of org.apache.jute_voltpatches.OutputArchive in project voltdb by VoltDB.

the class FileSnap method serialize.

/**
     * serialize the datatree and session into the file snapshot
     * @param dt the datatree to be serialized
     * @param sessions the sessions to be serialized
     * @param snapShot the file to store snapshot into
     */
@Override
public synchronized void serialize(DataTree dt, Map<Long, Long> sessions, File snapShot) throws IOException {
    if (!close) {
        OutputStream sessOS = new BufferedOutputStream(new FileOutputStream(snapShot));
        CheckedOutputStream crcOut = new CheckedOutputStream(sessOS, new Adler32());
        //CheckedOutputStream cout = new CheckedOutputStream()
        OutputArchive oa = BinaryOutputArchive.getArchive(crcOut);
        FileHeader header = new FileHeader(SNAP_MAGIC, VERSION, dbId);
        serialize(dt, sessions, oa, header);
        long val = crcOut.getChecksum().getValue();
        oa.writeLong(val, "val");
        oa.writeString("/", "path");
        sessOS.flush();
        crcOut.close();
        sessOS.close();
    }
}
Also used : BinaryOutputArchive(org.apache.jute_voltpatches.BinaryOutputArchive) OutputArchive(org.apache.jute_voltpatches.OutputArchive) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) CheckedOutputStream(java.util.zip.CheckedOutputStream) FileOutputStream(java.io.FileOutputStream) CheckedOutputStream(java.util.zip.CheckedOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) FileHeader(org.apache.zookeeper_voltpatches.server.persistence.FileHeader) Adler32(java.util.zip.Adler32)

Example 2 with OutputArchive

use of org.apache.jute_voltpatches.OutputArchive in project voltdb by VoltDB.

the class Util method marshallTxnEntry.

/**
     * Serializes transaction header and transaction data into a byte buffer.
     *
     * @param hdr transaction header
     * @param txn transaction data
     * @return serialized transaction record
     * @throws IOException
     */
public static byte[] marshallTxnEntry(TxnHeader hdr, Record txn) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    OutputArchive boa = BinaryOutputArchive.getArchive(baos);
    hdr.serialize(boa, "hdr");
    if (txn != null) {
        txn.serialize(boa, "txn");
    }
    return baos.toByteArray();
}
Also used : BinaryOutputArchive(org.apache.jute_voltpatches.BinaryOutputArchive) OutputArchive(org.apache.jute_voltpatches.OutputArchive) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

BinaryOutputArchive (org.apache.jute_voltpatches.BinaryOutputArchive)2 OutputArchive (org.apache.jute_voltpatches.OutputArchive)2 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 Adler32 (java.util.zip.Adler32)1 CheckedOutputStream (java.util.zip.CheckedOutputStream)1 FileHeader (org.apache.zookeeper_voltpatches.server.persistence.FileHeader)1