Package com.netflix.zeno.fastblob.io

Examples of com.netflix.zeno.fastblob.io.FastBlobWriter


        stateEngine.prepareForWrite();

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        FastBlobWriter writer = new FastBlobWriter(stateEngine);
        writer.writeSnapshot(baos);

        FastBlobStateEngine deserializeEngine = typeAStateEngine();

        FastBlobReader reader = new FastBlobReader(deserializeEngine);

        reader.readSnapshot(new ByteArrayInputStream(baos.toByteArray()));

        deserializeEngine.fillSerializationStatesFromDeserializedData();

        deserializeEngine.prepareForWrite();

        ByteArrayOutputStream reserializedStream = new ByteArrayOutputStream();

        FastBlobWriter rewriter = new FastBlobWriter(deserializeEngine);

        rewriter.writeSnapshot(reserializedStream);

        Assert.assertArrayEquals(baos.toByteArray(), reserializedStream.toByteArray());

        System.out.println(Arrays.toString(baos.toByteArray()));
        System.out.println(Arrays.toString(reserializedStream.toByteArray()));
View Full Code Here


        this.baos = new ByteArrayOutputStream();
    }

    protected void serializeAndDeserializeDelta() throws IOException, Exception {
        serializationState.prepareForWrite();
        new FastBlobWriter(serializationState, 0).writeDelta(new DataOutputStream(baos));
        serializationState.prepareForNextCycle();
        new FastBlobReader(serializationState).readDelta(new ByteArrayInputStream(baos.toByteArray()));
        baos.reset();
    }
View Full Code Here

        new FastBlobReader(serializationState).readSnapshot(is);
    }

    protected byte[] serializeSnapshot() throws IOException {
        serializationState.prepareForWrite();
        new FastBlobWriter(serializationState, 0).writeSnapshot(new DataOutputStream(baos));
        serializationState.prepareForNextCycle();
        baos.close();
        final byte data[] = baos.toByteArray();
        baos.reset();
        return data;
View Full Code Here

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dataOutputStream = new DataOutputStream(baos);

        stateEngine.prepareForWrite();

        FastBlobWriter writer = new FastBlobWriter(stateEngine);
        writer.writeSnapshot(dataOutputStream);

        FastBlobReader reader = new FastBlobReader(stateEngine);
        reader.readSnapshot(new ByteArrayInputStream(baos.toByteArray()));

        return stateEngine;
View Full Code Here

        stateEngine.prepareForWrite();

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        FastBlobWriter writer = new FastBlobWriter(stateEngine);
        writer.writeSnapshot(baos);
        snapshot1 = baos.toByteArray();
        baos.reset();

        stateEngine.prepareForNextCycle();

        /// second state removes 3, 7, 10 and adds 11, 12
        addFs(1, 2, 4, 5, 6, 8, 9, 11, 12);

        stateEngine.prepareForWrite();

        writer.writeDelta(baos);
        delta = baos.toByteArray();
        baos.reset();

        writer.writeSnapshot(baos);
        snapshot2 = baos.toByteArray();
        baos.reset();

        /// we also create a broken delta chain to cause ordinal reassignments.
        stateEngine = newStateEngine();

        addFs(1, 2, 4, 5, 6, 8, 9, 11, 12);

        stateEngine.prepareForWrite();

        writer = new FastBlobWriter(stateEngine);
        writer.writeSnapshot(baos);
        brokenDeltaChainSnapshot2 = baos.toByteArray();
   }
View Full Code Here

        /// The following lets the state engine know that we have finished adding all of our
        /// objects to the state.
        stateEngine.prepareForWrite();

        /// Create a writer, which will be responsible for creating snapshot and/or delta blobs.
        FastBlobWriter writer = new FastBlobWriter(stateEngine);

        /// Create an output stream to somewhere.  This can be to a local file on disk
        /// or directly to the blob destination.  The VMS team writes this data directly
        /// to disk, and then spawns a new thread to upload the data to S3.
        /// We need to pass a DataOutputStream.  Remember that DataOutputStream is not buffered,
        /// so if you write to a FileOutputStream or other non-buffered source, you likely want to
        /// make the DataOutputStream wrap a BufferedOutputStream
        /// (e.g. new DataOutputStream(new BufferedOutputStream(new FileOutputStream(destinationFile))))
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream outputStream = new DataOutputStream(baos);

        try {
            /// write the snapshot to the output stream.
            writer.writeSnapshot(outputStream);
        } catch(IOException e) {
            /// the FastBlobWriter throws an IOException if it is
            /// unable to write to the provided OutputStream
        } finally {
            /// it is your responsibility to close the stream.  The FastBlobWriter will not do this.
View Full Code Here

        /// We must again let the state engine know that we have finished adding all of our
        /// objects to the state.
        stateEngine.prepareForWrite();

        /// Create a writer, which will be responsible for creating snapshot and/or delta blobs.
        FastBlobWriter writer = new FastBlobWriter(stateEngine);

        /// Again create an output stream
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream outputStream = new DataOutputStream(baos);

        try {
            /// This time write the delta file.
            writer.writeDelta(outputStream);
        } catch(IOException e) {
            /// thrown if the FastBlobWriter was unable to write to the provided stream.
        } finally {
            try {
                outputStream.close();
View Full Code Here

        /// objects to the state.
        stateEngine.prepareForWrite();

        /// Create a writer, which will be responsible for creating snapshot and/or delta blobs.
        /// Note that we specify the index of the image we wish to write.
        FastBlobWriter writer = new FastBlobWriter(stateEngine, 0);

        image1Snapshot = writeSnapshot(writer);
        image2Snapshot = writeSnapshot(new FastBlobWriter(stateEngine, 1));
    }
View Full Code Here

        /// objects to the state.
        stateEngine.prepareForWrite();

        /// Create a writer, which will be responsible for creating snapshot and/or delta blobs.
        /// Again, note that we are specifying the index of image we wish to write.
        FastBlobWriter writer = new FastBlobWriter(stateEngine, 0);

        image1Delta = writeDelta(writer);
        image2Delta = writeDelta(new FastBlobWriter(stateEngine, 1));
    }
View Full Code Here

    protected void roundTripObjects(FastBlobStateEngine stateEngine) throws IOException {
        stateEngine.prepareForWrite();

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        FastBlobWriter writer = new FastBlobWriter(stateEngine);
        writer.writeSnapshot(new DataOutputStream(baos));

        FastBlobReader reader = new FastBlobReader(stateEngine);
        reader.readSnapshot(new ByteArrayInputStream(baos.toByteArray()));

        stateEngine.prepareForNextCycle();
View Full Code Here

TOP

Related Classes of com.netflix.zeno.fastblob.io.FastBlobWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.