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,
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() |
getBlockSize, getIdUpperBound, getPartitionKey, getUniqueID, setIDBlockSizerpublic ConsistentKeyIDAuthority(KeyColumnValueStore idStore, StoreManager manager, Configuration config) throws StorageException
StorageExceptionpublic List<KeyRange> getLocalIDPartition() throws StorageException
IDAuthoritygetLocalIDPartition in interface IDAuthorityStorageExceptionpublic void close()
throws StorageException
IDAuthorityclose in interface IDAuthorityclose in interface BackendOperation.TransactionalProviderStorageExceptionpublic StoreTransaction openTx() throws StorageException
openTx in interface BackendOperation.TransactionalProviderStorageExceptionpublic IDBlock getIDBlock(int partition, int idNamespace, Duration timeout) throws StorageException
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 parameterStorageExceptionCopyright © 2012–2014. All rights reserved.