use of org.corfudb.protocols.logprotocol.StreamCOWEntry in project CorfuDB by CorfuDB.
the class StreamsView method copy.
/**
* Make a copy-on-append copy of a stream.
*
* @param source The UUID of the stream to make a copy of.
* @param destination The UUID of the destination stream. It must not exist.
* @return A view
*/
public IStreamView copy(UUID source, UUID destination, long timestamp) {
boolean written = false;
while (!written) {
TokenResponse tokenResponse = runtime.getSequencerView().nextToken(Collections.singleton(destination), 1);
if (tokenResponse.getBackpointerMap().get(destination) != null && Address.isAddress(tokenResponse.getBackpointerMap().get(destination))) {
// Reading from this address will cause a hole fill
runtime.getAddressSpaceView().read(tokenResponse.getTokenValue());
throw new RuntimeException("Stream already exists!");
}
StreamCOWEntry entry = new StreamCOWEntry(source, timestamp);
TokenResponse cowToken = new TokenResponse(tokenResponse.getTokenValue(), tokenResponse.getEpoch(), Collections.singletonMap(destination, Address.COW_BACKPOINTER));
try {
runtime.getAddressSpaceView().write(cowToken, entry);
written = true;
} catch (OverwriteException oe) {
log.debug("hole fill during COW entry append, retrying...");
}
}
return get(destination);
}
use of org.corfudb.protocols.logprotocol.StreamCOWEntry in project CorfuDB by CorfuDB.
the class AbstractContextStreamView method processEntryForContext.
/** Check if the given entry adds a new context, and update
* the global pointer.
*
* If it does, add it to the context stack. Otherwise,
* pop the context.
*
* It is important that this method be called in order, since
* it updates the global pointer and can change the global pointer.
*
* @param data The entry to process.
* @return True, if this entry adds a context.
*/
protected boolean processEntryForContext(final ILogData data) {
if (data != null) {
final Object payload = data.getPayload(runtime);
// If this is a COW entry, we update the context as well.
if (payload instanceof StreamCOWEntry) {
StreamCOWEntry ce = (StreamCOWEntry) payload;
pushNewContext(ce.getOriginalStream(), ce.getFollowUntil());
return true;
}
}
return false;
}
Aggregations