Class ClientPolicy

java.lang.Object
com.aerospike.client.policy.ClientPolicy

public class ClientPolicy
extends Object
Container object for client policy Command.
  • Field Details

    • eventLoops

      public EventLoops eventLoops
      Optional event loops to use in asynchronous commands.

      Default: null (async methods are disabled)

    • user

      public String user
      User authentication to cluster. Leave null for clusters running without restricted access.

      Default: null

    • password

      public String password
      Password authentication to cluster. The password will be stored by the client and sent to server in hashed format. Leave null for clusters running without restricted access.

      Default: null

    • clusterName

      public String clusterName
      Expected cluster name. If not null, server nodes must return this cluster name in order to join the client's view of the cluster. Should only be set when connecting to servers that support the "cluster-name" info command.

      Default: null

    • authMode

      public AuthMode authMode
      Authentication mode used when user/password is defined.

      Default: AuthMode.INTERNAL

    • timeout

      public int timeout
      Initial host connection timeout in milliseconds. The timeout when opening a connection to the server host for the first time.

      Default: 1000

    • loginTimeout

      public int loginTimeout
      Login timeout in milliseconds. The timeout is used when user authentication is enabled and a node login is being performed.

      Default: 5000

    • minConnsPerNode

      public int minConnsPerNode
      Minimum number of synchronous connections allowed per server node. Preallocate min connections on client node creation. The client will periodically allocate new connections if count falls below min connections.

      Server proto-fd-idle-ms and client maxSocketIdle should be set to zero (no reap) if minConnsPerNode is greater than zero. Reaping connections can defeat the purpose of keeping connections in reserve for a future burst of activity.

      Default: 0

    • maxConnsPerNode

      public int maxConnsPerNode
      Maximum number of synchronous connections allowed per server node. Transactions will go through retry logic and potentially fail with "ResultCode.NO_MORE_CONNECTIONS" if the maximum number of connections would be exceeded.

      The number of connections used per node depends on concurrent commands in progress plus sub-commands used for parallel multi-node commands (batch, scan, and query). One connection will be used for each command.

      Default: 300

    • asyncMinConnsPerNode

      public int asyncMinConnsPerNode
      Minimum number of asynchronous connections allowed per server node. Preallocate min connections on client node creation. The client will periodically allocate new connections if count falls below min connections.

      Server proto-fd-idle-ms and client maxSocketIdle should be set to zero (no reap) if asyncMinConnsPerNode is greater than zero. Reaping connections can defeat the purpose of keeping connections in reserve for a future burst of activity.

      Default: 0

    • asyncMaxConnsPerNode

      public int asyncMaxConnsPerNode
      Maximum number of asynchronous connections allowed per server node. Transactions will go through retry logic and potentially fail with "ResultCode.NO_MORE_CONNECTIONS" if the maximum number of connections would be exceeded.

      The number of connections used per node depends on concurrent commands in progress plus sub-commands used for parallel multi-node commands (batch, scan, and query). One connection will be used for each command.

      If the value is -1, the value will be set to maxConnsPerNode.

      Default: -1 (Use maxConnsPerNode)

    • connPoolsPerNode

      public int connPoolsPerNode
      Number of synchronous connection pools used for each node. Machines with 8 cpu cores or less usually need just one connection pool per node. Machines with a large number of cpu cores may have their synchronous performance limited by contention for pooled connections. Contention for pooled connections can be reduced by creating multiple mini connection pools per node.

      Default: 1

    • maxSocketIdle

      public int maxSocketIdle
      Maximum socket idle in seconds. Socket connection pools will discard sockets that have been idle longer than the maximum.

      Connection pools are now implemented by a LIFO stack. Connections at the tail of the stack will always be the least used. These connections are checked for maxSocketIdle once every 30 tend iterations (usually 30 seconds).

      If server's proto-fd-idle-ms is greater than zero, then maxSocketIdle should be at least a few seconds less than the server's proto-fd-idle-ms, so the client does not attempt to use a socket that has already been reaped by the server.

      If server's proto-fd-idle-ms is zero (no reap), then maxSocketIdle should also be zero. Connections retrieved from a pool in transactions will not be checked for maxSocketIdle when maxSocketIdle is zero. Idle connections will still be trimmed down from peak connections to min connections (minConnsPerNode and asyncMinConnsPerNode) using a hard-coded 55 second limit in the cluster tend thread.

      Default: 55

    • tendInterval

      public int tendInterval
      Interval in milliseconds between cluster tends by maintenance thread.

      Default: 1000

    • failIfNotConnected

      public boolean failIfNotConnected
      Throw exception if all seed connections fail on cluster instantiation.

      Default: true

    • readPolicyDefault

      public Policy readPolicyDefault
      Default read policy that is used when read command's policy is null.
    • writePolicyDefault

      public WritePolicy writePolicyDefault
      Default write policy that is used when write command's policy is null.
    • scanPolicyDefault

      public ScanPolicy scanPolicyDefault
      Default scan policy that is used when scan command's policy is null.
    • queryPolicyDefault

      public QueryPolicy queryPolicyDefault
      Default query policy that is used when query command's policy is null.
    • batchPolicyDefault

      public BatchPolicy batchPolicyDefault
      Default batch policy that is used when batch command's policy is null.
    • infoPolicyDefault

      public InfoPolicy infoPolicyDefault
      Default info policy that is used when info command's policy is null.
    • tlsPolicy

      public TlsPolicy tlsPolicy
      TLS secure connection policy for TLS enabled servers. TLS connections are only supported for AerospikeClient synchronous commands.

      Default: null (Use normal sockets)

    • ipMap

      public Map<String,​String> ipMap
      A IP translation table is used in cases where different clients use different server IP addresses. This may be necessary when using clients from both inside and outside a local area network. Default is no translation.

      The key is the IP address returned from friend info requests to other servers. The value is the real IP address used to connect to the server.

      Default: null (no IP address translation)

    • threadPool

      public ExecutorService threadPool
      Underlying thread pool used in synchronous batch, scan, and query commands. These commands are often sent to multiple server nodes in parallel threads. A thread pool improves performance because threads do not have to be created/destroyed for each command. The default, null, indicates that the following daemon thread pool will be used:
       threadPool = Executors.newCachedThreadPool(new ThreadFactory() {
           public final Thread newThread(Runnable runnable) {
                              Thread thread = new Thread(runnable);
                              thread.setDaemon(true);
                              return thread;
                      }
              });
       
      Daemon threads automatically terminate when the program terminates.

      Default: null (use Executors.newCachedThreadPool)

    • sharedThreadPool

      public boolean sharedThreadPool
      Is threadPool shared between other client instances or classes. If threadPool is not shared (default), threadPool will be shutdown when the client instance is closed.

      If threadPool is shared, threadPool will not be shutdown when the client instance is closed. This shared threadPool should be shutdown manually before the program terminates. Shutdown is recommended, but not absolutely required if threadPool is constructed to use daemon threads.

      Default: false

    • useServicesAlternate

      public boolean useServicesAlternate
      Should use "services-alternate" instead of "services" in info request during cluster tending. "services-alternate" returns server configured external IP addresses that client uses to talk to nodes. "services-alternate" can be used in place of providing a client "ipMap".

      Default: false (use original "services" info request)

    • forceSingleNode

      public boolean forceSingleNode
      For testing purposes only. Do not modify.

      Should the AerospikeClient instance communicate with the first seed node only instead of using the data partition map to determine which node to send the database command.

      Default: false

    • rackAware

      public boolean rackAware
      Track server rack data. This field is useful when directing read commands to the server node that contains the key and exists on the same rack as the client. This serves to lower cloud provider costs when nodes are distributed across different racks/data centers.

      rackId, Replica.PREFER_RACK and server rack configuration must also be set to enable this functionality.

      Default: false

    • rackId

      public int rackId
      Rack where this client instance resides.

      rackAware, Replica.PREFER_RACK and server rack configuration must also be set to enable this functionality.

      Default: 0

  • Constructor Details