public class ThreadSafeStreamView extends Object implements IStreamView
IStreamView.SearchDirection
Constructor and Description |
---|
ThreadSafeStreamView(CorfuRuntime runtime,
UUID streamId) |
ThreadSafeStreamView(CorfuRuntime runtime,
UUID streamId,
StreamOptions options) |
Modifier and Type | Method and Description |
---|---|
long |
append(Object object,
Function<TokenResponse,Boolean> acquisitionCallback,
Function<TokenResponse,Boolean> deacquisitionCallback)
Append an object to the stream, returning the global address
it was written at.
|
ILogData |
current()
Retrieve the current entry in the stream, which was the entry previously
returned by a call to next() or previous().
|
long |
find(long globalAddress,
IStreamView.SearchDirection direction)
Find the global address of the next entry in this stream,
in the direction given.
|
void |
gc(long trimMark)
Garbage collect all the trimmed entries on this stream
|
long |
getCurrentGlobalPosition()
Get the current position of the pointer in this stream (global address).
|
UUID |
getId()
Return the ID of the stream this view is for.
|
long |
getTotalUpdates()
Get total number of updates registered to this stream.
|
boolean |
hasNext()
Returns whether or not there are potentially more entries in this
stream - this function may return true even if there are no entries
remaining, as addresses may have been acquired by other clients
but not written yet, or the addresses were hole-filled, or just failed.
|
ILogData |
next()
Retrieve the next entry from this stream, up to the tail of the stream
If there are no entries present, this function will return NULL.
|
ILogData |
nextUpTo(long maxGlobal)
Retrieve the next entry from this stream, up to the address given or the
tail of the stream.
|
ILogData |
previous()
Retrieve the previous entry in the stream.
|
List<ILogData> |
remainingUpTo(long maxGlobal)
Retrieve all of the entries from this stream, up to the address given or
the tail of the stream.
|
void |
reset()
Reset the state of this stream view, causing the next read to
start from the beginning of this stream.
|
void |
seek(long globalAddress)
Seek to the requested maxGlobal address.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
append, remaining, spliterator, spliteratorUpTo, stream, streamUpTo
forEachRemaining, remove
public ThreadSafeStreamView(CorfuRuntime runtime, UUID streamId, @Nonnull StreamOptions options)
public ThreadSafeStreamView(CorfuRuntime runtime, UUID streamId)
public UUID getId()
IStreamView
getId
in interface IStreamView
public void reset()
IStreamView
reset
in interface IStreamView
public void gc(long trimMark)
IStreamView
gc
in interface IStreamView
trimMark
- start of the active logpublic void seek(long globalAddress)
IStreamView
seek
in interface IStreamView
globalAddress
- Address to seek topublic long find(long globalAddress, IStreamView.SearchDirection direction)
IStreamView
find
in interface IStreamView
globalAddress
- The global address to start searching from.direction
- The direction to search.public long append(Object object, Function<TokenResponse,Boolean> acquisitionCallback, Function<TokenResponse,Boolean> deacquisitionCallback)
IStreamView
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 IStreamView
object
- The object 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 ILogData next()
IStreamView
next
in interface Iterator<ILogData>
next
in interface IStreamView
public ILogData previous()
IStreamView
previous
in interface IStreamView
public ILogData current()
IStreamView
current
in interface IStreamView
public ILogData nextUpTo(long maxGlobal)
IStreamView
nextUpTo
in interface IStreamView
maxGlobal
- The maximum global address to read up to.public List<ILogData> remainingUpTo(long maxGlobal)
IStreamView
remainingUpTo
in interface IStreamView
maxGlobal
- The maximum global address to read up to.public boolean hasNext()
IStreamView
hasNext
in interface Iterator<ILogData>
hasNext
in interface IStreamView
public long getCurrentGlobalPosition()
IStreamView
getCurrentGlobalPosition
in interface IStreamView
public long getTotalUpdates()
IStreamView
getTotalUpdates
in interface IStreamView
Copyright © 2019 CorfuDB. All rights reserved.