Search in sources :

Example 1 with CorfuCompileProxy

use of org.corfudb.runtime.object.CorfuCompileProxy in project CorfuDB by CorfuDB.

the class MultiCheckpointWriter method appendCheckpoints.

/** Checkpoint multiple SMRMaps serially.
     *
     * @param rt CorfuRuntime
     * @param author Author's name, stored in checkpoint metadata
     * @param postAppendFunc User-supplied lambda for post-append action on each
     *                       checkpoint entry type.
     * @return Global log address of the first record of
     * @throws Exception
     */
public long appendCheckpoints(CorfuRuntime rt, String author, BiConsumer<CheckpointEntry, Long> postAppendFunc) throws Exception {
    long globalAddress = CheckpointWriter.startGlobalSnapshotTxn(rt);
    try {
        for (ICorfuSMR<Map> map : maps) {
            UUID streamID = map.getCorfuStreamID();
            CheckpointWriter cpw = new CheckpointWriter(rt, streamID, author, (SMRMap) map);
            ISerializer serializer = ((CorfuCompileProxy<Map>) map.getCorfuSMRProxy()).getSerializer();
            cpw.setSerializer(serializer);
            cpw.setPostAppendFunc(postAppendFunc);
            List<Long> addresses = cpw.appendCheckpoint();
            checkpointLogAddresses.addAll(addresses);
        }
    } finally {
        rt.getObjectsView().TXEnd();
    }
    return globalAddress;
}
Also used : CorfuCompileProxy(org.corfudb.runtime.object.CorfuCompileProxy) UUID(java.util.UUID) Map(java.util.Map) SMRMap(org.corfudb.runtime.collections.SMRMap) ISerializer(org.corfudb.util.serializer.ISerializer)

Aggregations

Map (java.util.Map)1 UUID (java.util.UUID)1 SMRMap (org.corfudb.runtime.collections.SMRMap)1 CorfuCompileProxy (org.corfudb.runtime.object.CorfuCompileProxy)1 ISerializer (org.corfudb.util.serializer.ISerializer)1