Package com.netflix.zeno.fastblob.io

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


        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


    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

            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

        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()));

        /// get the type As
        FastBlobTypeDeserializationState<TypeAState1> typeAs = stateEngine1.getTypeDeserializationState("TypeA");

        /// here we use some implicit knowledge about how the state engine works to verify the functionality...
        /// A's serializer changed, so the ordinals for the new objects should not overlap with any of the original
        /// ordinals (0, 1, 2).
        Assert.assertEquals(1, typeAs.get(3).getA1());
        Assert.assertEquals(2, typeAs.get(4).getA1());
        Assert.assertEquals(4, typeAs.get(5).getA1());

        FastBlobTypeDeserializationState<TypeB> typeBs = stateEngine1.getTypeDeserializationState("TypeB");

        /// B's serializer did not change.  The ordinals for objects which exist across states will be reused (0, 2)
        /// one new ordinal will be added for the changed object (3)
        Assert.assertEquals(1, typeBs.get(0).getB1());
        Assert.assertEquals(3, typeBs.get(2).getB1());
        Assert.assertEquals(9, typeBs.get(3).getB1());

        FastBlobStateEngine removedTypeBStateEngine = new FastBlobStateEngine(removedTypeBFactory());

        new FastBlobReader(removedTypeBStateEngine).readSnapshot(new ByteArrayInputStream(serializedSnapshotState1.toByteArray()));
        new FastBlobReader(removedTypeBStateEngine).readDelta(new ByteArrayInputStream(serializedDeltaState2.toByteArray()));


        /// get the type As
        FastBlobTypeDeserializationState<TypeAState2> typeA2s = removedTypeBStateEngine.getTypeDeserializationState("TypeA");
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.FastBlobReader

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.