public class ConsistentKeyIDAuthority extends AbstractIDAuthority implements BackendOperation.TransactionalProvider
IDAuthority implementation
assuming that the backing store supports consistent key operations.
ID blocks are allocated by first applying for an id block, waiting for a
specified period of time and then checking that the application was the first
received for that particular id block. If so, the application is considered
successful. If not, some other process won the application and a new
application is tried.
The partition id is used as the key and since key operations are considered
consistent, this protocol guarantees unique id block assignments.
| Modifier and Type | Field and Description |
|---|---|
protected int |
randomUniqueIDLimit |
BASE_ID, idApplicationWaitMS, metricsPrefix, uid, uidBytes| Constructor and Description |
|---|
ConsistentKeyIDAuthority(KeyColumnValueStore idStore,
StoreManager manager,
Configuration config) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the IDAuthority and any underlying storage backend.
|
IDBlock |
getIDBlock(int partition,
int idNamespace,
java.time.Duration timeout)
Returns a block of new ids in the form of
IDBlock. |
List<KeyRange> |
getLocalIDPartition()
Returns the lower and upper limits of the key range assigned to this local machine as an array with two entries.
|
StoreTransaction |
openTx() |
boolean |
supportsInterruption()
Whether
IDAuthority.getIDBlock(int, int, Duration) may be safely interrupted. |
getBlockSize, getIdUpperBound, getPartitionKey, getUniqueID, setIDBlockSizerpublic ConsistentKeyIDAuthority(KeyColumnValueStore idStore, StoreManager manager, Configuration config) throws BackendException
BackendExceptionpublic List<KeyRange> getLocalIDPartition() throws BackendException
IDAuthoritygetLocalIDPartition in interface IDAuthorityBackendExceptionpublic void close()
throws BackendException
IDAuthorityclose in interface IDAuthorityclose in interface BackendOperation.TransactionalProviderBackendExceptionpublic boolean supportsInterruption()
IDAuthorityIDAuthority.getIDBlock(int, int, Duration) may be safely interrupted.supportsInterruption in interface IDAuthoritypublic StoreTransaction openTx() throws BackendException
openTx in interface BackendOperation.TransactionalProviderBackendExceptionpublic IDBlock getIDBlock(int partition, int idNamespace, java.time.Duration timeout) throws BackendException
IDAuthorityIDBlock. It is guaranteed that
the block of ids for the particular partition id is uniquely assigned,
that is, the block of ids has not been previously and will not
subsequently be assigned again when invoking this method on the local or
any remote machine that is connected to the underlying storage backend.
In other words, this method has to ensure that ids are uniquely assigned
per partition.
It is furthermore guaranteed that any id of the returned IDBlock is smaller than the upper bound
for the given partition as read from the IDBlockSizer set on this IDAuthority and that the
number of ids returned is equal to the block size of the IDBlockSizer.getIDBlock in interface IDAuthoritypartition - Partition for which to request an id blockidNamespace - namespace for ids within a partitiontimeout - When a call to this method is unable to return a id block
before this timeout elapses, the implementation must give up
and throw a StorageException ASAPpartition parameterBackendExceptionCopyright © 2012–2015. All rights reserved.