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 boolean |
_errorOnPublishGap |
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 constructor for BlockPublishStore.
|
protected |
BlockPublishStore(BlockPublishStore.Buffer buffer,
int blocksPerRealloc)
Protected constructor for BlockPublishStore.
|
protected |
BlockPublishStore(BlockPublishStore.Buffer buffer,
int blocksPerRealloc,
boolean isAFile)
Protected constructor for BlockPublishStore.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the BlockPublishStore.
|
void |
discardUpTo(long index)
This method is responsible for managing the discarding of blocks in a store
based on the specified index.
|
void |
flush()
Flushes the publish store.
|
void |
flush(long timeout)
Flushes the publish store, waiting until all messages in the store are
flushed or until a timeout occurs.
|
boolean |
getErrorOnPublishGap()
Get whether the Store will throw a PublishGapException from discardUpTo if the
sequence number being discarded is less then the current last persisted.
|
long |
getHighestUnpersisted()
Gets the highest unpersisted sequence number.
|
long |
getLastPersisted()
Gets the last persisted sequence number.
|
long |
getLowestUnpersisted()
Gets the lowest unpersisted sequence number.
|
protected void |
growFreeListIfEmpty()
Ensures that the free list is not empty by potentially growing it.
|
protected void |
recover()
Recovers the store's state during initialization.
|
void |
replay(Store.StoreReplayer replayer)
Replays stored messages onto a store replayer.
|
boolean |
replaySingle(Store.StoreReplayer replayer,
long index)
Replays a single message from the store, given a specific sequence index,
onto a store replayer.
|
void |
setErrorOnPublishGap(boolean errorOnGap)
Set whether the Store should throw a PublishGapException from discardUpTo if the
sequence number being discarded is less then the current last persisted.
|
void |
setMessage(Message m)
Sets the message to be stored.
|
void |
setResizeHandler(PublishStoreResizeHandler handler)
Sets a resize handler for the publish store.
|
void |
store(Message m)
Stores a message in the BlockPublishStore.
|
protected void |
store(Message m,
boolean assignSequence)
Protected utility method for storing messages in the BlockPublishStore.
|
long |
unpersistedCount()
Returns the count of unpersisted messages in the store.
|
protected PublishStoreResizeHandler _resizeHandler
protected BlockPublishStore.Buffer _buffer
protected boolean _errorOnPublishGap
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)
buffer - An instance of the Buffer interface representing the
data buffer.blocksPerRealloc - An integer representing the number of blocks per
reallocation.isAFile - A boolean indicating whether this store represents a
file.protected BlockPublishStore(BlockPublishStore.Buffer buffer, int blocksPerRealloc)
buffer - An instance of the Buffer interface representing the
data buffer.blocksPerRealloc - An integer representing the number of blocks per
reallocation.protected BlockPublishStore(BlockPublishStore.Buffer buffer)
buffer - An instance of the Buffer interface representing the data
buffer.public void store(Message m) throws StoreException
store in interface Storem - The message to be stored.StoreException - If an error occurs during message storage.public void close()
throws java.lang.Exception
close in interface java.lang.AutoCloseablejava.lang.Exception - If an error occurs during the closing operation.protected void store(Message m, boolean assignSequence) throws StoreException
m - The message to be stored.assignSequence - A boolean flag indicating whether to assign a sequence
number to the message.StoreException - If an error occurs during message storage.public void discardUpTo(long index)
throws StoreException
discardUpTo in interface Storeindex - 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
getLastPersisted in interface StoreStoreException - If an error occurs while retrieving the last persisted
sequence number.public long getLowestUnpersisted()
getLowestUnpersisted in interface Storepublic long getHighestUnpersisted()
public void setMessage(Message m)
setMessage in interface Storem - The message to be stored.public boolean getErrorOnPublishGap()
getErrorOnPublishGap in interface Storepublic void setErrorOnPublishGap(boolean errorOnGap)
setErrorOnPublishGap in interface StoreerrorOnGap - If true, an exception will be thrown during logon if a gap could be
created. If false, allow the logon to proceed.public void replay(Store.StoreReplayer replayer) throws StoreException, DisconnectedException
replay in interface Storereplayer - The replayer to play messages on.StoreException - If an exception occurs during replay, the
method will throw a StoreException, and all
following blocks will be ignored.DisconnectedException - If a disconnection occurs during replay.public boolean replaySingle(Store.StoreReplayer replayer, long index) throws StoreException, DisconnectedException
replaySingle in interface Storereplayer - The replayer to play the message on.index - The sequence index of the message to replay.StoreException - If an exception occurs during replay, the
method will throw a StoreException.DisconnectedException - If a disconnection occurs during replay.public long unpersistedCount()
unpersistedCount in interface Storeprotected void recover()
throws StoreException
StoreException - If an error occurs during store recovery.protected void growFreeListIfEmpty()
throws StoreException
StoreException - If an error occurs during the process of growing the
free list.public void flush()
throws TimedOutException
flush in interface StoreTimedOutException - If the flush operation times out before all
messages are flushed.public void flush(long timeout)
throws TimedOutException
flush in interface Storetimeout - The maximum time to wait for the flush operation, in
milliseconds.TimedOutException - If the flush operation times out before all
messages are flushed.public void setResizeHandler(PublishStoreResizeHandler handler)
setResizeHandler in interface Storehandler - The resize handler to set.