public class BookmarkRingBuffer
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
BookmarkRingBuffer.Entry
Represents a single entry in an array of bookmarks
|
Modifier and Type | Field and Description |
---|---|
static int |
UNSET_INDEX
Constant representing an unset index value.
|
Constructor and Description |
---|
BookmarkRingBuffer()
Initializes the underlying array, and sets
the "last discarded" value to something reasonable.
|
Modifier and Type | Method and Description |
---|---|
int |
capacity()
Size of underlying array.
|
void |
checkResize()
Called to check if resizing of the BookmarkRingBuffer is possible.
|
boolean |
discard(long index)
Discards an entry by index.
|
BookmarkRingBuffer.Entry |
find(BookmarkField field)
Finds an entry in the bookmark ring buffer with a specified bookmark field.
|
BookmarkRingBuffer.Entry |
getByIndex(long index)
Retrieves an Entry given an index.
|
long |
getEndIndex()
Returns the index value one greater than the last valid
Entry in self.
|
BookmarkField |
getLastDiscarded()
Returns the "last discarded" bookmark.
|
java.util.ArrayList<BookmarkRingBuffer.Entry> |
getRecoveryEntries()
Deprecated.
|
void |
getRecoveryEntries(java.util.ArrayList<BookmarkRingBuffer.Entry> entryList_)
Gets a list of recovery entries from the BookmarkRingBuffer.
|
long |
getStartIndex()
Returns the index value associated with the first valid
Entry in self.
|
boolean |
isEmpty()
Returns if the buffer is currently empty.
|
long |
log(BookmarkField bookmark)
Logs the bookmark by allocating an Entry, setting
the Entry to active, copying the bookmark value
to that entry, and returning the index
of that entry.
|
void |
persisted(BookmarkField bookmark)
Deprecated.
|
void |
persisted(long bookmark)
Deprecated.
|
long |
relog(long oldIndex,
BookmarkField bookmark)
Deprecated.
|
void |
reset()
Resets this bookmark ring buffer for reuse by clearing out its state.
|
long |
setRecovery()
Deprecated.
|
void |
setResizeHandler(BookmarkStoreResizeHandler handler,
BookmarkStore store)
Call this when you want to set a resize handler that is invoked when a store needs a resize.
|
void |
setSubId(Field sub)
Sets the Subscription Identifier for the bookmark.
|
java.lang.String |
toString()
Returns a debugging string representing ring buffer state.
|
public static final int UNSET_INDEX
public BookmarkRingBuffer()
public void reset()
public int capacity()
public BookmarkRingBuffer.Entry getByIndex(long index)
index
- An index returned by .getIndex(), getStartIndex(),
getEndIndex(), log, etc.public BookmarkField getLastDiscarded()
public boolean isEmpty()
public long getStartIndex()
public long getEndIndex()
public long log(BookmarkField bookmark)
bookmark
- The Bookmark to log.public boolean discard(long index)
index
- The index of the Entry to be discarded.public BookmarkRingBuffer.Entry find(BookmarkField field)
field
- The bookmark that you are searching for.@Deprecated public void persisted(BookmarkField bookmark)
bookmark
- The latest bookmark that can be safely disposed.@Deprecated public void persisted(long bookmark)
bookmark
- The bookmark containing the message.public void checkResize()
public void setResizeHandler(BookmarkStoreResizeHandler handler, BookmarkStore store)
handler
- The handler to invoke for the resize.store
- The store to be resized.public void setSubId(Field sub)
sub
- The Field object to copy as the new SubId.public void getRecoveryEntries(java.util.ArrayList<BookmarkRingBuffer.Entry> entryList_)
entryList_
- The list to fill with the recovery entries.@Deprecated public long setRecovery()
@Deprecated public java.util.ArrayList<BookmarkRingBuffer.Entry> getRecoveryEntries()
setRecovery()
@Deprecated public long relog(long oldIndex, BookmarkField bookmark)
oldIndex
- The index that the Entry was previously at.bookmark
- The index to move.public java.lang.String toString()
toString
in class java.lang.Object