public class InMemoryTokenStore extends Object implements TokenStore
TokenStore that stores tracking tokens in memory. This implementation is thread-safe.| Constructor and Description |
|---|
InMemoryTokenStore() |
| Modifier and Type | Method and Description |
|---|---|
TrackingToken |
fetchToken(String processorName,
int segment)
|
void |
releaseClaim(String processorName,
int segment)
Release a claim of the token for given
processorName and segment. |
void |
storeToken(TrackingToken token,
String processorName,
int segment)
Stores the given
token in the store. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitextendClaimpublic void storeToken(TrackingToken token, String processorName, int segment)
TokenStoretoken in the store. The token marks the current position of the process with given
processorName and segment. The given token may be null.
Any claims made by the current process have their timestamp updated.storeToken in interface TokenStoretoken - The token to store for a given process and segment. May be null.processorName - The name of the process for which to store the tokensegment - The index of the segment for which to store the tokenpublic TrackingToken fetchToken(String processorName, int segment)
TokenStoretoken for the given processorName and segment.
Returns null if the store holds no token or if the stored token for the given process and segment is
null.
The token will be claimed by the current process (JVM instance), preventing access by other instances. To release
the claim, use TokenStore.releaseClaim(String, int)fetchToken in interface TokenStoreprocessorName - The process name for which to fetch the tokensegment - The segment index for which to fetch the tokennull if the store holds no token for given process and segmentpublic void releaseClaim(String processorName, int segment)
TokenStoreprocessorName and segment. If no such claim existed,
nothing happens.
The caller must ensure not to use any streams opened based on the token for which the claim is released.
releaseClaim in interface TokenStoreprocessorName - The name of the process owning the token (e.g. a TrackingEventProcessor name)segment - the segment for which a token was obtainedCopyright © 2010–2017. All rights reserved.