Package com.netflix.zeno.fastblob.io

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


    }

    private void roundTripStateEngine(FastBlobStateEngine stateEngine) throws Exception, IOException {
        stateEngine.prepareForWrite();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        new FastBlobWriter(stateEngine).writeSnapshot(baos);
        new FastBlobReader(stateEngine).readSnapshot(new ByteArrayInputStream(baos.toByteArray()));
    }
View Full Code Here


    }

    private void fillDeserializationWithImage(FastBlobStateEngine serverStateEngine, FastBlobStateEngine clientStateEngine,
            int imageIndex) throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        FastBlobWriter writer = new FastBlobWriter(serverStateEngine, imageIndex);
        writer.writeSnapshot(baos);

        FastBlobReader reader = new FastBlobReader(clientStateEngine);
        reader.readSnapshot(new ByteArrayInputStream(baos.toByteArray()));
    }
View Full Code Here

        /// serialize that data
        stateEngine1.prepareForWrite();

        ByteArrayOutputStream serializedSnapshotState1 = new ByteArrayOutputStream();

        new FastBlobWriter(stateEngine1, 0).writeSnapshot(new DataOutputStream(serializedSnapshotState1));

        /// serialize the state engine
        ByteArrayOutputStream serializedStateEngine1 = new ByteArrayOutputStream();

        stateEngine1.serializeTo(serializedStateEngine1);

        /// server is restarted with updated serializers
        FastBlobStateEngine stateEngine2 = new FastBlobStateEngine(state2Factory());

        /// deserialize the state engine from the previous server (with the old serializers)
        stateEngine2.deserializeFrom(new ByteArrayInputStream(serializedStateEngine1.toByteArray()));
        stateEngine2.prepareForNextCycle();

        /// add new data to the state engine, with some overlap
        TypeC c1 = new TypeC(1);
        TypeC c2 = new TypeC(2);
        TypeC c3 = new TypeC(3);

        stateEngine2.add("TypeA", new TypeAState2(1, c1));
        stateEngine2.add("TypeA", new TypeAState2(2, c2));
        stateEngine2.add("TypeA", new TypeAState2(4, c3));

        stateEngine2.add("TypeB", new TypeB(1));
        stateEngine2.add("TypeB", new TypeB(9));
        stateEngine2.add("TypeB", new TypeB(3));

        stateEngine2.setLatestVersion("test");

        /// serialize a delta between the previous state and this state
        stateEngine2.prepareForWrite();

        ByteArrayOutputStream serializedDeltaState2 = new ByteArrayOutputStream();

        new FastBlobWriter(stateEngine2, 0).writeDelta(new DataOutputStream(serializedDeltaState2));


        /// now we need to deserialize.  Deserialize first the snapshot produced by server 1, then the delta produced by server 2 (with different serializers)
        new FastBlobReader(stateEngine1).readSnapshot(new ByteArrayInputStream(serializedSnapshotState1.toByteArray()));
        new FastBlobReader(stateEngine1).readDelta(new ByteArrayInputStream(serializedDeltaState2.toByteArray()));
View Full Code Here


    private void serializeAndDeserialize(FastBlobStateEngine stateEngine) throws IOException {
        stateEngine.prepareForWrite();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        FastBlobWriter writer = new FastBlobWriter(stateEngine, 0);
        writer.writeSnapshot(new DataOutputStream(baos));
        FastBlobReader reader = new FastBlobReader(stateEngine);
        reader.readSnapshot(new ByteArrayInputStream(baos.toByteArray()));
    }
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.