public class Client2Config
extends java.lang.Object
Client2
VoltDB client. A Client2Config
object is passed
as input to ClientFactory.createClient()
, which
generates a Client2
with the desired characteristics.Client2
,
Client2Notification
,
ClientFactory
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CLIENT_REQUEST_HARD_LIMIT |
static int |
DEFAULT_CLIENT_REQUEST_RESUME_LEVEL |
static int |
DEFAULT_CLIENT_REQUEST_WARNING_LEVEL |
static long |
DEFAULT_CONNECTION_RESPONSE_TIMEOUT |
static long |
DEFAULT_CONNECTION_SETUP_TIMEOUT |
static int |
DEFAULT_NETWORK_BACKPRESSURE_LEVEL |
static int |
DEFAULT_OUTSTANDING_TRANSACTION_LIMIT |
static long |
DEFAULT_PROCEDURE_TIMEOUT |
static long |
DEFAULT_RECONNECT_DELAY |
static long |
DEFAULT_RECONNECT_RETRY_DELAY |
static int |
DEFAULT_REQUEST_PRIORITY |
static int |
DEFAULT_RESPONSE_THREADS |
static int |
HIGHEST_PRIORITY |
static int |
LOWEST_PRIORITY |
Constructor and Description |
---|
Client2Config()
Constructs a configuration with default values.
|
Modifier and Type | Method and Description |
---|---|
Client2Config |
authenticatedSubject(javax.security.auth.Subject subject)
Sets the authenticated subject to be used for connections
to VoltDB.
|
Client2Config |
clientRequestBackpressureLevel(int warning,
int resume)
Sets levels for controlling backpressure notifications.
|
Client2Config |
clientRequestLimit(int limit)
Sets the limit on the number of requests that can be pending in
a client at any one time.
|
Client2Config |
connectFailureHandler(Client2Notification.ConnectionStatus handler)
Registers a handler for connection-establishment failures.
|
Client2Config |
connectionDownHandler(Client2Notification.ConnectionStatus handler)
Registers a handler for connection-down events.
|
Client2Config |
connectionResponseTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
Sets the connection response timeout.
|
Client2Config |
connectionSetupTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
Sets the timeout for connection setup, including authentication
to the server.
|
Client2Config |
connectionUpHandler(Client2Notification.ConnectionStatus handler)
Registers a handler for connection-up events.
|
Client2Config |
defaultTrustStore()
Configures trust store for TLS/SSL using a default path for the
trust store file, based on where Java is installed, and a default
password.
|
Client2Config |
disableConnectionMgmt()
Disable automatic connection management.
|
Client2Config |
enableSSL()
Enables TLS/SSL for server connections.
|
Client2Config |
errorLogHandler(Client2Notification.ErrorLog handler)
Registers an error-log handler.
|
Client2Config |
hashedPassword(java.lang.String password)
Set hashed password for connections to VoltDB.
|
Client2Config |
hashedPassword(java.lang.String password,
org.voltdb.client.ClientAuthScheme hashScheme)
Set hashed password for connections to VoltDB.
|
Client2Config |
lateResponseHandler(Client2Notification.LateResponse handler)
Registers a handler for late server responses.
|
Client2Config |
loginContext(java.lang.String name)
Creates a new login context and authenticates the user, then
adds the authenticated subject to this client configuration.
|
Client2Config |
networkBackpressureLevel(int level)
This setting controls the maximum number of requests that
the Client2 API can have queued at the VoltDB network
layer for a single connection.
|
Client2Config |
outstandingTransactionLimit(int limit)
Sets the limit on the number of transactions that can be
outstanding at the VoltDB server at any one time.
|
Client2Config |
password(java.lang.String password)
Set cleartext password for connections to VoltDB.
|
Client2Config |
procedureCallTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
Sets the timeout for procedure calls.
|
Client2Config |
reconnectDelay(long initialDelay,
long retryDelay,
java.util.concurrent.TimeUnit unit)
Sets delay times for attempts to reconnect failed connections.
|
Client2Config |
requestBackpressureHandler(Client2Notification.RequestBackpressure handler)
Registers a handler to be notified about changes in request backpressure.
|
Client2Config |
requestPriority(int prio)
Sets the default priority for procedure calls from
a
Client2 created using this configuration. |
Client2Config |
responseExecutorService(java.util.concurrent.ExecutorService execService,
boolean stopOnClose)
Provides an
ExecutorService with which to
complete callProcedure requests. |
Client2Config |
responseThreadCount(int count)
Sets the fixed number of 'response' threads to be available
in the pool of such threads.
|
Client2Config |
roundingMode(boolean enable,
java.math.RoundingMode mode)
Enables or disables the rounding mode in the client.
|
Client2Config |
transactionRateLimit(int tpsLimit)
Limits the rate at which transactions can be sent to the
VoltDB server.
|
Client2Config |
trustStore(java.lang.String path,
java.lang.String password)
Configures trust store for TLS/SSL using a specified name for the
trust store and a specified password.
|
Client2Config |
trustStoreFromPropertyFile(java.lang.String path)
Configures trust store for TLS/SSL from a property file.
|
Client2Config |
username(java.lang.String username)
Set username for connections to VoltDB.
|
public static final long DEFAULT_CONNECTION_SETUP_TIMEOUT
public static final long DEFAULT_CONNECTION_RESPONSE_TIMEOUT
public static final long DEFAULT_PROCEDURE_TIMEOUT
public static final int DEFAULT_CLIENT_REQUEST_HARD_LIMIT
public static final int DEFAULT_CLIENT_REQUEST_WARNING_LEVEL
public static final int DEFAULT_CLIENT_REQUEST_RESUME_LEVEL
public static final int DEFAULT_OUTSTANDING_TRANSACTION_LIMIT
public static final int DEFAULT_NETWORK_BACKPRESSURE_LEVEL
public static final long DEFAULT_RECONNECT_DELAY
public static final long DEFAULT_RECONNECT_RETRY_DELAY
public static final int DEFAULT_REQUEST_PRIORITY
public static final int DEFAULT_RESPONSE_THREADS
public static final int HIGHEST_PRIORITY
public static final int LOWEST_PRIORITY
public Client2Config()
All configuration methods in Client2Config
return this
,
so calls can be chained.
public Client2Config username(java.lang.String username)
username
- usernamepublic Client2Config password(java.lang.String password)
password
- passwordpublic Client2Config hashedPassword(java.lang.String password)
password
- hashed passwordpublic Client2Config hashedPassword(java.lang.String password, org.voltdb.client.ClientAuthScheme hashScheme)
password
- hashed passwordhashScheme
- hash scheme used to hash the passwordpublic Client2Config authenticatedSubject(javax.security.auth.Subject subject)
subject
- subject (javax.security.auth.Subject
)public Client2Config loginContext(java.lang.String name)
See package javax.security.auth.login
for details.
name
- as used as key to locate the login context entryauthenticatedSubject(javax.security.auth.Subject)
public Client2Config connectionSetupTimeout(long timeout, java.util.concurrent.TimeUnit unit)
timeout
- the timeout intervalunit
- the units in which the timeout was expressedpublic Client2Config connectionResponseTimeout(long timeout, java.util.concurrent.TimeUnit unit)
If no response has been received on a connection within the specified time, the connection will be considered lost. A 'ping' request will be periodically executed on an otherwise-idle connection in order to ensure keep the connection alive.
timeout
- the timeout intervalunit
- the units in which the timeout was expressedpublic Client2Config procedureCallTimeout(long timeout, java.util.concurrent.TimeUnit unit)
If a call has received no response from VoltDB in the specified time, it will be completed with a timeout error.
timeout
- the timeout intervalunit
- the units in which the timeout was expressedpublic Client2Config clientRequestLimit(int limit)
callProcedure()
is called, up to when the response
has been delivered to the application or the call has failed.
Calls which exceed this limit will be rejected by the API.
This is an absolute limit on resource consumption. It should
be set somewhat larger than the warning level established by
a call to clientRequestBackpressureLevel(int, int)
in order to
give the application headroom to react to the warning.
limit
- the desired request limitclientRequestBackpressureLevel(int, int)
public Client2Config clientRequestBackpressureLevel(int warning, int resume)
When the pending count reaches the warning level or greater, the application is warned to slow down: backpressure starts. When the pending count subsequently drops to the resume level (or lower), the application is informed that it no longer needs to slow down: backpressure ends.
For predictable operation, the implementation will adjust values such that:
warning
- the level at which the application is warned to slow downresume
- the level at which application slow-down can endclientRequestLimit(int)
,
requestBackpressureHandler(org.voltdb.client.Client2Notification.RequestBackpressure)
public Client2Config outstandingTransactionLimit(int limit)
Requests will be queued in the Client2 API after this limit is reached, to avoid overwhelming the VoltDB cluster.
limit
- the desired request limitpublic Client2Config transactionRateLimit(int tpsLimit)
If the application is making requests to callProcedure
in excess of the target rate, then the client queue length
will likely grow to the point at which request backpressure
is signaled. Queued requests may be timed out in the usual manner.
Any throttling of sends imposed by setting this configuration
parameter is applied before, and independently of, that implied
by outstandingTransactionLimit
.
By default there is no rate limiting.
tpsLimit
- target rate limit in transactions per secondpublic Client2Config networkBackpressureLevel(int level)
Transmission order is fixed before a request is queued to the network layer. Thus, setting this value too high can adversely affect the ability of high-priority requests to overtake lower-priority requests.
VoltDB recommends changing the default only after careful measurement in a realistic scenario.
level
- the desired backpressure levelpublic Client2Config reconnectDelay(long initialDelay, long retryDelay, java.util.concurrent.TimeUnit unit)
In typical use, the initial delay will be fairly small, in order to recover from a momentary glitch; the retryDelay will be somewhat longer.
VoltDB recommends changing delay times from the defaults only when default settings have been shown to be problematic in your specific use-case.
initialDelay
- delay before first reconnect attemptretryDelay
- delay between subsequent retriesunit
- time units used for both delay valuespublic Client2Config disableConnectionMgmt()
Normally, after the application connects to at least one VoltDB
server using connectSync
or connectAsync
,
the API will manage connections to the VoltDB cluster. Connections
will be created to available cluster nodes as they are discovered,
and failed connections will be reconnected when possible.
The application can disable this, and assume all responsibility for making initial connections, and for recovery from loss of connection.
public Client2Config requestPriority(int prio)
Client2
created using this configuration.
The value given here can be overridden by individual procedure calls.
The valid priority range is from HIGHEST_PRIORITY
to LOWEST_PRIORITY
, inclusive. Higher priorities
have lower numerical values.
prio
- prioritypublic Client2Config trustStoreFromPropertyFile(java.lang.String path)
path
- property file containing trust store properties:
trustStore
trust store file specification
trustStorePassword
trust store password
enableSSL()
public Client2Config defaultTrustStore()
enableSSL()
public Client2Config trustStore(java.lang.String path, java.lang.String password)
path
- trust store file specificationpassword
- trust store passwordenableSSL()
public Client2Config enableSSL()
enableSSL
.public Client2Config connectFailureHandler(Client2Notification.ConnectionStatus handler)
handler
- a Client2Notification.ConnectionStatus
Client2Notification
public Client2Config connectionUpHandler(Client2Notification.ConnectionStatus handler)
handler
- a Client2Notification.ConnectionStatus
Client2Notification
public Client2Config connectionDownHandler(Client2Notification.ConnectionStatus handler)
handler
- a Client2Notification.ConnectionStatus
Client2Notification
public Client2Config lateResponseHandler(Client2Notification.LateResponse handler)
handler
- a Client2Notification.LateResponse
Client2Notification
public Client2Config requestBackpressureHandler(Client2Notification.RequestBackpressure handler)
Backpressure trigger levels are configurable via clientRequestBackpressureLevel(int, int)
.
handler
- a Client2Notification.RequestBackpressure
Client2Notification
public Client2Config errorLogHandler(Client2Notification.ErrorLog handler)
The Client2
implementation may print messages on
its standard error when certain unexpected situations arise.
The application can choose to handle the message instead,
perhaps writing to its own log.
Applications are cautioned against attempting to interpret the text of a log message. The wording is subject to change without notice.
handler
- a Client2Notification.ErrorLog
Client2Notification
public Client2Config responseThreadCount(int count)
This setting is only meaningful for the internal client
response ExecutorService
. If you provide a
custom service by responseExecutorService
then
the count specified here is not used.
count
- number of response threads to createpublic Client2Config responseExecutorService(java.util.concurrent.ExecutorService execService, boolean stopOnClose)
ExecutorService
with which to
complete callProcedure
requests. This replaces
the default provided by the Client2
interface.
When a response message is received from the VoltDB cluster, it
is handed over to a thread from this service for processing.
The eventual setting of the call's CompletableFuture
into the 'completed' state will occur on this thread.
The caller chooses whether or not Client2.close()
will
automatically execute a shutdown
on the executor
service.
execService
- an ExecutorService
stopOnClose
- true to stop the service on client closepublic Client2Config roundingMode(boolean enable, java.math.RoundingMode mode)
enable
- true iff rounding is enabledmode
- the rounding mode (java.math.RoundingMode
)