Search in sources :

Example 1 with ISMRConsumable

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

the class StreamViewSMRAdapter method dataAndCheckpointMapper.

private List<SMREntry> dataAndCheckpointMapper(ILogData logData) {
    if (logData.hasCheckpointMetadata()) {
        // This is a CHECKPOINT record.  Extract the SMREntries, if any.
        CheckpointEntry cp = (CheckpointEntry) logData.getPayload(runtime);
        if (cp.getSmrEntries() != null && cp.getSmrEntries().getUpdates().size() > 0) {
            cp.getSmrEntries().getUpdates().forEach(e -> {
                e.setRuntime(runtime);
                e.setEntry(logData);
            });
            return cp.getSmrEntries().getUpdates();
        } else {
            return (List<SMREntry>) Collections.EMPTY_LIST;
        }
    } else {
        return ((ISMRConsumable) logData.getPayload(runtime)).getSMRUpdates(streamView.getID());
    }
}
Also used : CheckpointEntry(org.corfudb.protocols.logprotocol.CheckpointEntry) ISMRConsumable(org.corfudb.protocols.logprotocol.ISMRConsumable) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ISMRConsumable

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

the class OptimisticTransactionalContext method tryCommitAllProxies.

/** Try to commit the optimistic updates to each proxy. */
protected void tryCommitAllProxies() {
    // First, get the committed entry
    // in order to get the backpointers
    // and the underlying SMREntries.
    ILogData committedEntry = this.builder.getRuntime().getAddressSpaceView().read(commitAddress);
    updateAllProxies(x -> {
        log.trace("Commit[{}] Committing {}", this, x);
        x.getUnderlyingObject().optimisticCommitUnsafe();
        x.getUnderlyingObject().syncObjectUnsafe(commitAddress - 1);
        List<SMREntry> committedWrites = getWriteSetEntryList(x.getStreamID());
        List<SMREntry> entryWrites = ((ISMRConsumable) committedEntry.getPayload(this.getBuilder().runtime)).getSMRUpdates(x.getStreamID());
        if (committedWrites.size() == entryWrites.size()) {
            IntStream.range(0, committedWrites.size()).forEach(i -> {
                if (committedWrites.get(i).isUndoable()) {
                    entryWrites.get(i).setUndoRecord(committedWrites.get(i).getUndoRecord());
                }
            });
        }
        x.getUnderlyingObject().seek(commitAddress + 1);
        log.trace("Commit[{}] Committed {}", this, x);
    });
}
Also used : ILogData(org.corfudb.protocols.wireprotocol.ILogData) ISMRConsumable(org.corfudb.protocols.logprotocol.ISMRConsumable) SMREntry(org.corfudb.protocols.logprotocol.SMREntry)

Aggregations

ISMRConsumable (org.corfudb.protocols.logprotocol.ISMRConsumable)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CheckpointEntry (org.corfudb.protocols.logprotocol.CheckpointEntry)1 SMREntry (org.corfudb.protocols.logprotocol.SMREntry)1 ILogData (org.corfudb.protocols.wireprotocol.ILogData)1