@Deprecated public class WriteSetSMRStream extends Object implements ISMRStream
SMRStreamAdapter wraps an optimistic transaction execution context, per object, with an SMRStream API.
The main purpose of wrapping the write-set of optimistic transactions as an SMRStream is to provide the abstraction of a stream of SMREntries. The SMRStream maintains for us a position in the sequence. We can consume it in a forward direction, and scroll back to previously read entries.
First, forget about nested transactions for now, and neglect the contexts stack; that is, assume the stack has size 1.
A reminder from AbstractTransactionalContext about the write-set of a transaction: * A write-set is a key component of a transaction. * We collect the write-set as a map, organized by streams. * For each stream, we record a pair: * - a set of conflict-parameters modified by this transaction on the * stream, * - a list of SMR updates by this transaction on the stream. *
The implementation of the current() method looks at the write-set, picks the list of SMRentries corresponding to the current object id, and returns the entry in the list corresponding the the current SMRStream position.
previous() decrements the current SMRStream position and returns the entry corresponding to it.
RemainingUpTo() returns a list of entries.
WriteSetSMRStream does not support the full API - neither append nor seek are supported.
Enter nested transactions.
WriteSetSMRStream maintains the abstractions also across nested transactions. It supports navigating forward/backward across the SMREntries in the entire transaction stack.
Constructor and Description |
---|
WriteSetSMRStream(List<AbstractTransactionalContext> contexts,
UUID id)
Deprecated.
Returns a new WriteSetSMRStream containing transactional contexts and stream id.
|
Modifier and Type | Method and Description |
---|---|
long |
append(SMREntry entry,
Function<TokenResponse,Boolean> acquisitionCallback,
Function<TokenResponse,Boolean> deacquisitionCallback)
Deprecated.
Append a SMREntry to the stream, returning the global address
it was written at.
|
List<SMREntry> |
current()
Deprecated.
|
void |
gc(long trimMark)
Deprecated.
|
UUID |
getID()
Deprecated.
Get the UUID for this stream (optional operation).
|
boolean |
isStreamCurrentContextThreadCurrentContext()
Deprecated.
Return whether stream current transaction is the thread current transaction.
|
boolean |
isStreamForThisThread()
Deprecated.
Return whether we are the stream for this current thread
|
long |
pos()
Deprecated.
|
List<SMREntry> |
previous()
Deprecated.
|
List<SMREntry> |
remainingUpTo(long maxGlobal)
Deprecated.
|
void |
reset()
Deprecated.
|
void |
seek(long globalAddress)
Deprecated.
|
Stream<SMREntry> |
stream()
Deprecated.
|
Stream<SMREntry> |
streamUpTo(long maxGlobal)
Deprecated.
|
String |
toString()
Deprecated.
|
public WriteSetSMRStream(List<AbstractTransactionalContext> contexts, UUID id)
contexts
- list of transactional contextsid
- stream idpublic boolean isStreamCurrentContextThreadCurrentContext()
This is validated by checking whether the current context for this stream is the same as the current context for this thread.
public boolean isStreamForThisThread()
This is validated by checking whether the root context for this stream is the same as the root context for this thread.
public void gc(long trimMark)
gc
in interface ISMRStream
public List<SMREntry> remainingUpTo(long maxGlobal)
remainingUpTo
in interface ISMRStream
public List<SMREntry> current()
current
in interface ISMRStream
public List<SMREntry> previous()
previous
in interface ISMRStream
public long pos()
pos
in interface ISMRStream
public void reset()
reset
in interface ISMRStream
public void seek(long globalAddress)
seek
in interface ISMRStream
public Stream<SMREntry> stream()
stream
in interface ISMRStream
public Stream<SMREntry> streamUpTo(long maxGlobal)
streamUpTo
in interface ISMRStream
public long append(SMREntry entry, Function<TokenResponse,Boolean> acquisitionCallback, Function<TokenResponse,Boolean> deacquisitionCallback)
ISMRStream
Optionally, provide a method to be called when an address is acquired, and also a method to be called when an address is released (due to an unsuccessful append).
append
in interface ISMRStream
entry
- The SMR entry to append.acquisitionCallback
- A function to call when an address is
acquired.
It should return true to continue with the
append.deacquisitionCallback
- A function to call when an address is
released. It should return true to retry
writing.public UUID getID()
ISMRStream
getID
in interface ISMRStream
Copyright © 2019 CorfuDB. All rights reserved.