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());
}
}
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);
});
}
Aggregations