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