public class FoundationKVDatabase extends Object implements KVDatabase
KVDatabase
implementation.
Allows specifying a key prefix for all keys, allowing multiple independent databases. Key watches are supported.
Modifier and Type | Field and Description |
---|---|
static int |
API_VERSION
The API version used by this class.
|
Constructor and Description |
---|
FoundationKVDatabase()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
FoundationKVTransaction |
createTransaction()
Create a new transaction.
|
FoundationKVTransaction |
createTransaction(Map<String,?> options)
Create a new transaction with the specified options.
|
static long |
decodeCounter(byte[] bytes)
Decode a 64 bit counter value.
|
static byte[] |
encodeCounter(long value)
Encode a 64 bit counter value.
|
Database |
getDatabase()
Get the underlying
Database associated with this instance. |
byte[] |
getKeyPrefix()
Get the key prefix for all keys.
|
NetworkOptions |
getNetworkOptions()
Get the
NetworkOptions associated with this instance. |
void |
setClusterFilePath(String clusterFilePath)
Configure the cluster file path.
|
void |
setExecutor(Executor executor)
Configure the
Executor used for the FoundationDB networking event loop. |
void |
setKeyPrefix(byte[] keyPrefix)
Configure a prefix for all keys.
|
void |
start()
Start this instance.
|
void |
stop()
Stop this instance.
|
public static final int API_VERSION
public FoundationKVDatabase()
FDBException
- if API_VERSION
is not supportedpublic NetworkOptions getNetworkOptions()
NetworkOptions
associated with this instance.
Options must be configured prior to start()
.public void setExecutor(Executor executor)
Executor
used for the FoundationDB networking event loop.
By default, the default thread pool is used to execute the FoundationDB network.
executor
- executor for networking activityFDB.startNetwork()
public void setClusterFilePath(String clusterFilePath)
clusterFilePath
- cluster file pathnamepublic byte[] getKeyPrefix()
public void setKeyPrefix(byte[] keyPrefix)
The key prefix may not be changed after this instance has started.
keyPrefix
- new prefix, or null for noneIllegalArgumentException
- if keyPrefix
starts with 0xff
IllegalStateException
- if this instance has already been startedpublic Database getDatabase()
Database
associated with this instance.Database
IllegalStateException
- if this instance has not yet been started@PostConstruct public void start()
KVDatabase
This method is idempotent: if this instance is already started, nothing happens.
Whether an instance that has been started and stopped can be restarted is implementation-dependent.
start
in interface KVDatabase
@PreDestroy public void stop()
KVDatabase
This method is idempotent: if this instance has not been started, or is already stopped, nothing happens.
stop
in interface KVDatabase
public FoundationKVTransaction createTransaction()
KVDatabase
createTransaction
in interface KVDatabase
public FoundationKVTransaction createTransaction(Map<String,?> options)
KVDatabase
createTransaction
in interface KVDatabase
options
- optional transaction options; may be nullpublic static byte[] encodeCounter(long value)
value
- counter valuepublic static long decodeCounter(byte[] bytes)
bytes
- encoded valueNullPointerException
- if bytes
is nullIllegalArgumentException
- if bytes
is invalidCopyright © 2022. All rights reserved.