public class BlockPublishStore extends java.lang.Object implements Store
Store
implementations. As messages are stored,
space is allocated from a pre-created flat buffer. As messages are discarded, space in that buffer
is marked "free" for future store operations. If messages are stored faster than they are published, the buffer
is re-sized to create more capacity.Modifier and Type | Class and Description |
---|---|
static interface |
BlockPublishStore.Buffer
Interface which is used to hold the BlockPublishStore
buffer data.
|
static class |
BlockPublishStore.ByteSequence
A simple wrapper object around a byte array that allows a sub-range to be specified using its offset and length
properties.
|
Store.StoreReplayer
Modifier and Type | Field and Description |
---|---|
protected BlockPublishStore.Buffer |
_buffer |
protected PublishStoreResizeHandler |
_resizeHandler |
protected static int |
AMPS_MIN_PUB_STORE_DISCARDED_VERSION |
protected static int |
METADATA_LAST_DISCARDED_LOCATION |
protected static int |
METADATA_VERSION_LOCATION |
SOWDeleteByBookmark, SOWDeleteByBookmarkCancel, SOWDeleteByData, SOWDeleteByFilter, SOWDeleteByKeys
Modifier | Constructor and Description |
---|---|
protected |
BlockPublishStore(BlockPublishStore.Buffer buffer) |
protected |
BlockPublishStore(BlockPublishStore.Buffer buffer,
int blocksPerRealloc) |
protected |
BlockPublishStore(BlockPublishStore.Buffer buffer,
int blocksPerRealloc,
boolean isAFile) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
discardUpTo(long index)
Discard all operations up to the index provided.
|
void |
flush()
Wait for the store to discard everything that has been stored
up to the point in time when flush is called, then
return.
|
void |
flush(long timeout)
Wait for the store to discard everything that has been stored
up to the point in time when flush is called, then
return.
|
long |
getHighestUnpersisted() |
long |
getLastPersisted()
Return the last persisted index in the store.
|
long |
getLowestUnpersisted()
Return the oldest index in the store.
|
protected void |
growFreeListIfEmpty() |
protected void |
recover() |
void |
replay(Store.StoreReplayer replayer)
Replay all operations in the store using the provided StoreReplayer.
|
boolean |
replaySingle(Store.StoreReplayer replayer,
long index)
Replay the operation at the specified index.
|
void |
setMessage(Message m)
Provide the Store with a preallocated Message for use in replay.
|
void |
setResizeHandler(PublishStoreResizeHandler handler)
Set the resize handler for the publish store.
|
void |
store(Message m)
Store the provided message.
|
protected void |
store(Message m,
boolean assignSequence) |
long |
unpersistedCount()
Return the number of operations in the store.
|
protected PublishStoreResizeHandler _resizeHandler
protected BlockPublishStore.Buffer _buffer
protected static final int AMPS_MIN_PUB_STORE_DISCARDED_VERSION
protected static final int METADATA_VERSION_LOCATION
protected static final int METADATA_LAST_DISCARDED_LOCATION
protected BlockPublishStore(BlockPublishStore.Buffer buffer, int blocksPerRealloc, boolean isAFile)
protected BlockPublishStore(BlockPublishStore.Buffer buffer, int blocksPerRealloc)
protected BlockPublishStore(BlockPublishStore.Buffer buffer)
public void store(Message m) throws StoreException
Store
store
in interface Store
m
- the message to storeStoreException
- Thrown if the Store is unable to store the message.public void close() throws java.lang.Exception
close
in interface java.lang.AutoCloseable
java.lang.Exception
protected void store(Message m, boolean assignSequence) throws StoreException
StoreException
public void discardUpTo(long index) throws StoreException
Store
discardUpTo
in interface Store
index
- the index number to keep -- all previous index numbers will be discardedStoreException
- Thrown if the Store is unable to discard the messages.public long getLastPersisted() throws StoreException
Store
getLastPersisted
in interface Store
StoreException
- Thrown if the store is unable to produce the last persisted index.public long getLowestUnpersisted()
Store
getLowestUnpersisted
in interface Store
public long getHighestUnpersisted()
public void setMessage(Message m)
Store
setMessage
in interface Store
m
- The message object for the Store to use during replay.public void replay(Store.StoreReplayer replayer) throws StoreException, DisconnectedException
Store
replay
in interface Store
replayer
- the StoreReplayer to use to replay the operationsStoreException
- Thrown if the Store is unable to replay the operations.DisconnectedException
- Thrown if the Store receives a DisconnectedException while replaying.public boolean replaySingle(Store.StoreReplayer replayer, long index) throws StoreException, DisconnectedException
Store
replaySingle
in interface Store
replayer
- the StoreReplayer to use to replay the operationsindex
- The index of the message to replay within the storeStoreException
- Thrown if the Store is unable to replay the operations.DisconnectedException
- Thrown if the Store receives a DisconnectedException while replaying.public long unpersistedCount()
Store
unpersistedCount
in interface Store
protected void recover() throws StoreException
StoreException
protected void growFreeListIfEmpty() throws StoreException
StoreException
public void flush() throws TimedOutException
Store
flush
in interface Store
TimedOutException
- Not thrown from this overload.public void flush(long timeout) throws TimedOutException
Store
flush
in interface Store
timeout
- the number of milliseconds to wait for the flushTimedOutException
- Thrown if the timeout period passes without the messages being discarded.public void setResizeHandler(PublishStoreResizeHandler handler)
Store
setResizeHandler
in interface Store
handler
- The handler to install.