public class LoggedBookmarkStore extends java.lang.Object implements BookmarkStore
prune()
to manage the size of the file by removing
outdated entries.Modifier and Type | Class and Description |
---|---|
protected static class |
LoggedBookmarkStore.Subscription
The Subscription object is used to represent internal bookmark state
for the messages received and discarded on a specific subscription
within the bookmark store.
|
Constructor and Description |
---|
LoggedBookmarkStore(java.lang.String path)
Same as calling LoggedBookmarkStore(path, 1, false).
|
LoggedBookmarkStore(java.lang.String path,
int targetNumberOfSubscriptions)
Same as calling LoggedBookmarkStore(path, targetNumberOfSubscriptions, false).
|
LoggedBookmarkStore(java.lang.String path,
int targetNumberOfSubscriptions,
boolean useLastModifiedTime)
A file-backed bookmark store implementation that fully supports
discarding messages in an order different from the order they arrived
(i.e.
|
LoggedBookmarkStore(java.lang.String path,
int targetNumberOfSubscriptions,
boolean useLastModifiedTime,
RecoveryPointAdapter adapter)
A file-backed bookmark store implementation that fully supports
discarding messages in an order different from the order they arrived
(i.e.
|
LoggedBookmarkStore(java.lang.String path,
int targetNumberOfSubscriptions,
boolean useLastModifiedTime,
RecoveryPointAdapter adapter,
RecoveryPointFactory factory)
A file-backed bookmark store implementation that fully supports
discarding messages in an order different from the order they arrived
(i.e.
|
Modifier and Type | Method and Description |
---|---|
void |
_purge() |
void |
_purge(Field subId_) |
protected void |
adapterUpdate(Field subId,
BookmarkField bookmark)
Used inernally to update the RecoveryPointAdapter if there is one.
|
void |
close()
Closes the bookmark store.
|
void |
discard(Field subId,
long bookmarkSeqNo)
Call this when you want to mark the message specified by the
subscription ID and the bookmark sequence number as discarded,
indicating that the application has completed processing the message.
|
void |
discard(Message message)
Call this when you want to mark the provided message as discarded,
indicating that the application has completed processing the message.
|
protected LoggedBookmarkStore.Subscription |
find(Field subId)
Finds and returns the Subscription object for the specified
subscription id (subId).
|
Field |
getMostRecent(Field subId)
Call this when you want to return the correct recovery point for
resubscription of the provided subID from the BookmarkStore.
|
Field |
getMostRecent(Field subId,
boolean useList)
Call this when you want to return the correct recovery point for
resubscription of the provided subID from the BookmarkStore.
|
long |
getOldestBookmarkSeq(Field subId)
Call this when you want to retrieve the sequence number of the oldest bookmark in the store.
|
int |
getServerVersion()
Called by Client when connected to an AMPS server in order to retrieve
the version number of the server.
|
boolean |
isDiscarded(Message message)
Called for each arriving message to determine if
the application has already processed and discarded this message.
|
long |
log(Message message)
Called internally by the Client to log a bookmark to the persistent log.
|
void |
persisted(Field subId,
BookmarkField bookmark)
Called internally by the Client to record the last persisted message in the transaction log of the connected AMPS server
to all of its sync replication destinations.
|
void |
persisted(Field subId,
long bookmark)
Deprecated.
use
persisted(Field, BookmarkField) instead. |
void |
prune()
Remove outdated entries in the bookmark store.
|
void |
prune(java.lang.String tmpFileName_)
Remove outdated entries in the bookmark store.
|
void |
purge()
Remove all entries in the bookmark store, completely
clearing all record of messages received and discarded.
|
void |
purge(Field subId_)
Remove all entries in the bookmark store for a subId.
|
void |
setRecoveryPointFactory(RecoveryPointFactory factory_)
Change the RecoveryPointFactory used by this store for its adapter.
|
void |
setResizeHandler(BookmarkStoreResizeHandler handler)
Called this when you want to set a resize handler that is invoked when the store needs to resize.
|
void |
setServerVersion(int version)
Used to change the version of the AMPS server that this bookmark store's
client has connected to.
|
public LoggedBookmarkStore(java.lang.String path) throws java.io.IOException
path
- The path to the backing bookmark log file.java.io.IOException
- If there is a problem creating, reading, or writing
the backing file.LoggedBookmarkStore(String, int, boolean)
public LoggedBookmarkStore(java.lang.String path, int targetNumberOfSubscriptions) throws java.io.IOException
path
- The path to the backing bookmark log file.targetNumberOfSubscriptions
- The initial capacity for the numberjava.io.IOException
- If there is a problem creating, reading, or writing
the backing file.LoggedBookmarkStore(String, int, boolean)
public LoggedBookmarkStore(java.lang.String path, int targetNumberOfSubscriptions, boolean useLastModifiedTime) throws java.io.IOException
path
- The path to the backing bookmark log file.targetNumberOfSubscriptions
- The initial capacity for the number
of bookmark subscriptions you anticipate creating on the AMPS
client instance that this bookmark store is registered on. This
will grow as needed if more subscriptions are created than
anticipated.useLastModifiedTime
- Indicates whether the recovery timestamp
feature should be used. If true, the last-modified time of the
backing file is included (as an AMPS timestamp bookmark in a
comma-separated list of bookmarks) when getMostRecent() is called
after recovering from a bookmark file. This feature could be
useful if you have an infrequently run process that is run on a
schedule that is longer than the AMPS server keeps messages in
its transaction log. When this process is started and recovers
a bookmark log full of old bookmarks that are no longer available
using the MOST_RECENT bookmark indicator, the recovery timestamp
will cause the bookmark subscription to begin at the start of the
transaction log (e.g. EPOCH), rather than its tail (e.g. NOW).java.io.IOException
- If there is a problem creating, reading, or writing
the backing file.public LoggedBookmarkStore(java.lang.String path, int targetNumberOfSubscriptions, boolean useLastModifiedTime, RecoveryPointAdapter adapter) throws java.io.IOException
path
- The path to the backing bookmark log file.targetNumberOfSubscriptions
- The initial capacity for the number
of bookmark subscriptions you anticipate creating on the AMPS
client instance that this bookmark store is registered on. This
will grow as needed if more subscriptions are created than
anticipated.useLastModifiedTime
- Indicates whether the recovery timestamp
feature should be used. If true, the last-modified time of the
backing file is included (as an AMPS timestamp bookmark in a
comma-separated list of bookmarks) when getMostRecent() is called
after recovering from a bookmark file. This feature could be
useful if you have an infrequently run process that is run on a
schedule that is longer than the AMPS server keeps messages in
its transaction log. When this process is started and recovers
a bookmark log full of old bookmarks that are no longer available
using the MOST_RECENT bookmark indicator, the recovery timestamp
will cause the bookmark subscription to begin at the start of the
transaction log (e.g. EPOCH), rather than its tail (e.g. NOW).adapter
- The RecoveryPointAdapter backing up the store. The
adapter will be sent FixedRecoveryPoints.java.io.IOException
- If there is a problem creating, reading, or writing
the backing file.public LoggedBookmarkStore(java.lang.String path, int targetNumberOfSubscriptions, boolean useLastModifiedTime, RecoveryPointAdapter adapter, RecoveryPointFactory factory) throws java.io.IOException
path
- The path to the backing bookmark log file.targetNumberOfSubscriptions
- The initial capacity for the number
of bookmark subscriptions you anticipate creating on the AMPS
client instance that this bookmark store is registered on. This
will grow as needed if more subscriptions are created than
anticipated.useLastModifiedTime
- Indicates whether the recovery timestamp
feature should be used. If true, the last-modified time of the
backing file is included (as an AMPS timestamp bookmark in a
comma-separated list of bookmarks) when getMostRecent() is called
after recovering from a bookmark file. This feature could be
useful if you have an infrequently run process that is run on a
schedule that is longer than the AMPS server keeps messages in
its transaction log. When this process is started and recovers
a bookmark log full of old bookmarks that are no longer available
using the MOST_RECENT bookmark indicator, the recovery timestamp
will cause the bookmark subscription to begin at the start of the
transaction log (e.g. EPOCH), rather than its tail (e.g. NOW).adapter
- The RecoveryPointAdapter backing up the store.factory
- The RecoveryPointFactory used to craete RecoveryPoints
that are sent to the adapter.java.io.IOException
- If there is a problem creating, reading, or writing
the backing file.public void prune() throws java.io.IOException, StoreException
java.io.IOException
- Thrown when an operation on the file fails.StoreException
- Thrown when any other operation fails with details on the failure.public void prune(java.lang.String tmpFileName_) throws java.io.IOException, StoreException
tmpFileName_
- The name of the temporary file.java.io.IOException
- Thrown when an operation on the file fails.StoreException
- Thrown when any other operation fails with details on the failure.public long log(Message message) throws AMPSException
BookmarkStore
log
in interface BookmarkStore
message
- The message containing the bookmark to log.AMPSException
- Thrown when the message cannot be logged.public void discard(Field subId, long bookmarkSeqNo) throws AMPSException
BookmarkStore
discard
in interface BookmarkStore
subId
- The subscription ID of the bookmark.bookmarkSeqNo
- The bookmark sequence number.AMPSException
- Thrown when the specified bookmark cannot be discareded.public void discard(Message message) throws AMPSException
BookmarkStore
discard
in interface BookmarkStore
message
- Message to be marked as discarded.AMPSException
- Thrown when the specified message cannot be discareded.public Field getMostRecent(Field subId) throws AMPSException
BookmarkStore
getMostRecent
in interface BookmarkStore
subId
- The subscription ID of the most recent bookmark.AMPSException
- Thrown when the store cannot produce a recovery point for the specified subID.public Field getMostRecent(Field subId, boolean useList) throws AMPSException
BookmarkStore
getMostRecent
in interface BookmarkStore
subId
- The subscription ID of the most recent bookmark.useList
- In the case where the store has not received any persisted
acks, it will build a list of bookmarks based on the last discarded for
each publisher if true (default).AMPSException
- Thrown when the store cannot produce a recovery point for the specified subID.public boolean isDiscarded(Message message) throws AMPSException
BookmarkStore
isDiscarded
in interface BookmarkStore
message
- Message used to determine if the application has already
processed and discarded the message.AMPSException
- Thrown when the store cannot determine if the message is discarded.@Deprecated public void persisted(Field subId, long bookmark) throws AMPSException
persisted(Field, BookmarkField)
instead.persisted
in interface BookmarkStore
subId
- The subscription ID for the message.bookmark
- The bookmark sequence number.AMPSException
- Thrown if the store is unable to record information in the store.public void persisted(Field subId, BookmarkField bookmark) throws AMPSException
BookmarkStore
persisted
in interface BookmarkStore
subId
- The subscription ID for the message.bookmark
- The bookmark containing the message.AMPSException
- Thrown if the store is unable to record information in the store.public long getOldestBookmarkSeq(Field subId) throws AMPSException
BookmarkStore
getOldestBookmarkSeq
in interface BookmarkStore
subId
- The subscription ID for the oldest bookmark in the store.AMPSException
- The operation could not successfully be completed.public void setResizeHandler(BookmarkStoreResizeHandler handler)
BookmarkStore
setResizeHandler
in interface BookmarkStore
handler
- The handler to invoke for the resize.protected LoggedBookmarkStore.Subscription find(Field subId) throws java.io.IOException
subId
- The subId to find or create a Subscription for.java.io.IOException
- For legacy reasons.public void purge() throws AMPSException
purge
in interface BookmarkStore
AMPSException
- Thrown if the store is unable to remove the contents.public void _purge() throws AMPSException
AMPSException
public void purge(Field subId_) throws AMPSException
purge
in interface BookmarkStore
subId_
- The subId to remove from the store.AMPSException
- Thrown if the store is unable to remove information for the subscription.public void _purge(Field subId_) throws AMPSException
AMPSException
public void setRecoveryPointFactory(RecoveryPointFactory factory_) throws AMPSException
factory_
- The new RecoveryPointFactoryAMPSException
- If one of factory or adapter is null.public void close() throws AMPSException
close
in interface java.lang.AutoCloseable
StoreException
- if there is an error closing the file backing in the store,
or the store already closed.AMPSException
public void setServerVersion(int version)
setServerVersion
in interface BookmarkStore
version
- An AMPS server version integer of the form 03080000 for
version 3.8.0.0.public int getServerVersion()
protected void adapterUpdate(Field subId, BookmarkField bookmark) throws java.io.IOException
subId
- The subId to update.bookmark
- The latest bookmark.java.io.IOException
- If there is an exception from the adapter.