T - The type of data written.public interface RevisionedStreamClient<T>
extends java.lang.AutoCloseable
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the client and frees any resources associated with it.
|
boolean |
compareAndSetMark(Revision expected,
Revision newLocation)
Records a provided location that can later be obtained by calling
getMark(). |
Revision |
fetchLatestRevision()
Returns the latest revision.
|
Revision |
fetchOldestRevision()
Returns the oldest revision that reads can start from.
|
Revision |
getMark()
Returns a location previously set by
compareAndSetMark(Revision, Revision). |
java.util.Iterator<java.util.Map.Entry<Revision,T>> |
readFrom(Revision start)
Read all data after a specified revision to the end of the stream.
|
void |
truncateToRevision(Revision revision)
Removes all data through the revision provided.
|
Revision |
writeConditionally(Revision latestRevision,
T value)
If the supplied revision is the latest revision in the stream write the provided value and return the new revision.
|
void |
writeUnconditionally(T value)
Write a new value to the stream.
|
Revision fetchOldestRevision()
Revision fetchLatestRevision()
java.util.Iterator<java.util.Map.Entry<Revision,T>> readFrom(Revision start) throws TruncatedDataException
start - The location the iterator should start at.TruncatedDataException - If the data at start no longer exists because it has been
truncated. IE: It is below fetchOldestRevision()Revision writeConditionally(Revision latestRevision, T value)
latestRevision - The version to verify is the most recent.value - The value to be written to the stream.void writeUnconditionally(T value)
value - The value to be written.Revision getMark()
compareAndSetMark(Revision, Revision).boolean compareAndSetMark(Revision expected, Revision newLocation)
getMark().
Atomically set the mark to newLocation if it is the expected value.expected - The expected value (May be null to indicate the mark is expected to be null)newLocation - The new valuevoid truncateToRevision(Revision revision)
fetchOldestRevision() to the provided revision. After this call returns if
readFrom(Revision) is called with an older revision it will throw.revision - The revision that should be the new oldest Revision.void close()
close in interface java.lang.AutoCloseableAutoCloseable.close()