public class FDB
extends java.lang.Object
selectAPIVersion(int)
.
This call is required before using any other part of the API. The call allows
an error to be thrown at this point to prevent client code from accessing a later library
with incorrect assumptions from the current version. The API version documented here is version
630
.Database
object to use is
to call open()
.
open()
or started explicitly with a call to startNetwork()
.
Modifier and Type | Field and Description |
---|---|
static java.util.concurrent.ExecutorService |
DEFAULT_EXECUTOR |
Modifier and Type | Method and Description |
---|---|
Cluster |
createCluster()
Deprecated.
Use
open() instead. |
Cluster |
createCluster(java.lang.String clusterFilePath)
Deprecated.
Use
open(String) instead. |
Cluster |
createCluster(java.lang.String clusterFilePath,
java.util.concurrent.Executor e)
Deprecated.
Use
open(String, Executor) instead. |
void |
disableShutdownHook()
Disables shutdown hook that stops network thread upon process shutdown.
|
void |
enableDirectBufferQuery(boolean enabled)
Enables or disables use of DirectByteBuffers for getRange() queries.
|
int |
getAPIVersion()
Returns the API version that was selected by the
selectAPIVersion()
call. |
static FDB |
instance()
Return the instance of the FDB API singleton.
|
static boolean |
isAPIVersionSelected()
Determines if the API version has already been selected.
|
boolean |
isDirectBufferQueriesEnabled()
Determines whether
getRange() queries can use DirectByteBuffer from
DirectBufferPool to copy results. |
Database |
open()
Initializes networking if required and connects to the cluster specified by the
default fdb.cluster file.
A single client can use this function multiple times to connect to different clusters simultaneously, with each invocation requiring its own cluster file. |
Database |
open(java.lang.String clusterFilePath)
Initializes networking if required and connects to the cluster specified by
clusterFilePath .A single client can use this function multiple times to connect to different clusters simultaneously, with each invocation requiring its own cluster file. |
Database |
open(java.lang.String clusterFilePath,
EventKeeper eventKeeper)
Initializes networking if required and connects to the cluster specified by
clusterFilePath .A single client can use this function multiple times to connect to different clusters simultaneously, with each invocation requiring its own cluster file. |
Database |
open(java.lang.String clusterFilePath,
java.util.concurrent.Executor e)
Initializes networking if required and connects to the cluster specified by
clusterFilePath .A single client can use this function multiple times to connect to different clusters simultaneously, with each invocation requiring its own cluster file. |
Database |
open(java.lang.String clusterFilePath,
java.util.concurrent.Executor e,
EventKeeper eventKeeper)
Initializes networking if required and connects to the cluster specified by
clusterFilePath .A single client can use this function multiple times to connect to different clusters simultaneously, with each invocation requiring its own cluster file. |
NetworkOptions |
options()
Returns a set of options that can be set on a the FoundationDB API.
|
void |
resizeDirectBufferPool(int poolSize,
int bufferSize)
Resizes the DirectBufferPool with given parameters, which is used by getRange() requests.
|
static FDB |
selectAPIVersion(int version)
Select the version for the client API.
|
void |
setUnclosedWarning(boolean warnOnUnclosed)
Enables or disables the stderr warning that is printed whenever an object with FoundationDB
native resources is garbage collected without being closed.
|
void |
startNetwork()
Initializes networking.
|
void |
startNetwork(java.util.concurrent.Executor e)
Initializes networking.
|
void |
stopNetwork()
Stops the FoundationDB networking engine.
|
public static final java.util.concurrent.ExecutorService DEFAULT_EXECUTOR
public NetworkOptions options()
startNetwork()
or implicitly by a call to open()
and
and its variants.public static boolean isAPIVersionSelected()
true
if the user has already called
selectAPIVersion()
and that call
has completed successfully.true
if an API version has been selected and false
otherwisepublic static FDB instance() throws FDBException
null
value for the singleton, but if the
selectAPIVersion()
method has not yet been
called, it will throw an FDBException
indicating that an API
version has not yet been set.FDBException
- if selectAPIVersion()
has not been calledpublic static FDB selectAPIVersion(int version) throws FDBException
version
- the API version requiredFDBException
public void disableShutdownHook()
stopNetwork()
.public void setUnclosedWarning(boolean warnOnUnclosed)
warnOnUnclosed
- Whether the warning should be printed for unclosed objectspublic int getAPIVersion()
selectAPIVersion()
call. This can be used to guard different parts of client code against different versions
of the FoundationDB API to allow for libraries using FoundationDB to be compatible across
several versions.public void enableDirectBufferQuery(boolean enabled)
enabled
- Whether DirectByteBuffer should be used for getRange() queries.public boolean isDirectBufferQueriesEnabled()
getRange()
queries can use DirectByteBuffer
from
DirectBufferPool
to copy results.true
if direct buffer queries have been enabled and false
otherwisepublic void resizeDirectBufferPool(int poolSize, int bufferSize)
poolSize
- Number of buffers in poolbufferSize
- Size of each buffer in bytes@Deprecated public Cluster createCluster() throws java.lang.IllegalStateException, FDBException
open()
instead.startNetwork()
had been called.CompletableFuture
that will be set to a FoundationDB Cluster
.FDBException
- on errors encountered starting the FoundationDB networking enginejava.lang.IllegalStateException
- if the network had been previously stopped@Deprecated public Cluster createCluster(java.lang.String clusterFilePath) throws java.lang.IllegalStateException, FDBException
open(String)
instead.clusterFilePath
. If the FoundationDB network
has not been started, it will be started in the course of this call as if
startNetwork()
had been called.clusterFilePath
- the
cluster file
defining the FoundationDB cluster. This can be null
if the
default fdb.cluster file
is to be used.CompletableFuture
that will be set to a FoundationDB Cluster
.FDBException
- on errors encountered starting the FoundationDB networking enginejava.lang.IllegalStateException
- if the network had been previously stopped@Deprecated public Cluster createCluster(java.lang.String clusterFilePath, java.util.concurrent.Executor e) throws FDBException, java.lang.IllegalStateException
open(String, Executor)
instead.clusterFilePath
. If the FoundationDB network
has not been started, it will be started in the course of this call. The supplied
Executor
will be used as the default for the execution of all callbacks that
are produced from using the resulting Cluster
.clusterFilePath
- the
cluster file
defining the FoundationDB cluster. This can be null
if the
default fdb.cluster file
is to be used.e
- used to run the FDB network threadCompletableFuture
that will be set to a FoundationDB Cluster
.FDBException
- on errors encountered starting the FoundationDB networking enginejava.lang.IllegalStateException
- if the network had been previously stoppedpublic Database open() throws FDBException
CompletableFuture
that will be set to a FoundationDB Database
FDBException
public Database open(java.lang.String clusterFilePath) throws FDBException
clusterFilePath
.clusterFilePath
- the
cluster file
defining the FoundationDB cluster. This can be null
if the
default fdb.cluster file
is to be used.CompletableFuture
that will be set to a FoundationDB Database
FDBException
public Database open(java.lang.String clusterFilePath, EventKeeper eventKeeper) throws FDBException
clusterFilePath
.clusterFilePath
- the
cluster file
defining the FoundationDB cluster. This can be null
if the
default fdb.cluster file
is to be used.eventKeeper
- the EventKeeper to use for instrumentation calls, or null
if no instrumentation is desired.CompletableFuture
that will be set to a FoundationDB Database
FDBException
public Database open(java.lang.String clusterFilePath, java.util.concurrent.Executor e) throws FDBException
clusterFilePath
.clusterFilePath
- the
cluster file
defining the FoundationDB cluster. This can be null
if the
default fdb.cluster file
is to be used.e
- the Executor
to use to execute asynchronous callbacksCompletableFuture
that will be set to a FoundationDB Database
FDBException
public Database open(java.lang.String clusterFilePath, java.util.concurrent.Executor e, EventKeeper eventKeeper) throws FDBException
clusterFilePath
.clusterFilePath
- the
cluster file
defining the FoundationDB cluster. This can be null
if the
default fdb.cluster file
is to be used.e
- the Executor
to use to execute asynchronous callbackseventKeeper
- the EventKeeper
to use to record instrumentation metrics, or null
if no
instrumentation is desired.CompletableFuture
that will be set to a FoundationDB Database
FDBException
public void startNetwork() throws FDBException, java.lang.IllegalStateException
startNetwork()
will create a new thread and execute the networking
event loop on that thread. This method is called upon Database
creation by default if the network has not yet been started. If one
wishes to control what thread the network runs on,
one should use the version of startNetwork()
that takes an Executor
.NetworkOptions
.java.lang.IllegalStateException
- if the network has already been stoppedFDBException
NetworkOptions
public void startNetwork(java.util.concurrent.Executor e) throws FDBException, java.lang.IllegalStateException
Executor
. This
event loop is a blocking operation that is not
expected to terminate until the program is complete. This will therefore consume an
entire thread from e
if e
is a thread pool or will completely block
the single thread of a single-threaded Executor
.NetworkOptions
. These options should be set before a call
to this method.e
- the Executor
to use to execute network operations onjava.lang.IllegalStateException
- if the network has already been stoppedFDBException
NetworkOptions
public void stopNetwork() throws FDBException
FDBException
- on errors while stopping the network