FastBlobStateEngine behavior for fresh start vs. when initialized using a snapshot

55 views
Skip to first unread message

Regunath Balasubramanian

unread,
Mar 26, 2014, 9:35:30 AM3/26/14
to netfli...@googlegroups.com
Hello,

I have a cron-like timer triggered Java process that produces snapshots and deltas from a data store at periodic intervals - one snapshot per day followed by 30 minute deltas.
The snapshot files are understandably larger than deltas and I can see the delta file sizes vary by the quantum of changes in each cycle.

In case of a restart (or) fresh start, I create the FastBlobStateEngine and use the FastBlobReader to read in any existing snapshot. I then add objects to it in the read cycle. At the end of it, I write out a snapshot or delta depending on the scheme (daily snapshots followed by minute-wise deltas). The code is somewhat like:

stateEngine = new FastBlobStateEngine(serializerFactory);

FastBlobReader previousStateReader = new FastBlobReader(stateEngine);

previousStateReader.readSnapshot(new DataInputStream(new BufferedInputStream(new FileInputStream(snapshotFile))));

stateEngine.setLatestVersion(<version derived from snapshotFile>);

stateEngine.prepareForNextCycle();

// now fetch and add items to state engine for a cycle

fetchItemsFromDataStore();

addItemsToStateEngine();

// write the output snapshot or delta

stateEngine.prepareForWrite();

FastBlobWriter writer = new FastBlobWriter(stateEngine);

writer.writeDelta(<File output stream>);

stateEngine.prepareForNextCycle();

I notice that the first delta file, when written, is of the same size (and contents maybe) as the snapshot file that the state engine was initialized with (using the FastBlobReader as described above). I would expect the delta file to be much smaller and only contain changes over the snapshot that was read. However subsequent delta files are created with contents and size as expected i.e. only changes from the last run cycle.

Is this behavior as per design? 

Thanks
Regu

Regunath Balasubramanian

unread,
Mar 31, 2014, 8:11:28 AM3/31/14
to netfli...@googlegroups.com
Hello,

Please ignore this question. I have changed my implementation to separate out FastBlobStateEngine instances used in write path and the read path. This ensures I donot append objects to a state engine to which data was added using the FastBlobReader.

Regards
Regu
Reply all
Reply to author
Forward
0 new messages