Search in sources :

Example 6 with CheckpointEntry

use of org.corfudb.protocols.logprotocol.CheckpointEntry in project CorfuDB by CorfuDB.

the class BackpointerStreamView method examineCheckpointRecord.

private void examineCheckpointRecord(final QueuedStreamContext context, ILogData currentEntry, boolean considerCheckpoint, long currentRead) {
    CheckpointEntry.CheckpointEntryType cpType = currentEntry.getCheckpointType();
    UUID cpID = currentEntry.getCheckpointID();
    if (context.checkpointSuccessID == null && cpType == CheckpointEntry.CheckpointEntryType.END) {
        CheckpointEntry cpEntry = (CheckpointEntry) currentEntry.getPayload(runtime);
        log.trace("Checkpoint: address {} found END, id {} author {}", currentRead, cpEntry.getCheckpointID(), cpEntry.getCheckpointAuthorID());
        if (considerCheckpoint) {
            context.checkpointSuccessID = cpEntry.getCheckpointID();
            context.checkpointSuccessNumEntries = 1L;
            context.checkpointSuccessBytes = (long) currentEntry.getSizeEstimate();
            context.checkpointSuccessEndAddr = currentRead;
        }
    }
    if (context.checkpointSuccessID != null && context.checkpointSuccessID.equals(cpID)) {
        CheckpointEntry cpEntry = (CheckpointEntry) currentEntry.getPayload(runtime);
        log.trace("Checkpoint: address {} type {} id {} author {}", currentRead, cpEntry.getCpType(), cpEntry.getCheckpointID(), cpEntry.getCheckpointAuthorID());
        if (considerCheckpoint) {
            context.readCpQueue.add(currentEntry.getGlobalAddress());
            context.checkpointSuccessNumEntries++;
            context.checkpointSuccessBytes += cpEntry.getSmrEntriesBytes();
            if (cpEntry.getCpType().equals(CheckpointEntry.CheckpointEntryType.START)) {
                long cpStartAddr;
                if (cpEntry.getDict().get(CheckpointEntry.CheckpointDictKey.START_LOG_ADDRESS) != null) {
                    cpStartAddr = Long.decode(cpEntry.getDict().get(CheckpointEntry.CheckpointDictKey.START_LOG_ADDRESS));
                } else {
                    cpStartAddr = currentRead;
                }
                context.checkpointSuccessStartAddr = cpStartAddr;
                log.trace("Checkpoint: halt backpointer fill at address {} type {} id {} author {}", cpStartAddr, cpEntry.getCpType(), cpEntry.getCheckpointID(), cpEntry.getCheckpointAuthorID());
                return;
            }
        }
    } else {
        log.trace("Checkpoint: skip address {} type {} id {}", currentRead, cpType, cpID);
    }
}
Also used : CheckpointEntry(org.corfudb.protocols.logprotocol.CheckpointEntry)

Aggregations

CheckpointEntry (org.corfudb.protocols.logprotocol.CheckpointEntry)6 LocalDateTime (java.time.LocalDateTime)2 MultiSMREntry (org.corfudb.protocols.logprotocol.MultiSMREntry)2 SMREntry (org.corfudb.protocols.logprotocol.SMREntry)2 TokenResponse (org.corfudb.protocols.wireprotocol.TokenResponse)2 AbstractTransactionalContext (org.corfudb.runtime.object.transactions.AbstractTransactionalContext)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Iterators (com.google.common.collect.Iterators)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BiConsumer (java.util.function.BiConsumer)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Getter (lombok.Getter)1 Setter (lombok.Setter)1 ISMRConsumable (org.corfudb.protocols.logprotocol.ISMRConsumable)1 SMRMap (org.corfudb.runtime.collections.SMRMap)1 TransactionType (org.corfudb.runtime.object.transactions.TransactionType)1 TransactionalContext (org.corfudb.runtime.object.transactions.TransactionalContext)1