Class AerospikeClient
- All Implemented Interfaces:
IAerospikeClient
,Closeable
,AutoCloseable
public class AerospikeClient extends Object implements IAerospikeClient, Closeable
AerospikeClient
object to access an Aerospike
database cluster and perform database operations.
This client is thread-safe. One client instance should be used per cluster. Multiple threads should share this cluster instance.
Your application uses this class API to perform database operations such as writing and reading records, and selecting sets of records. Write operations include specialized functionality such as append/prepend and arithmetic addition.
Each record may have multiple bins, unless the Aerospike server nodes are configured as "single-bin". In "multi-bin" mode, partial records may be written or read by specifying the relevant subset of bins.
-
Field Summary
Fields Modifier and Type Field Description BatchPolicy
batchPolicyDefault
Default batch policy that is used when batch command policy is null.InfoPolicy
infoPolicyDefault
Default info policy that is used when info command policy is null.QueryPolicy
queryPolicyDefault
Default query policy that is used when query command policy is null.Policy
readPolicyDefault
Default read policy that is used when read command policy is null.ScanPolicy
scanPolicyDefault
Default scan policy that is used when scan command policy is null.WritePolicy
writePolicyDefault
Default write policy that is used when write command policy is null. -
Constructor Summary
Constructors Constructor Description AerospikeClient(ClientPolicy policy, Host... hosts)
Initialize Aerospike client with suitable hosts to seed the cluster map.AerospikeClient(ClientPolicy policy, String hostname, int port)
Initialize Aerospike client.AerospikeClient(String hostname, int port)
Initialize Aerospike client. -
Method Summary
Modifier and Type Method Description void
add(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key, Bin... bins)
Asynchronously add integer/double bin values to existing record bin values.void
add(WritePolicy policy, Key key, Bin... bins)
Add integer/double bin values to existing record bin values.void
append(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key, Bin... bins)
Asynchronously append bin string values to existing record bin values.void
append(WritePolicy policy, Key key, Bin... bins)
Append bin string values to existing record bin values.void
changePassword(AdminPolicy policy, String user, String password)
Change user's password.void
close()
Close all client connections to database server nodes.void
createIndex(EventLoop eventLoop, IndexListener listener, Policy policy, String namespace, String setName, String indexName, String binName, IndexType indexType, IndexCollectionType indexCollectionType)
Asynchronously create complex secondary index to be used on bins containing collections.IndexTask
createIndex(Policy policy, String namespace, String setName, String indexName, String binName, IndexType indexType)
Create scalar secondary index.IndexTask
createIndex(Policy policy, String namespace, String setName, String indexName, String binName, IndexType indexType, IndexCollectionType indexCollectionType)
Create complex secondary index to be used on bins containing collections.void
createRole(AdminPolicy policy, String roleName, List<Privilege> privileges)
Create user defined role.void
createRole(AdminPolicy policy, String roleName, List<Privilege> privileges, List<String> whitelist)
Create user defined role with optional privileges and whitelist.void
createUser(AdminPolicy policy, String user, String password, List<String> roles)
Create user with password and roles.void
delete(EventLoop eventLoop, DeleteListener listener, WritePolicy policy, Key key)
Asynchronously delete record for specified key.boolean
delete(WritePolicy policy, Key key)
Delete record for specified key.void
dropIndex(EventLoop eventLoop, IndexListener listener, Policy policy, String namespace, String setName, String indexName)
Asynchronously delete secondary index.IndexTask
dropIndex(Policy policy, String namespace, String setName, String indexName)
Delete secondary index.void
dropRole(AdminPolicy policy, String roleName)
Drop user defined role.void
dropUser(AdminPolicy policy, String user)
Remove user from cluster.void
execute(EventLoop eventLoop, ExecuteListener listener, WritePolicy policy, Key key, String packageName, String functionName, Value... functionArgs)
Asynchronously execute user defined function on server.Object
execute(WritePolicy policy, Key key, String packageName, String functionName, Value... functionArgs)
Execute user defined function on server and return results.ExecuteTask
execute(WritePolicy policy, Statement statement, Operation... operations)
Apply operations on records that match the statement filter.ExecuteTask
execute(WritePolicy policy, Statement statement, String packageName, String functionName, Value... functionArgs)
Apply user defined function on records that match the statement filter.void
exists(EventLoop eventLoop, ExistsArrayListener listener, BatchPolicy policy, Key[] keys)
Asynchronously check if multiple record keys exist in one batch call.void
exists(EventLoop eventLoop, ExistsListener listener, Policy policy, Key key)
Asynchronously determine if a record key exists.void
exists(EventLoop eventLoop, ExistsSequenceListener listener, BatchPolicy policy, Key[] keys)
Asynchronously check if multiple record keys exist in one batch call.boolean[]
exists(BatchPolicy policy, Key[] keys)
Check if multiple record keys exist in one batch call.boolean
exists(Policy policy, Key key)
Determine if a record key exists.void
get(EventLoop eventLoop, BatchListListener listener, BatchPolicy policy, List<BatchRead> records)
Asynchronously read multiple records for specified batch keys in one batch call.void
get(EventLoop eventLoop, BatchSequenceListener listener, BatchPolicy policy, List<BatchRead> records)
Asynchronously read multiple records for specified batch keys in one batch call.void
get(EventLoop eventLoop, RecordArrayListener listener, BatchPolicy policy, Key[] keys)
Asynchronously read multiple records for specified keys in one batch call.void
get(EventLoop eventLoop, RecordArrayListener listener, BatchPolicy policy, Key[] keys, String... binNames)
Asynchronously read multiple record headers and bins for specified keys in one batch call.void
get(EventLoop eventLoop, RecordListener listener, Policy policy, Key key)
Asynchronously read entire record for specified key.void
get(EventLoop eventLoop, RecordListener listener, Policy policy, Key key, String... binNames)
Asynchronously read record header and bins for specified key.void
get(EventLoop eventLoop, RecordSequenceListener listener, BatchPolicy policy, Key[] keys)
Asynchronously read multiple records for specified keys in one batch call.void
get(EventLoop eventLoop, RecordSequenceListener listener, BatchPolicy policy, Key[] keys, String... binNames)
Asynchronously read multiple record headers and bins for specified keys in one batch call.Record[]
get(BatchPolicy policy, Key[] keys)
Read multiple records for specified keys in one batch call.Record[]
get(BatchPolicy policy, Key[] keys, String... binNames)
Read multiple record headers and bins for specified keys in one batch call.void
get(BatchPolicy policy, List<BatchRead> records)
Read multiple records for specified batch keys in one batch call.Record
get(Policy policy, Key key)
Read entire record for specified key.Record
get(Policy policy, Key key, String... binNames)
Read record header and bins for specified key.BatchPolicy
getBatchPolicyDefault()
com.aerospike.client.cluster.Cluster
getCluster()
Return operating cluster.ClusterStats
getClusterStats()
Return operating cluster statistics.void
getHeader(EventLoop eventLoop, RecordArrayListener listener, BatchPolicy policy, Key[] keys)
Asynchronously read multiple record header data for specified keys in one batch call.void
getHeader(EventLoop eventLoop, RecordListener listener, Policy policy, Key key)
Asynchronously read record generation and expiration only for specified key.void
getHeader(EventLoop eventLoop, RecordSequenceListener listener, BatchPolicy policy, Key[] keys)
Asynchronously read multiple record header data for specified keys in one batch call.Record[]
getHeader(BatchPolicy policy, Key[] keys)
Read multiple record header data for specified keys in one batch call.Record
getHeader(Policy policy, Key key)
Read record generation and expiration only for specified key.InfoPolicy
getInfoPolicyDefault()
Node
getNode(String nodeName)
Return node given its name.List<String>
getNodeNames()
Return list of active server node names in the cluster.Node[]
getNodes()
Return array of active server nodes in the cluster.QueryPolicy
getQueryPolicyDefault()
Policy
getReadPolicyDefault()
ScanPolicy
getScanPolicyDefault()
WritePolicy
getWritePolicyDefault()
void
grantPrivileges(AdminPolicy policy, String roleName, List<Privilege> privileges)
Grant privileges to an user defined role.void
grantRoles(AdminPolicy policy, String user, List<String> roles)
Add roles to user's list of roles.void
info(EventLoop eventLoop, InfoListener listener, InfoPolicy policy, Node node, String... commands)
Asynchronously make info commands.boolean
isConnected()
Determine if we are ready to talk to the database server cluster.void
operate(EventLoop eventLoop, RecordListener listener, WritePolicy policy, Key key, Operation... operations)
Asynchronously perform multiple read/write operations on a single key in one batch call.Record
operate(WritePolicy policy, Key key, Operation... operations)
Perform multiple read/write operations on a single key in one batch call.void
prepend(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key, Bin... bins)
Asynchronously prepend bin string values to existing record bin values.void
prepend(WritePolicy policy, Key key, Bin... bins)
Prepend bin string values to existing record bin values.void
put(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key, Bin... bins)
Asynchronously write record bin(s).void
put(WritePolicy policy, Key key, Bin... bins)
Write record bin(s).void
query(EventLoop eventLoop, RecordSequenceListener listener, QueryPolicy policy, Statement statement)
Asynchronously execute query on all server nodes.RecordSet
query(QueryPolicy policy, Statement statement)
Execute query on all server nodes and return record iterator.ResultSet
queryAggregate(QueryPolicy policy, Statement statement)
Execute query, apply statement's aggregation function, and return result iterator.ResultSet
queryAggregate(QueryPolicy policy, Statement statement, String packageName, String functionName, Value... functionArgs)
Execute query, apply statement's aggregation function, and return result iterator.ResultSet
queryAggregateNode(QueryPolicy policy, Statement statement, Node node)
Execute query on a single server node, apply statement's aggregation function, and return result iterator.RecordSet
queryNode(QueryPolicy policy, Statement statement, Node node)
Execute query on a single server node and return record iterator.void
queryPartitions(EventLoop eventLoop, RecordSequenceListener listener, QueryPolicy policy, Statement statement, PartitionFilter partitionFilter)
Asynchronously execute query for specified partitions.RecordSet
queryPartitions(QueryPolicy policy, Statement statement, PartitionFilter partitionFilter)
Execute query for specified partitions and return record iterator.Role
queryRole(AdminPolicy policy, String roleName)
Retrieve role definition.List<Role>
queryRoles(AdminPolicy policy)
Retrieve all roles.User
queryUser(AdminPolicy policy, String user)
Retrieve roles for a given user.List<User>
queryUsers(AdminPolicy policy)
Retrieve all users and their roles.RegisterTask
register(Policy policy, ClassLoader resourceLoader, String resourcePath, String serverPath, Language language)
Register package located in a resource containing user defined functions with server.RegisterTask
register(Policy policy, String clientPath, String serverPath, Language language)
Register package located in a file containing user defined functions with server.RegisterTask
registerUdfString(Policy policy, String code, String serverPath, Language language)
Register UDF functions located in a code string with server.void
removeUdf(InfoPolicy policy, String serverPath)
Remove user defined function from server nodes.void
revokePrivileges(AdminPolicy policy, String roleName, List<Privilege> privileges)
Revoke privileges from an user defined role.void
revokeRoles(AdminPolicy policy, String user, List<String> roles)
Remove roles from user's list of roles.void
scanAll(EventLoop eventLoop, RecordSequenceListener listener, ScanPolicy policy, String namespace, String setName, String... binNames)
Asynchronously read all records in specified namespace and set.void
scanAll(ScanPolicy policy, String namespace, String setName, ScanCallback callback, String... binNames)
Read all records in specified namespace and set.void
scanNode(ScanPolicy policy, Node node, String namespace, String setName, ScanCallback callback, String... binNames)
Read all records in specified namespace and set for one node only.void
scanNode(ScanPolicy policy, String nodeName, String namespace, String setName, ScanCallback callback, String... binNames)
Read all records in specified namespace and set for one node only.void
scanPartitions(EventLoop eventLoop, RecordSequenceListener listener, ScanPolicy policy, PartitionFilter partitionFilter, String namespace, String setName, String... binNames)
Asynchronously read records in specified namespace, set and partition filter.void
scanPartitions(ScanPolicy policy, PartitionFilter partitionFilter, String namespace, String setName, ScanCallback callback, String... binNames)
Read records in specified namespace, set and partition filter.void
setWhitelist(AdminPolicy policy, String roleName, List<String> whitelist)
Set IP address whitelist for a role.void
touch(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key)
Asynchronously reset record's time to expiration using the policy's expiration.void
touch(WritePolicy policy, Key key)
Reset record's time to expiration using the policy's expiration.void
truncate(InfoPolicy policy, String ns, String set, Calendar beforeLastUpdate)
Remove records in specified namespace/set efficiently.
-
Field Details
-
readPolicyDefault
Default read policy that is used when read command policy is null. -
writePolicyDefault
Default write policy that is used when write command policy is null. -
scanPolicyDefault
Default scan policy that is used when scan command policy is null. -
queryPolicyDefault
Default query policy that is used when query command policy is null. -
batchPolicyDefault
Default batch policy that is used when batch command policy is null. -
infoPolicyDefault
Default info policy that is used when info command policy is null.
-
-
Constructor Details
-
AerospikeClient
Initialize Aerospike client. If the host connection succeeds, the client will:- Add host to the cluster map
- Request host's list of other nodes in cluster
- Add these nodes to cluster map
If the connection succeeds, the client is ready to process database requests. If the connection fails, the cluster will remain in a disconnected state until the server is activated.
- Parameters:
hostname
- host nameport
- host port- Throws:
AerospikeException
- if host connection fails
-
AerospikeClient
Initialize Aerospike client. The client policy is used to set defaults and size internal data structures. If the host connection succeeds, the client will:- Add host to the cluster map
- Request host's list of other nodes in cluster
- Add these nodes to cluster map
If the connection succeeds, the client is ready to process database requests. If the connection fails and the policy's failOnInvalidHosts is true, a connection exception will be thrown. Otherwise, the cluster will remain in a disconnected state until the server is activated.
- Parameters:
policy
- client configuration parameters, pass in null for defaultshostname
- host nameport
- host port- Throws:
AerospikeException
- if host connection fails
-
AerospikeClient
Initialize Aerospike client with suitable hosts to seed the cluster map. The client policy is used to set defaults and size internal data structures. For the first host connection that succeeds, the client will:- Add host to the cluster map
- Request host's list of other nodes in cluster
- Add these nodes to cluster map
In most cases, only one host is necessary to seed the cluster. The remaining hosts are added as future seeds in case of a complete network failure.
If one connection succeeds, the client is ready to process database requests. If all connections fail and the policy's failIfNotConnected is true, a connection exception will be thrown. Otherwise, the cluster will remain in a disconnected state until the server is activated.
- Parameters:
policy
- client configuration parameters, pass in null for defaultshosts
- array of potential hosts to seed the cluster- Throws:
AerospikeException
- if all host connections fail
-
-
Method Details
-
getReadPolicyDefault
- Specified by:
getReadPolicyDefault
in interfaceIAerospikeClient
-
getWritePolicyDefault
- Specified by:
getWritePolicyDefault
in interfaceIAerospikeClient
-
getScanPolicyDefault
- Specified by:
getScanPolicyDefault
in interfaceIAerospikeClient
-
getQueryPolicyDefault
- Specified by:
getQueryPolicyDefault
in interfaceIAerospikeClient
-
getBatchPolicyDefault
- Specified by:
getBatchPolicyDefault
in interfaceIAerospikeClient
-
getInfoPolicyDefault
- Specified by:
getInfoPolicyDefault
in interfaceIAerospikeClient
-
close
public void close()Close all client connections to database server nodes.If event loops are defined, the client will send a cluster close signal to these event loops. The client instance does not initiate shutdown until the pending async commands complete. The close() method, however, will return before shutdown completes if close() is called from an event loop thread. This is done in order to prevent deadlock.
This close() method will wait for shutdown if the current thread is not an event loop thread. It's recommended to call close() from a non event loop thread for this reason.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceIAerospikeClient
-
isConnected
public final boolean isConnected()Determine if we are ready to talk to the database server cluster.- Specified by:
isConnected
in interfaceIAerospikeClient
- Returns:
true
if cluster is ready,false
if cluster is not ready
-
getNodes
Return array of active server nodes in the cluster.- Specified by:
getNodes
in interfaceIAerospikeClient
- Returns:
- array of active nodes
-
getNodeNames
Return list of active server node names in the cluster.- Specified by:
getNodeNames
in interfaceIAerospikeClient
- Returns:
- list of active node names
-
getNode
Return node given its name.- Specified by:
getNode
in interfaceIAerospikeClient
- Throws:
AerospikeException.InvalidNode
- if node does not exist.
-
getClusterStats
Return operating cluster statistics.- Specified by:
getClusterStats
in interfaceIAerospikeClient
-
getCluster
public final com.aerospike.client.cluster.Cluster getCluster()Return operating cluster.- Specified by:
getCluster
in interfaceIAerospikeClient
-
put
Write record bin(s). The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists.- Specified by:
put
in interfaceIAerospikeClient
- Parameters:
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairs- Throws:
AerospikeException
- if write fails
-
put
public final void put(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key, Bin... bins) throws AerospikeExceptionAsynchronously write record bin(s). This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists.
- Specified by:
put
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send results, pass in null for fire and forgetpolicy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairs- Throws:
AerospikeException
- if event loop registration fails
-
append
Append bin string values to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for string values.- Specified by:
append
in interfaceIAerospikeClient
- Parameters:
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairs- Throws:
AerospikeException
- if append fails
-
append
public final void append(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key, Bin... bins) throws AerospikeExceptionAsynchronously append bin string values to existing record bin values. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for string values.
- Specified by:
append
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send results, pass in null for fire and forgetpolicy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairs- Throws:
AerospikeException
- if event loop registration fails
-
prepend
Prepend bin string values to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call works only for string values.- Specified by:
prepend
in interfaceIAerospikeClient
- Parameters:
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairs- Throws:
AerospikeException
- if prepend fails
-
prepend
public final void prepend(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key, Bin... bins) throws AerospikeExceptionAsynchronously prepend bin string values to existing record bin values. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for string values.
- Specified by:
prepend
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send results, pass in null for fire and forgetpolicy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairs- Throws:
AerospikeException
- if event loop registration fails
-
add
Add integer/double bin values to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists.- Specified by:
add
in interfaceIAerospikeClient
- Parameters:
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairs- Throws:
AerospikeException
- if add fails
-
add
public final void add(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key, Bin... bins) throws AerospikeExceptionAsynchronously add integer/double bin values to existing record bin values. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists.
- Specified by:
add
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send results, pass in null for fire and forgetpolicy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairs- Throws:
AerospikeException
- if event loop registration fails
-
delete
Delete record for specified key. The policy specifies the transaction timeout.- Specified by:
delete
in interfaceIAerospikeClient
- Parameters:
policy
- delete configuration parameters, pass in null for defaultskey
- unique record identifier- Returns:
- whether record existed on server before deletion
- Throws:
AerospikeException
- if delete fails
-
delete
public final void delete(EventLoop eventLoop, DeleteListener listener, WritePolicy policy, Key key) throws AerospikeExceptionAsynchronously delete record for specified key. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The policy specifies the transaction timeout.
- Specified by:
delete
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send results, pass in null for fire and forgetpolicy
- write configuration parameters, pass in null for defaultskey
- unique record identifier- Throws:
AerospikeException
- if event loop registration fails
-
truncate
public final void truncate(InfoPolicy policy, String ns, String set, Calendar beforeLastUpdate) throws AerospikeExceptionRemove records in specified namespace/set efficiently. This method is many orders of magnitude faster than deleting records one at a time.See https://www.aerospike.com/docs/reference/info#truncate
This asynchronous server call may return before the truncation is complete. The user can still write new records after the server call returns because new records will have last update times greater than the truncate cutoff (set at the time of truncate call).
- Specified by:
truncate
in interfaceIAerospikeClient
- Parameters:
policy
- info command configuration parameters, pass in null for defaultsns
- required namespaceset
- optional set name. Pass in null to delete all sets in namespace.beforeLastUpdate
- optional delete records before record last update time. If specified, value must be before the current time. Pass in null to delete all records in namespace/set.- Throws:
AerospikeException
- if truncate fails
-
touch
Reset record's time to expiration using the policy's expiration. Fail if the record does not exist.- Specified by:
touch
in interfaceIAerospikeClient
- Parameters:
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifier- Throws:
AerospikeException
- if touch fails
-
touch
public final void touch(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key) throws AerospikeExceptionAsynchronously reset record's time to expiration using the policy's expiration. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.Fail if the record does not exist.
- Specified by:
touch
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send results, pass in null for fire and forgetpolicy
- write configuration parameters, pass in null for defaultskey
- unique record identifier- Throws:
AerospikeException
- if event loop registration fails
-
exists
Determine if a record key exists. The policy can be used to specify timeouts.- Specified by:
exists
in interfaceIAerospikeClient
- Parameters:
policy
- generic configuration parameters, pass in null for defaultskey
- unique record identifier- Returns:
- whether record exists or not
- Throws:
AerospikeException
- if command fails
-
exists
public final void exists(EventLoop eventLoop, ExistsListener listener, Policy policy, Key key) throws AerospikeExceptionAsynchronously determine if a record key exists. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The policy can be used to specify timeouts.
- Specified by:
exists
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- generic configuration parameters, pass in null for defaultskey
- unique record identifier- Throws:
AerospikeException
- if event loop registration fails
-
exists
Check if multiple record keys exist in one batch call. The returned boolean array is in positional order with the original key array order. The policy can be used to specify timeouts and maximum concurrent nodes.If a batch request to a node fails, the entire batch is cancelled.
- Specified by:
exists
in interfaceIAerospikeClient
- Parameters:
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiers- Returns:
- array key/existence status pairs
- Throws:
AerospikeException
- if command fails
-
exists
public final void exists(EventLoop eventLoop, ExistsArrayListener listener, BatchPolicy policy, Key[] keys) throws AerospikeExceptionAsynchronously check if multiple record keys exist in one batch call. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The returned boolean array is in positional order with the original key array order.
If a batch request to a node fails, the entire batch is cancelled.
- Specified by:
exists
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- unique record identifiers- Throws:
AerospikeException
- if event loop registration fails
-
exists
public final void exists(EventLoop eventLoop, ExistsSequenceListener listener, BatchPolicy policy, Key[] keys) throws AerospikeExceptionAsynchronously check if multiple record keys exist in one batch call. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.Each key's result is returned in separate onExists() calls.
If a batch request to a node fails, responses from other nodes will continue to be processed.
- Specified by:
exists
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- unique record identifiers- Throws:
AerospikeException
- if event loop registration fails
-
get
Read entire record for specified key. The policy can be used to specify timeouts.- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
policy
- generic configuration parameters, pass in null for defaultskey
- unique record identifier- Returns:
- if found, return record instance. If not found, return null.
- Throws:
AerospikeException
- if read fails
-
get
public final void get(EventLoop eventLoop, RecordListener listener, Policy policy, Key key) throws AerospikeExceptionAsynchronously read entire record for specified key. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The policy can be used to specify timeouts.
- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- generic configuration parameters, pass in null for defaultskey
- unique record identifier- Throws:
AerospikeException
- if event loop registration fails
-
get
Read record header and bins for specified key. The policy can be used to specify timeouts.- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
policy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierbinNames
- bins to retrieve- Returns:
- if found, return record instance. If not found, return null.
- Throws:
AerospikeException
- if read fails
-
get
public final void get(EventLoop eventLoop, RecordListener listener, Policy policy, Key key, String... binNames) throws AerospikeExceptionAsynchronously read record header and bins for specified key. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The policy can be used to specify timeouts.
- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierbinNames
- bins to retrieve- Throws:
AerospikeException
- if event loop registration fails
-
getHeader
Read record generation and expiration only for specified key. Bins are not read. The policy can be used to specify timeouts.- Specified by:
getHeader
in interfaceIAerospikeClient
- Parameters:
policy
- generic configuration parameters, pass in null for defaultskey
- unique record identifier- Returns:
- if found, return record instance. If not found, return null.
- Throws:
AerospikeException
- if read fails
-
getHeader
public final void getHeader(EventLoop eventLoop, RecordListener listener, Policy policy, Key key) throws AerospikeExceptionAsynchronously read record generation and expiration only for specified key. Bins are not read. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The policy can be used to specify timeouts.
- Specified by:
getHeader
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- generic configuration parameters, pass in null for defaultskey
- unique record identifier- Throws:
AerospikeException
- if event loop registration fails
-
get
Read multiple records for specified batch keys in one batch call. This method allows different namespaces/bins to be requested for each key in the batch. The returned records are located in the same list. If the BatchRead key field is not found, the corresponding record field will be null. The policy can be used to specify timeouts and maximum concurrent threads.If a batch request to a node fails, the entire batch is cancelled.
- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
policy
- batch configuration parameters, pass in null for defaultsrecords
- list of unique record identifiers and the bins to retrieve. The returned records are located in the same list.- Throws:
AerospikeException
- if read fails
-
get
public final void get(EventLoop eventLoop, BatchListListener listener, BatchPolicy policy, List<BatchRead> records) throws AerospikeExceptionAsynchronously read multiple records for specified batch keys in one batch call. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.This method allows different namespaces/bins to be requested for each key in the batch. The returned records are located in the same list. If the BatchRead key field is not found, the corresponding record field will be null. The policy can be used to specify timeouts.
If a batch request to a node fails, the entire batch is cancelled.
- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultsrecords
- list of unique record identifiers and the bins to retrieve. The returned records are located in the same list.- Throws:
AerospikeException
- if event loop registration fails
-
get
public final void get(EventLoop eventLoop, BatchSequenceListener listener, BatchPolicy policy, List<BatchRead> records) throws AerospikeExceptionAsynchronously read multiple records for specified batch keys in one batch call. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.This method allows different namespaces/bins to be requested for each key in the batch. Each record result is returned in separate onRecord() calls. If the BatchRead key field is not found, the corresponding record field will be null. The policy can be used to specify timeouts.
If a batch request to a node fails, responses from other nodes will continue to be processed.
- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultsrecords
- list of unique record identifiers and the bins to retrieve. The returned records are located in the same list.- Throws:
AerospikeException
- if event loop registration fails
-
get
Read multiple records for specified keys in one batch call. The returned records are in positional order with the original key array order. If a key is not found, the positional record will be null. The policy can be used to specify timeouts and maximum concurrent threads.If a batch request to a node fails, the entire batch is cancelled.
- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiers- Returns:
- array of records
- Throws:
AerospikeException
- if read fails
-
get
public final void get(EventLoop eventLoop, RecordArrayListener listener, BatchPolicy policy, Key[] keys) throws AerospikeExceptionAsynchronously read multiple records for specified keys in one batch call. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The returned records are in positional order with the original key array order. If a key is not found, the positional record will be null. The policy can be used to specify timeouts.
If a batch request to a node fails, the entire batch is cancelled.
- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiers- Throws:
AerospikeException
- if event loop registration fails
-
get
public final void get(EventLoop eventLoop, RecordSequenceListener listener, BatchPolicy policy, Key[] keys) throws AerospikeExceptionAsynchronously read multiple records for specified keys in one batch call. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.Each record result is returned in separate onRecord() calls. If a key is not found, the record will be null. The policy can be used to specify timeouts.
If a batch request to a node fails, responses from other nodes will continue to be processed.
- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiers- Throws:
AerospikeException
- if event loop registration fails
-
get
public final Record[] get(BatchPolicy policy, Key[] keys, String... binNames) throws AerospikeExceptionRead multiple record headers and bins for specified keys in one batch call. The returned records are in positional order with the original key array order. If a key is not found, the positional record will be null. The policy can be used to specify timeouts and maximum concurrent threads.If a batch request to a node fails, the entire batch is cancelled.
- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersbinNames
- array of bins to retrieve- Returns:
- array of records
- Throws:
AerospikeException
- if read fails
-
get
public final void get(EventLoop eventLoop, RecordArrayListener listener, BatchPolicy policy, Key[] keys, String... binNames) throws AerospikeExceptionAsynchronously read multiple record headers and bins for specified keys in one batch call. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The returned records are in positional order with the original key array order. If a key is not found, the positional record will be null. The policy can be used to specify timeouts.
If a batch request to a node fails, the entire batch is cancelled.
- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersbinNames
- array of bins to retrieve- Throws:
AerospikeException
- if event loop registration fails
-
get
public final void get(EventLoop eventLoop, RecordSequenceListener listener, BatchPolicy policy, Key[] keys, String... binNames) throws AerospikeExceptionAsynchronously read multiple record headers and bins for specified keys in one batch call. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.Each record result is returned in separate onRecord() calls. If a key is not found, the record will be null. The policy can be used to specify timeouts.
If a batch request to a node fails, responses from other nodes will continue to be processed.
- Specified by:
get
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersbinNames
- array of bins to retrieve- Throws:
AerospikeException
- if event loop registration fails
-
getHeader
Read multiple record header data for specified keys in one batch call. The returned records are in positional order with the original key array order. If a key is not found, the positional record will be null. The policy can be used to specify timeouts and maximum concurrent threads.If a batch request to a node fails, the entire batch is cancelled.
- Specified by:
getHeader
in interfaceIAerospikeClient
- Parameters:
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiers- Returns:
- array of records
- Throws:
AerospikeException
- if read fails
-
getHeader
public final void getHeader(EventLoop eventLoop, RecordArrayListener listener, BatchPolicy policy, Key[] keys) throws AerospikeExceptionAsynchronously read multiple record header data for specified keys in one batch call. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The returned records are in positional order with the original key array order. If a key is not found, the positional record will be null. The policy can be used to specify timeouts.
If a batch request to a node fails, the entire batch is cancelled.
- Specified by:
getHeader
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiers- Throws:
AerospikeException
- if event loop registration fails
-
getHeader
public final void getHeader(EventLoop eventLoop, RecordSequenceListener listener, BatchPolicy policy, Key[] keys) throws AerospikeExceptionAsynchronously read multiple record header data for specified keys in one batch call. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.Each record result is returned in separate onRecord() calls. If a key is not found, the record will be null. The policy can be used to specify timeouts.
If a batch request to a node fails, responses from other nodes will continue to be processed.
- Specified by:
getHeader
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiers- Throws:
AerospikeException
- if event loop registration fails
-
operate
public final Record operate(WritePolicy policy, Key key, Operation... operations) throws AerospikeExceptionPerform multiple read/write operations on a single key in one batch call. An example would be to add an integer value to an existing record and then read the result, all in one database call.The server executes operations in the same order as the operations array. Both scalar bin operations (Operation) and CDT bin operations (ListOperation, MapOperation) can be performed in same call.
- Specified by:
operate
in interfaceIAerospikeClient
- Parameters:
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifieroperations
- database operations to perform- Returns:
- record if there is a read in the operations list
- Throws:
AerospikeException
- if command fails
-
operate
public final void operate(EventLoop eventLoop, RecordListener listener, WritePolicy policy, Key key, Operation... operations) throws AerospikeExceptionAsynchronously perform multiple read/write operations on a single key in one batch call. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.An example would be to add an integer value to an existing record and then read the result, all in one database call.
The server executes operations in the same order as the operations array. Both scalar bin operations (Operation) and CDT bin operations (ListOperation, MapOperation) can be performed in same call.
- Specified by:
operate
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send results, pass in null for fire and forgetpolicy
- write configuration parameters, pass in null for defaultskey
- unique record identifieroperations
- database operations to perform- Throws:
AerospikeException
- if event loop registration fails
-
scanAll
public final void scanAll(ScanPolicy policy, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeExceptionRead all records in specified namespace and set. If the policy'sconcurrentNodes
is specified, each server node will be read in parallel. Otherwise, server nodes are read in series.This call will block until the scan is complete - callbacks are made within the scope of this call.
- Specified by:
scanAll
in interfaceIAerospikeClient
- Parameters:
policy
- scan configuration parameters, pass in null for defaultsnamespace
- namespace - equivalent to database namesetName
- optional set name - equivalent to database tablecallback
- read callback method - called with record databinNames
- optional bin to retrieve. All bins will be returned if not specified.- Throws:
AerospikeException
- if scan fails
-
scanAll
public final void scanAll(EventLoop eventLoop, RecordSequenceListener listener, ScanPolicy policy, String namespace, String setName, String... binNames) throws AerospikeExceptionAsynchronously read all records in specified namespace and set. If the policy'sconcurrentNodes
is specified, each server node will be read in parallel. Otherwise, server nodes are read in series.This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.
- Specified by:
scanAll
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- scan configuration parameters, pass in null for defaultsnamespace
- namespace - equivalent to database namesetName
- optional set name - equivalent to database tablebinNames
- optional bin to retrieve. All bins will be returned if not specified.- Throws:
AerospikeException
- if event loop registration fails
-
scanNode
public final void scanNode(ScanPolicy policy, String nodeName, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeExceptionRead all records in specified namespace and set for one node only. The node is specified by name.This call will block until the scan is complete - callbacks are made within the scope of this call.
- Specified by:
scanNode
in interfaceIAerospikeClient
- Parameters:
policy
- scan configuration parameters, pass in null for defaultsnodeName
- server node namenamespace
- namespace - equivalent to database namesetName
- optional set name - equivalent to database tablecallback
- read callback method - called with record databinNames
- optional bin to retrieve. All bins will be returned if not specified.- Throws:
AerospikeException
- if scan fails
-
scanNode
public final void scanNode(ScanPolicy policy, Node node, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeExceptionRead all records in specified namespace and set for one node only.This call will block until the scan is complete - callbacks are made within the scope of this call.
- Specified by:
scanNode
in interfaceIAerospikeClient
- Parameters:
policy
- scan configuration parameters, pass in null for defaultsnode
- server nodenamespace
- namespace - equivalent to database namesetName
- optional set name - equivalent to database tablecallback
- read callback method - called with record databinNames
- optional bin to retrieve. All bins will be returned if not specified.- Throws:
AerospikeException
- if scan fails
-
scanPartitions
public final void scanPartitions(ScanPolicy policy, PartitionFilter partitionFilter, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeExceptionRead records in specified namespace, set and partition filter.This call will block until the scan is complete - callbacks are made within the scope of this call.
- Specified by:
scanPartitions
in interfaceIAerospikeClient
- Parameters:
policy
- scan configuration parameters, pass in null for defaultspartitionFilter
- filter on a subset of data partitionsnamespace
- namespace - equivalent to database namesetName
- optional set name - equivalent to database tablecallback
- read callback method - called with record databinNames
- optional bin to retrieve. All bins will be returned if not specified- Throws:
AerospikeException
- if scan fails
-
scanPartitions
public final void scanPartitions(EventLoop eventLoop, RecordSequenceListener listener, ScanPolicy policy, PartitionFilter partitionFilter, String namespace, String setName, String... binNames) throws AerospikeExceptionAsynchronously read records in specified namespace, set and partition filter.This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.
- Specified by:
scanPartitions
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- scan configuration parameters, pass in null for defaultspartitionFilter
- filter on a subset of data partitionsnamespace
- namespace - equivalent to database namesetName
- optional set name - equivalent to database tablebinNames
- optional bin to retrieve. All bins will be returned if not specified.- Throws:
AerospikeException
- if event loop registration fails
-
register
public final RegisterTask register(Policy policy, String clientPath, String serverPath, Language language) throws AerospikeExceptionRegister package located in a file containing user defined functions with server. This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned RegisterTask instance.- Specified by:
register
in interfaceIAerospikeClient
- Parameters:
policy
- generic configuration parameters, pass in null for defaultsclientPath
- path of client file containing user defined functions, relative to current directoryserverPath
- path to store user defined functions on the server, relative to configured script directory.language
- language of user defined functions- Throws:
AerospikeException
- if register fails
-
register
public final RegisterTask register(Policy policy, ClassLoader resourceLoader, String resourcePath, String serverPath, Language language) throws AerospikeExceptionRegister package located in a resource containing user defined functions with server. This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned RegisterTask instance.- Specified by:
register
in interfaceIAerospikeClient
- Parameters:
policy
- generic configuration parameters, pass in null for defaultsresourceLoader
- class loader where resource is located. Example: MyClass.class.getClassLoader() or Thread.currentThread().getContextClassLoader() for webappsresourcePath
- class path where Lua resource is locatedserverPath
- path to store user defined functions on the server, relative to configured script directory.language
- language of user defined functions- Throws:
AerospikeException
- if register fails
-
registerUdfString
public final RegisterTask registerUdfString(Policy policy, String code, String serverPath, Language language) throws AerospikeExceptionRegister UDF functions located in a code string with server. Example:String code = "local function reducer(val1,val2)\n" + " return val1 + val2\n" + "end\n" + "\n" + "function sum_single_bin(stream,name)\n" + " local function mapper(rec)\n" + " return rec[name]\n" + " end\n" + " return stream : map(mapper) : reduce(reducer)\n" + "end\n"; client.registerUdfString(null, code, "mysum.lua", Language.LUA);
This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned RegisterTask instance.
- Specified by:
registerUdfString
in interfaceIAerospikeClient
- Parameters:
policy
- generic configuration parameters, pass in null for defaultscode
- code string containing user defined functions.serverPath
- path to store user defined functions on the server, relative to configured script directory.language
- language of user defined functions- Throws:
AerospikeException
- if register fails
-
removeUdf
Remove user defined function from server nodes.- Specified by:
removeUdf
in interfaceIAerospikeClient
- Parameters:
policy
- info configuration parameters, pass in null for defaultsserverPath
- location of UDF on server nodes. Example: mylua.lua- Throws:
AerospikeException
- if remove fails
-
execute
public final Object execute(WritePolicy policy, Key key, String packageName, String functionName, Value... functionArgs) throws AerospikeExceptionExecute user defined function on server and return results. The function operates on a single record. The package name is used to locate the udf file location:udf file = <server udf dir>/<package name>.lua
- Specified by:
execute
in interfaceIAerospikeClient
- Parameters:
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierpackageName
- server package name where user defined function residesfunctionName
- user defined functionfunctionArgs
- arguments passed in to user defined function- Returns:
- return value of user defined function
- Throws:
AerospikeException
- if transaction fails
-
execute
public final void execute(EventLoop eventLoop, ExecuteListener listener, WritePolicy policy, Key key, String packageName, String functionName, Value... functionArgs) throws AerospikeExceptionAsynchronously execute user defined function on server. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The function operates on a single record. The package name is used to locate the udf file location:
udf file = <server udf dir>/<package name>.lua
- Specified by:
execute
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send results, pass in null for fire and forgetpolicy
- write configuration parameters, pass in null for defaultskey
- unique record identifierpackageName
- server package name where user defined function residesfunctionName
- user defined functionfunctionArgs
- arguments passed in to user defined function- Throws:
AerospikeException
- if event loop registration fails
-
execute
public final ExecuteTask execute(WritePolicy policy, Statement statement, String packageName, String functionName, Value... functionArgs) throws AerospikeExceptionApply user defined function on records that match the statement filter. Records are not returned to the client. This asynchronous server call will return before the command is complete. The user can optionally wait for command completion by using the returned ExecuteTask instance.- Specified by:
execute
in interfaceIAerospikeClient
- Parameters:
policy
- write configuration parameters, pass in null for defaultsstatement
- record filter. Statement instance is not suitable for reuse since it's modified in this method.packageName
- server package where user defined function residesfunctionName
- function namefunctionArgs
- to pass to function name, if any- Throws:
AerospikeException
- if command fails
-
execute
public final ExecuteTask execute(WritePolicy policy, Statement statement, Operation... operations) throws AerospikeExceptionApply operations on records that match the statement filter. Records are not returned to the client. This asynchronous server call will return before the command is complete. The user can optionally wait for command completion by using the returned ExecuteTask instance.- Specified by:
execute
in interfaceIAerospikeClient
- Parameters:
policy
- write configuration parameters, pass in null for defaultsstatement
- record filter. Statement instance is not suitable for reuse since it's modified in this method.operations
- list of operations to be performed on selected records- Throws:
AerospikeException
- if command fails
-
query
Execute query on all server nodes and return record iterator. The query executor puts records on a queue in separate threads. The calling thread concurrently pops records off the queue through the record iterator.- Specified by:
query
in interfaceIAerospikeClient
- Parameters:
policy
- query configuration parameters, pass in null for defaultsstatement
- query filter. Statement instance is not suitable for reuse since it's modified in this method.- Returns:
- record iterator
- Throws:
AerospikeException
- if query fails
-
query
public final void query(EventLoop eventLoop, RecordSequenceListener listener, QueryPolicy policy, Statement statement) throws AerospikeExceptionAsynchronously execute query on all server nodes. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.Each record result is returned in separate onRecord() calls.
- Specified by:
query
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- query configuration parameters, pass in null for defaultsstatement
- query filter. Statement instance is not suitable for reuse since it's modified in this method.- Throws:
AerospikeException
- if event loop registration fails
-
queryNode
public final RecordSet queryNode(QueryPolicy policy, Statement statement, Node node) throws AerospikeExceptionExecute query on a single server node and return record iterator. The query executor puts records on a queue in a separate thread. The calling thread concurrently pops records off the queue through the record iterator.- Specified by:
queryNode
in interfaceIAerospikeClient
- Parameters:
policy
- query configuration parameters, pass in null for defaultsstatement
- query filter. Statement instance is not suitable for reuse since it's modified in this method.node
- server node to execute query- Returns:
- record iterator
- Throws:
AerospikeException
- if query fails
-
queryPartitions
public final RecordSet queryPartitions(QueryPolicy policy, Statement statement, PartitionFilter partitionFilter) throws AerospikeExceptionExecute query for specified partitions and return record iterator. The query executor puts records on a queue in separate threads. The calling thread concurrently pops records off the queue through the record iterator.- Specified by:
queryPartitions
in interfaceIAerospikeClient
- Parameters:
policy
- query configuration parameters, pass in null for defaultsstatement
- query filter. Statement instance is not suitable for reuse since it's modified in this method.partitionFilter
- filter on a subset of data partitions- Throws:
AerospikeException
- if query fails
-
queryPartitions
public final void queryPartitions(EventLoop eventLoop, RecordSequenceListener listener, QueryPolicy policy, Statement statement, PartitionFilter partitionFilter) throws AerospikeExceptionAsynchronously execute query for specified partitions. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.Each record result is returned in separate onRecord() calls.
- Specified by:
queryPartitions
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- query configuration parameters, pass in null for defaultsstatement
- query filter. Statement instance is not suitable for reuse since it's modified in this method.partitionFilter
- filter on a subset of data partitions- Throws:
AerospikeException
- if query fails
-
queryAggregate
public final ResultSet queryAggregate(QueryPolicy policy, Statement statement, String packageName, String functionName, Value... functionArgs) throws AerospikeExceptionExecute query, apply statement's aggregation function, and return result iterator. The query executor puts results on a queue in separate threads. The calling thread concurrently pops results off the queue through the result iterator.The aggregation function is called on both server and client (final reduce). Therefore, the Lua script files must also reside on both server and client. The package name is used to locate the udf file location:
udf file = <udf dir>/<package name>.lua
- Specified by:
queryAggregate
in interfaceIAerospikeClient
- Parameters:
policy
- query configuration parameters, pass in null for defaultsstatement
- query filter. Statement instance is not suitable for reuse since it's modified in this method.packageName
- server package where user defined function residesfunctionName
- aggregation function namefunctionArgs
- arguments to pass to function name, if any- Returns:
- result iterator
- Throws:
AerospikeException
- if query fails
-
queryAggregate
public final ResultSet queryAggregate(QueryPolicy policy, Statement statement) throws AerospikeExceptionExecute query, apply statement's aggregation function, and return result iterator. The aggregation function should be initialized via the statement's setAggregateFunction() and should be located in a resource or a filesystem file.The query executor puts results on a queue in separate threads. The calling thread concurrently pops results off the queue through the ResultSet iterator. The aggregation function is called on both server and client (final reduce). Therefore, the Lua script file must also reside on both server and client.
- Specified by:
queryAggregate
in interfaceIAerospikeClient
- Parameters:
policy
- query configuration parameters, pass in null for defaultsstatement
- query filter. Statement instance is not suitable for reuse since it's modified in this method.- Throws:
AerospikeException
- if query fails
-
queryAggregateNode
public final ResultSet queryAggregateNode(QueryPolicy policy, Statement statement, Node node) throws AerospikeExceptionExecute query on a single server node, apply statement's aggregation function, and return result iterator. The aggregation function should be initialized via the statement's setAggregateFunction() and should be located in a resource or a filesystem file.The query executor puts results on a queue in separate threads. The calling thread concurrently pops results off the queue through the ResultSet iterator. The aggregation function is called on both server and client (final reduce). Therefore, the Lua script file must also reside on both server and client.
- Specified by:
queryAggregateNode
in interfaceIAerospikeClient
- Parameters:
policy
- query configuration parameters, pass in null for defaultsstatement
- query filter. Statement instance is not suitable for reuse since it's modified in this method.node
- server node to execute query- Throws:
AerospikeException
- if query fails
-
createIndex
public final IndexTask createIndex(Policy policy, String namespace, String setName, String indexName, String binName, IndexType indexType) throws AerospikeExceptionCreate scalar secondary index. This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned IndexTask instance.- Specified by:
createIndex
in interfaceIAerospikeClient
- Parameters:
policy
- generic configuration parameters, pass in null for defaultsnamespace
- namespace - equivalent to database namesetName
- optional set name - equivalent to database tableindexName
- name of secondary indexbinName
- bin name that data is indexed onindexType
- underlying data type of secondary index- Throws:
AerospikeException
- if index create fails
-
createIndex
public final IndexTask createIndex(Policy policy, String namespace, String setName, String indexName, String binName, IndexType indexType, IndexCollectionType indexCollectionType) throws AerospikeExceptionCreate complex secondary index to be used on bins containing collections. This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned IndexTask instance.- Specified by:
createIndex
in interfaceIAerospikeClient
- Parameters:
policy
- generic configuration parameters, pass in null for defaultsnamespace
- namespace - equivalent to database namesetName
- optional set name - equivalent to database tableindexName
- name of secondary indexbinName
- bin name that data is indexed onindexType
- underlying data type of secondary indexindexCollectionType
- index collection type- Throws:
AerospikeException
- if index create fails
-
createIndex
public final void createIndex(EventLoop eventLoop, IndexListener listener, Policy policy, String namespace, String setName, String indexName, String binName, IndexType indexType, IndexCollectionType indexCollectionType) throws AerospikeExceptionAsynchronously create complex secondary index to be used on bins containing collections. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.- Specified by:
createIndex
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- generic configuration parameters, pass in null for defaultsnamespace
- namespace - equivalent to database namesetName
- optional set name - equivalent to database tableindexName
- name of secondary indexbinName
- bin name that data is indexed onindexType
- underlying data type of secondary indexindexCollectionType
- index collection type- Throws:
AerospikeException
- if index create fails
-
dropIndex
public final IndexTask dropIndex(Policy policy, String namespace, String setName, String indexName) throws AerospikeExceptionDelete secondary index. This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned IndexTask instance.- Specified by:
dropIndex
in interfaceIAerospikeClient
- Parameters:
policy
- generic configuration parameters, pass in null for defaultsnamespace
- namespace - equivalent to database namesetName
- optional set name - equivalent to database tableindexName
- name of secondary index- Throws:
AerospikeException
- if index drop fails
-
dropIndex
public final void dropIndex(EventLoop eventLoop, IndexListener listener, Policy policy, String namespace, String setName, String indexName) throws AerospikeExceptionAsynchronously delete secondary index. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.- Specified by:
dropIndex
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- generic configuration parameters, pass in null for defaultsnamespace
- namespace - equivalent to database namesetName
- optional set name - equivalent to database tableindexName
- name of secondary index- Throws:
AerospikeException
- if index drop fails
-
info
public final void info(EventLoop eventLoop, InfoListener listener, InfoPolicy policy, Node node, String... commands) throws AerospikeExceptionAsynchronously make info commands. This method registers the command with an event loop and returns. The event loop thread will process the command and send the results to the listener.The info protocol is a name/value pair based system, where an individual database server node is queried to determine its configuration and status. The list of supported info commands can be found at: https://www.aerospike.com/docs/reference/info/index.html
- Specified by:
info
in interfaceIAerospikeClient
- Parameters:
eventLoop
- event loop that will process the commandlistener
- where to send resultspolicy
- info configuration parameters, pass in null for defaultsnode
- server node to execute command, pass in null for random nodecommands
- list of info commands- Throws:
AerospikeException
- if info commands fail
-
createUser
public final void createUser(AdminPolicy policy, String user, String password, List<String> roles) throws AerospikeExceptionCreate user with password and roles. Clear-text password will be hashed using bcrypt before sending to server.- Specified by:
createUser
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaultsuser
- user namepassword
- user password in clear-text formatroles
- variable arguments array of role names. Predefined roles are listed inRole
- Throws:
AerospikeException
- if command fails
-
dropUser
Remove user from cluster.- Specified by:
dropUser
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaultsuser
- user name- Throws:
AerospikeException
- if command fails
-
changePassword
public final void changePassword(AdminPolicy policy, String user, String password) throws AerospikeExceptionChange user's password.- Specified by:
changePassword
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaultsuser
- user namepassword
- user password in clear-text format- Throws:
AerospikeException
- if command fails
-
grantRoles
public final void grantRoles(AdminPolicy policy, String user, List<String> roles) throws AerospikeExceptionAdd roles to user's list of roles.- Specified by:
grantRoles
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaultsuser
- user nameroles
- role names. Predefined roles are listed inRole
- Throws:
AerospikeException
- if command fails
-
revokeRoles
public final void revokeRoles(AdminPolicy policy, String user, List<String> roles) throws AerospikeExceptionRemove roles from user's list of roles.- Specified by:
revokeRoles
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaultsuser
- user nameroles
- role names. Predefined roles are listed inRole
- Throws:
AerospikeException
- if command fails
-
createRole
public final void createRole(AdminPolicy policy, String roleName, List<Privilege> privileges) throws AerospikeExceptionCreate user defined role.- Specified by:
createRole
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaultsroleName
- role nameprivileges
- privileges assigned to the role.- Throws:
AerospikeException
- if command fails
-
createRole
public final void createRole(AdminPolicy policy, String roleName, List<Privilege> privileges, List<String> whitelist) throws AerospikeExceptionCreate user defined role with optional privileges and whitelist.- Parameters:
policy
- admin configuration parameters, pass in null for defaultsroleName
- role nameprivileges
- optional list of privileges assigned to role.whitelist
- optional list of allowable IP addresses assigned to role. IP addresses can contain wildcards (ie. 10.1.2.0/24).- Throws:
AerospikeException
- if command fails
-
dropRole
Drop user defined role.- Specified by:
dropRole
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaultsroleName
- role name- Throws:
AerospikeException
- if command fails
-
grantPrivileges
public final void grantPrivileges(AdminPolicy policy, String roleName, List<Privilege> privileges) throws AerospikeExceptionGrant privileges to an user defined role.- Specified by:
grantPrivileges
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaultsroleName
- role nameprivileges
- privileges assigned to the role.- Throws:
AerospikeException
- if command fails
-
revokePrivileges
public final void revokePrivileges(AdminPolicy policy, String roleName, List<Privilege> privileges) throws AerospikeExceptionRevoke privileges from an user defined role.- Specified by:
revokePrivileges
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaultsroleName
- role nameprivileges
- privileges assigned to the role.- Throws:
AerospikeException
- if command fails
-
setWhitelist
public final void setWhitelist(AdminPolicy policy, String roleName, List<String> whitelist) throws AerospikeExceptionSet IP address whitelist for a role. If whitelist is null or empty, remove existing whitelist from role.- Parameters:
policy
- admin configuration parameters, pass in null for defaultsroleName
- role namewhitelist
- list of allowable IP addresses or null. IP addresses can contain wildcards (ie. 10.1.2.0/24).- Throws:
AerospikeException
- if command fails
-
queryUser
Retrieve roles for a given user.- Specified by:
queryUser
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaultsuser
- user name filter- Throws:
AerospikeException
- if command fails
-
queryUsers
Retrieve all users and their roles.- Specified by:
queryUsers
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaults- Throws:
AerospikeException
- if command fails
-
queryRole
Retrieve role definition.- Specified by:
queryRole
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaultsroleName
- role name filter- Throws:
AerospikeException
- if command fails
-
queryRoles
Retrieve all roles.- Specified by:
queryRoles
in interfaceIAerospikeClient
- Parameters:
policy
- admin configuration parameters, pass in null for defaults- Throws:
AerospikeException
- if command fails
-