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.
Modifier and Type | Field and Description |
---|---|
BatchDeletePolicy |
batchDeletePolicyDefault
Default delete policy used in batch delete commands.
|
BatchPolicy |
batchParentPolicyWriteDefault
Default parent policy used in batch write commands.
|
BatchPolicy |
batchPolicyDefault
Default parent policy used in batch read commands.
|
BatchUDFPolicy |
batchUDFPolicyDefault
Default user defined function policy used in batch UDF excecute commands.
|
BatchWritePolicy |
batchWritePolicyDefault
Default write policy used in batch operate commands.
|
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 and 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.
|
Modifier and Type | Method and 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,
CTX... ctx)
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,
CTX... ctx)
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 |
createRole(AdminPolicy policy,
String roleName,
List<Privilege> privileges,
List<String> whitelist,
int readQuota,
int writeQuota)
Create user defined role with optional privileges, whitelist and read/write quotas.
|
void |
createUser(AdminPolicy policy,
String user,
String password,
List<String> roles)
Create user with password and roles.
|
BatchResults |
delete(BatchPolicy batchPolicy,
BatchDeletePolicy deletePolicy,
Key[] keys)
Delete records for specified keys.
|
void |
delete(EventLoop eventLoop,
BatchRecordArrayListener listener,
BatchPolicy batchPolicy,
BatchDeletePolicy deletePolicy,
Key[] keys)
Asynchronously delete records for specified keys.
|
void |
delete(EventLoop eventLoop,
BatchRecordSequenceListener listener,
BatchPolicy batchPolicy,
BatchDeletePolicy deletePolicy,
Key[] keys)
Asynchronously delete records for specified keys.
|
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 |
disableMetrics()
Disable extended periodic cluster and node latency metrics.
|
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 |
enableMetrics(com.aerospike.client.metrics.MetricsPolicy policy)
Enable extended periodic cluster and node latency metrics.
|
BatchResults |
execute(BatchPolicy batchPolicy,
BatchUDFPolicy udfPolicy,
Key[] keys,
String packageName,
String functionName,
Value... functionArgs)
Execute user defined function on server for each key and return results.
|
void |
execute(EventLoop eventLoop,
BatchRecordArrayListener listener,
BatchPolicy batchPolicy,
BatchUDFPolicy udfPolicy,
Key[] keys,
String packageName,
String functionName,
Value... functionArgs)
Asynchronously execute user defined function on server for each key and return results.
|
void |
execute(EventLoop eventLoop,
BatchRecordSequenceListener listener,
BatchPolicy batchPolicy,
BatchUDFPolicy udfPolicy,
Key[] keys,
String packageName,
String functionName,
Value... functionArgs)
Asynchronously execute user defined function on server for each key and return results.
|
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 background query statement filter.
|
ExecuteTask |
execute(WritePolicy policy,
Statement statement,
String packageName,
String functionName,
Value... functionArgs)
Apply user defined function on records that match the background query statement filter.
|
boolean[] |
exists(BatchPolicy policy,
Key[] keys)
Check if multiple record keys exist in one batch call.
|
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(Policy policy,
Key key)
Determine if a record key exists.
|
Record[] |
get(BatchPolicy policy,
Key[] keys)
Read multiple records for specified keys in one batch call.
|
Record[] |
get(BatchPolicy policy,
Key[] keys,
Operation... ops)
Read multiple records for specified keys using read operations 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.
|
boolean |
get(BatchPolicy policy,
List<BatchRead> records)
Read multiple records for specified batch keys in one batch call.
|
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,
Operation... ops)
Asynchronously read multiple records for specified keys using read operations 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,
Operation... ops)
Asynchronously read multiple records for specified keys using read operations 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(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.
|
BatchDeletePolicy |
getBatchDeletePolicyDefault() |
BatchPolicy |
getBatchParentPolicyWriteDefault() |
BatchPolicy |
getBatchPolicyDefault() |
BatchUDFPolicy |
getBatchUDFPolicyDefault() |
BatchWritePolicy |
getBatchWritePolicyDefault() |
com.aerospike.client.cluster.Cluster |
getCluster()
Return operating cluster.
|
ClusterStats |
getClusterStats()
Return operating cluster statistics snapshot.
|
void |
getClusterStats(ClusterStatsListener listener)
Asynchronously return operating cluster statistics snapshot.
|
Record[] |
getHeader(BatchPolicy policy,
Key[] keys)
Read multiple record header data for specified keys in one batch call.
|
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(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.
|
BatchResults |
operate(BatchPolicy batchPolicy,
BatchWritePolicy writePolicy,
Key[] keys,
Operation... ops)
Perform read/write operations on multiple keys.
|
boolean |
operate(BatchPolicy policy,
List<BatchRecord> records)
Read/Write multiple records for specified batch keys in one batch call.
|
void |
operate(EventLoop eventLoop,
BatchOperateListListener listener,
BatchPolicy policy,
List<BatchRecord> records)
Asynchronously read/write multiple records for specified batch keys in one batch call.
|
void |
operate(EventLoop eventLoop,
BatchRecordArrayListener listener,
BatchPolicy batchPolicy,
BatchWritePolicy writePolicy,
Key[] keys,
Operation... ops)
Asynchronously perform read/write operations on multiple keys.
|
void |
operate(EventLoop eventLoop,
BatchRecordSequenceListener listener,
BatchPolicy batchPolicy,
BatchWritePolicy writePolicy,
Key[] keys,
Operation... ops)
Asynchronously perform read/write operations on multiple keys.
|
void |
operate(EventLoop eventLoop,
BatchRecordSequenceListener listener,
BatchPolicy policy,
List<BatchRecord> records)
Asynchronously read/write multiple records for specified batch keys in one batch call.
|
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.
|
void |
query(QueryPolicy policy,
Statement statement,
PartitionFilter partitionFilter,
QueryListener listener)
Execute query for specified partitions and return records via the listener.
|
void |
query(QueryPolicy policy,
Statement statement,
QueryListener listener)
Execute query on all server nodes and return records via the listener.
|
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 |
setQuotas(AdminPolicy policy,
String roleName,
int readQuota,
int writeQuota)
Set maximum reads/writes per second limits for a role.
|
void |
setWhitelist(AdminPolicy policy,
String roleName,
List<String> whitelist)
Set IP address whitelist for a role.
|
void |
setXDRFilter(InfoPolicy policy,
String datacenter,
String namespace,
Expression filter)
Set XDR filter for given datacenter name and namespace.
|
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.
|
public final Policy readPolicyDefault
public final WritePolicy writePolicyDefault
public final ScanPolicy scanPolicyDefault
public final QueryPolicy queryPolicyDefault
public final BatchPolicy batchPolicyDefault
public final BatchPolicy batchParentPolicyWriteDefault
public final BatchWritePolicy batchWritePolicyDefault
public final BatchDeletePolicy batchDeletePolicyDefault
public final BatchUDFPolicy batchUDFPolicyDefault
public final InfoPolicy infoPolicyDefault
public AerospikeClient(String hostname, int port) throws AerospikeException
- 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.
hostname
- host nameport
- host portAerospikeException
- if host connection failspublic AerospikeClient(ClientPolicy policy, String hostname, int port) throws AerospikeException
- 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.
policy
- client configuration parameters, pass in null for defaultshostname
- host nameport
- host portAerospikeException
- if host connection failspublic AerospikeClient(ClientPolicy policy, Host... hosts) throws AerospikeException
- 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.
policy
- client configuration parameters, pass in null for defaultshosts
- array of potential hosts to seed the clusterAerospikeException
- if all host connections failpublic final Policy getReadPolicyDefault()
getReadPolicyDefault
in interface IAerospikeClient
public final WritePolicy getWritePolicyDefault()
getWritePolicyDefault
in interface IAerospikeClient
public final ScanPolicy getScanPolicyDefault()
getScanPolicyDefault
in interface IAerospikeClient
public final QueryPolicy getQueryPolicyDefault()
getQueryPolicyDefault
in interface IAerospikeClient
public final BatchPolicy getBatchPolicyDefault()
getBatchPolicyDefault
in interface IAerospikeClient
public final BatchPolicy getBatchParentPolicyWriteDefault()
getBatchParentPolicyWriteDefault
in interface IAerospikeClient
public final BatchWritePolicy getBatchWritePolicyDefault()
getBatchWritePolicyDefault
in interface IAerospikeClient
public final BatchDeletePolicy getBatchDeletePolicyDefault()
getBatchDeletePolicyDefault
in interface IAerospikeClient
public final BatchUDFPolicy getBatchUDFPolicyDefault()
getBatchUDFPolicyDefault
in interface IAerospikeClient
public final InfoPolicy getInfoPolicyDefault()
getInfoPolicyDefault
in interface IAerospikeClient
public void close()
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.
close
in interface IAerospikeClient
close
in interface Closeable
close
in interface AutoCloseable
public final boolean isConnected()
isConnected
in interface IAerospikeClient
true
if cluster is ready,
false
if cluster is not readypublic final Node[] getNodes()
getNodes
in interface IAerospikeClient
public final List<String> getNodeNames()
getNodeNames
in interface IAerospikeClient
public final Node getNode(String nodeName) throws AerospikeException.InvalidNode
getNode
in interface IAerospikeClient
AerospikeException.InvalidNode
- if node does not exist.public final void enableMetrics(com.aerospike.client.metrics.MetricsPolicy policy)
enableMetrics
in interface IAerospikeClient
public final void disableMetrics()
disableMetrics
in interface IAerospikeClient
public final ClusterStats getClusterStats()
getClusterStats
in interface IAerospikeClient
public final void getClusterStats(ClusterStatsListener listener)
getClusterStats
in interface IAerospikeClient
public final com.aerospike.client.cluster.Cluster getCluster()
getCluster
in interface IAerospikeClient
public final void put(WritePolicy policy, Key key, Bin... bins) throws AerospikeException
put
in interface IAerospikeClient
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairsAerospikeException
- if write failspublic final void put(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key, Bin... bins) throws AerospikeException
The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists.
put
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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 pairsAerospikeException
- if event loop registration failspublic final void append(WritePolicy policy, Key key, Bin... bins) throws AerospikeException
append
in interface IAerospikeClient
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairsAerospikeException
- if append failspublic final void append(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key, Bin... bins) throws AerospikeException
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.
append
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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 pairsAerospikeException
- if event loop registration failspublic final void prepend(WritePolicy policy, Key key, Bin... bins) throws AerospikeException
prepend
in interface IAerospikeClient
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairsAerospikeException
- if prepend failspublic final void prepend(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key, Bin... bins) throws AerospikeException
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.
prepend
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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 pairsAerospikeException
- if event loop registration failspublic final void add(WritePolicy policy, Key key, Bin... bins) throws AerospikeException
add
in interface IAerospikeClient
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairsAerospikeException
- if add failspublic final void add(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key, Bin... bins) throws AerospikeException
The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists.
add
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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 pairsAerospikeException
- if event loop registration failspublic final boolean delete(WritePolicy policy, Key key) throws AerospikeException
delete
in interface IAerospikeClient
policy
- delete configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if delete failspublic final void delete(EventLoop eventLoop, DeleteListener listener, WritePolicy policy, Key key) throws AerospikeException
The policy specifies the transaction timeout.
delete
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send results, pass in null for fire and forgetpolicy
- write configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if event loop registration failspublic final BatchResults delete(BatchPolicy batchPolicy, BatchDeletePolicy deletePolicy, Key[] keys) throws AerospikeException
BatchRecord.resultCode
will be ResultCode.KEY_NOT_FOUND_ERROR
.
Requires server version 6.0+
delete
in interface IAerospikeClient
batchPolicy
- batch configuration parameters, pass in null for defaultsdeletePolicy
- delete configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException.BatchRecordArray
- which contains results for keys that did completeAerospikeException
public final void delete(EventLoop eventLoop, BatchRecordArrayListener listener, BatchPolicy batchPolicy, BatchDeletePolicy deletePolicy, Key[] keys) throws AerospikeException
If a key is not found, the corresponding result BatchRecord.resultCode
will be
ResultCode.KEY_NOT_FOUND_ERROR
.
Requires server version 6.0+
delete
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultsbatchPolicy
- batch configuration parameters, pass in null for defaultsdeletePolicy
- delete configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException
- if event loop registration failspublic final void delete(EventLoop eventLoop, BatchRecordSequenceListener listener, BatchPolicy batchPolicy, BatchDeletePolicy deletePolicy, Key[] keys) throws AerospikeException
Each record result is returned in separate onRecord() calls.
If a key is not found, the corresponding result BatchRecord.resultCode
will be
ResultCode.KEY_NOT_FOUND_ERROR
.
Requires server version 6.0+
delete
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultsbatchPolicy
- batch configuration parameters, pass in null for defaultsdeletePolicy
- delete configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException
- if event loop registration failspublic final void truncate(InfoPolicy policy, String ns, String set, Calendar beforeLastUpdate) throws AerospikeException
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).
truncate
in interface IAerospikeClient
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.AerospikeException
- if truncate failspublic final void touch(WritePolicy policy, Key key) throws AerospikeException
touch
in interface IAerospikeClient
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if touch failspublic final void touch(EventLoop eventLoop, WriteListener listener, WritePolicy policy, Key key) throws AerospikeException
Fail if the record does not exist.
touch
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send results, pass in null for fire and forgetpolicy
- write configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if event loop registration failspublic final boolean exists(Policy policy, Key key) throws AerospikeException
exists
in interface IAerospikeClient
policy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if command failspublic final void exists(EventLoop eventLoop, ExistsListener listener, Policy policy, Key key) throws AerospikeException
The policy can be used to specify timeouts.
exists
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if event loop registration failspublic final boolean[] exists(BatchPolicy policy, Key[] keys) throws AerospikeException
exists
in interface IAerospikeClient
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException.BatchExists
- which contains results for keys that did completeAerospikeException
public final void exists(EventLoop eventLoop, ExistsArrayListener listener, BatchPolicy policy, Key[] keys) throws AerospikeException
The returned boolean array is in positional order with the original key array order.
exists
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- unique record identifiersAerospikeException
- if event loop registration failspublic final void exists(EventLoop eventLoop, ExistsSequenceListener listener, BatchPolicy policy, Key[] keys) throws AerospikeException
Each key's result is returned in separate onExists() calls.
exists
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- unique record identifiersAerospikeException
- if event loop registration failspublic final Record get(Policy policy, Key key) throws AerospikeException
get
in interface IAerospikeClient
policy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if read failspublic final void get(EventLoop eventLoop, RecordListener listener, Policy policy, Key key) throws AerospikeException
The policy can be used to specify timeouts.
get
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if event loop registration failspublic final Record get(Policy policy, Key key, String... binNames) throws AerospikeException
get
in interface IAerospikeClient
policy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierbinNames
- bins to retrieveAerospikeException
- if read failspublic final void get(EventLoop eventLoop, RecordListener listener, Policy policy, Key key, String... binNames) throws AerospikeException
The policy can be used to specify timeouts.
get
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierbinNames
- bins to retrieveAerospikeException
- if event loop registration failspublic final Record getHeader(Policy policy, Key key) throws AerospikeException
getHeader
in interface IAerospikeClient
policy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if read failspublic final void getHeader(EventLoop eventLoop, RecordListener listener, Policy policy, Key key) throws AerospikeException
The policy can be used to specify timeouts.
getHeader
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if event loop registration failspublic final boolean get(BatchPolicy policy, List<BatchRead> records) throws AerospikeException
get
in interface IAerospikeClient
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.AerospikeException
- if read failspublic final void get(EventLoop eventLoop, BatchListListener listener, BatchPolicy policy, List<BatchRead> records) throws AerospikeException
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.
get
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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.AerospikeException
- if event loop registration failspublic final void get(EventLoop eventLoop, BatchSequenceListener listener, BatchPolicy policy, List<BatchRead> records) throws AerospikeException
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.
get
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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.AerospikeException
- if event loop registration failspublic final Record[] get(BatchPolicy policy, Key[] keys) throws AerospikeException
get
in interface IAerospikeClient
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException.BatchRecords
- which contains results for keys that did completeAerospikeException
public final void get(EventLoop eventLoop, RecordArrayListener listener, BatchPolicy policy, Key[] keys) throws AerospikeException
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.
get
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException
- if event loop registration failspublic final void get(EventLoop eventLoop, RecordSequenceListener listener, BatchPolicy policy, Key[] keys) throws AerospikeException
Each record result is returned in separate onRecord() calls. If a key is not found, the record will be null.
get
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException
- if event loop registration failspublic final Record[] get(BatchPolicy policy, Key[] keys, String... binNames) throws AerospikeException
get
in interface IAerospikeClient
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersbinNames
- array of bins to retrieveAerospikeException.BatchRecords
- which contains results for keys that did completeAerospikeException
public final void get(EventLoop eventLoop, RecordArrayListener listener, BatchPolicy policy, Key[] keys, String... binNames) throws AerospikeException
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.
get
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersbinNames
- array of bins to retrieveAerospikeException
- if event loop registration failspublic final void get(EventLoop eventLoop, RecordSequenceListener listener, BatchPolicy policy, Key[] keys, String... binNames) throws AerospikeException
Each record result is returned in separate onRecord() calls. If a key is not found, the record will be null.
get
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersbinNames
- array of bins to retrieveAerospikeException
- if event loop registration failspublic final Record[] get(BatchPolicy policy, Key[] keys, Operation... ops) throws AerospikeException
get
in interface IAerospikeClient
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersops
- array of read operations on recordAerospikeException.BatchRecords
- which contains results for keys that did completeAerospikeException
public final void get(EventLoop eventLoop, RecordArrayListener listener, BatchPolicy policy, Key[] keys, Operation... ops) throws AerospikeException
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.
get
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersops
- array of read operations on recordAerospikeException
- if event loop registration failspublic final void get(EventLoop eventLoop, RecordSequenceListener listener, BatchPolicy policy, Key[] keys, Operation... ops) throws AerospikeException
Each record result is returned in separate onRecord() calls. If a key is not found, the record will be null.
get
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersops
- array of read operations on recordAerospikeException
- if event loop registration failspublic final Record[] getHeader(BatchPolicy policy, Key[] keys) throws AerospikeException
getHeader
in interface IAerospikeClient
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException.BatchRecords
- which contains results for keys that did completeAerospikeException
public final void getHeader(EventLoop eventLoop, RecordArrayListener listener, BatchPolicy policy, Key[] keys) throws AerospikeException
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.
getHeader
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException
- if event loop registration failspublic final void getHeader(EventLoop eventLoop, RecordSequenceListener listener, BatchPolicy policy, Key[] keys) throws AerospikeException
Each record result is returned in separate onRecord() calls. If a key is not found, the record will be null.
getHeader
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException
- if event loop registration failspublic final Record operate(WritePolicy policy, Key key, Operation... operations) throws AerospikeException
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.
operate
in interface IAerospikeClient
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifieroperations
- database operations to performAerospikeException
- if command failspublic final void operate(EventLoop eventLoop, RecordListener listener, WritePolicy policy, Key key, Operation... operations) throws AerospikeException
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.
operate
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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 performAerospikeException
- if event loop registration failspublic final boolean operate(BatchPolicy policy, List<BatchRecord> records) throws AerospikeException
BatchRecord
can be BatchRead
, BatchWrite
, BatchDelete
or
BatchUDF
.
Requires server version 6.0+
operate
in interface IAerospikeClient
policy
- batch configuration parameters, pass in null for defaultsrecords
- list of unique record identifiers and read/write operationsAerospikeException
- if command failspublic final void operate(EventLoop eventLoop, BatchOperateListListener listener, BatchPolicy policy, List<BatchRecord> records) throws AerospikeException
This method allows different namespaces/bins to be requested for each key in the batch. The returned records are located in the same list.
BatchRecord
can be BatchRead
, BatchWrite
, BatchDelete
or
BatchUDF
.
Requires server version 6.0+
operate
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultsrecords
- list of unique record identifiers and read/write operationsAerospikeException
- if event loop registration failspublic final void operate(EventLoop eventLoop, BatchRecordSequenceListener listener, BatchPolicy policy, List<BatchRecord> records) throws AerospikeException
This method allows different namespaces/bins to be requested for each key in the batch. Each record result is returned in separate onRecord() calls.
BatchRecord
can be BatchRead
, BatchWrite
, BatchDelete
or
BatchUDF
.
Requires server version 6.0+
operate
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- batch configuration parameters, pass in null for defaultsrecords
- list of unique record identifiers and read/write operationsAerospikeException
- if event loop registration failspublic final BatchResults operate(BatchPolicy batchPolicy, BatchWritePolicy writePolicy, Key[] keys, Operation... ops) throws AerospikeException
BatchRecord.resultCode
will be ResultCode.KEY_NOT_FOUND_ERROR
.
Requires server version 6.0+
operate
in interface IAerospikeClient
batchPolicy
- batch configuration parameters, pass in null for defaultswritePolicy
- write configuration parameters, pass in null for defaultskeys
- array of unique record identifiersops
- read/write operations to perform. Operation.get()
is not allowed because it returns a
variable number of bins and makes it difficult (sometimes impossible) to lineup operations
with results. Instead, use Operation.get(String)
for each bin name.AerospikeException.BatchRecordArray
- which contains results for keys that did completeAerospikeException
public final void operate(EventLoop eventLoop, BatchRecordArrayListener listener, BatchPolicy batchPolicy, BatchWritePolicy writePolicy, Key[] keys, Operation... ops) throws AerospikeException
If a key is not found, the corresponding result BatchRecord.resultCode
will be
ResultCode.KEY_NOT_FOUND_ERROR
.
Requires server version 6.0+
operate
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultsbatchPolicy
- batch configuration parameters, pass in null for defaultswritePolicy
- write configuration parameters, pass in null for defaultskeys
- array of unique record identifiersops
- read/write operations to perform. Operation.get()
is not allowed because it returns a
variable number of bins and makes it difficult (sometimes impossible) to lineup operations
with results. Instead, use Operation.get(String)
for each bin name.AerospikeException
- if event loop registration failspublic final void operate(EventLoop eventLoop, BatchRecordSequenceListener listener, BatchPolicy batchPolicy, BatchWritePolicy writePolicy, Key[] keys, Operation... ops) throws AerospikeException
Each record result is returned in separate onRecord() calls.
If a key is not found, the corresponding result BatchRecord.resultCode
will be
ResultCode.KEY_NOT_FOUND_ERROR
.
Requires server version 6.0+
operate
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultsbatchPolicy
- batch configuration parameters, pass in null for defaultswritePolicy
- write configuration parameters, pass in null for defaultskeys
- array of unique record identifiersops
- read/write operations to perform. Operation.get()
is not allowed because it returns a
variable number of bins and makes it difficult (sometimes impossible) to lineup operations
with results. Instead, use Operation.get(String)
for each bin name.AerospikeException
- if event loop registration failspublic final void scanAll(ScanPolicy policy, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeException
concurrentNodes
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.
scanAll
in interface IAerospikeClient
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.AerospikeException
- if scan failspublic final void scanAll(EventLoop eventLoop, RecordSequenceListener listener, ScanPolicy policy, String namespace, String setName, String... binNames) throws AerospikeException
concurrentNodes
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.
scanAll
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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.AerospikeException
- if event loop registration failspublic final void scanNode(ScanPolicy policy, String nodeName, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeException
This call will block until the scan is complete - callbacks are made within the scope of this call.
scanNode
in interface IAerospikeClient
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.AerospikeException
- if scan failspublic final void scanNode(ScanPolicy policy, Node node, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeException
This call will block until the scan is complete - callbacks are made within the scope of this call.
scanNode
in interface IAerospikeClient
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.AerospikeException
- if scan failspublic final void scanPartitions(ScanPolicy policy, PartitionFilter partitionFilter, String namespace, String setName, ScanCallback callback, String... binNames) throws AerospikeException
This call will block until the scan is complete - callbacks are made within the scope of this call.
scanPartitions
in interface IAerospikeClient
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 specifiedAerospikeException
- if scan failspublic final void scanPartitions(EventLoop eventLoop, RecordSequenceListener listener, ScanPolicy policy, PartitionFilter partitionFilter, String namespace, String setName, String... binNames) throws AerospikeException
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.
scanPartitions
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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.AerospikeException
- if event loop registration failspublic final RegisterTask register(Policy policy, String clientPath, String serverPath, Language language) throws AerospikeException
register
in interface IAerospikeClient
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 functionsAerospikeException
- if register failspublic final RegisterTask register(Policy policy, ClassLoader resourceLoader, String resourcePath, String serverPath, Language language) throws AerospikeException
register
in interface IAerospikeClient
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 functionsAerospikeException
- if register failspublic final RegisterTask registerUdfString(Policy policy, String code, String serverPath, Language language) throws AerospikeException
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.
registerUdfString
in interface IAerospikeClient
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 functionsAerospikeException
- if register failspublic final void removeUdf(InfoPolicy policy, String serverPath) throws AerospikeException
removeUdf
in interface IAerospikeClient
policy
- info configuration parameters, pass in null for defaultsserverPath
- location of UDF on server nodes. Example: mylua.luaAerospikeException
- if remove failspublic final Object execute(WritePolicy policy, Key key, String packageName, String functionName, Value... functionArgs) throws AerospikeException
udf file = <server udf dir>/<package name>.lua
execute
in interface IAerospikeClient
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 functionAerospikeException
- if transaction failspublic final void execute(EventLoop eventLoop, ExecuteListener listener, WritePolicy policy, Key key, String packageName, String functionName, Value... functionArgs) throws AerospikeException
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
execute
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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 functionAerospikeException
- if event loop registration failspublic final BatchResults execute(BatchPolicy batchPolicy, BatchUDFPolicy udfPolicy, Key[] keys, String packageName, String functionName, Value... functionArgs) throws AerospikeException
udf file = <server udf dir>/<package name>.lua
Requires server version 6.0+
execute
in interface IAerospikeClient
batchPolicy
- batch configuration parameters, pass in null for defaultsudfPolicy
- udf configuration parameters, pass in null for defaultskeys
- array of unique record identifierspackageName
- server package name where user defined function residesfunctionName
- user defined functionfunctionArgs
- arguments passed in to user defined functionAerospikeException.BatchRecordArray
- which contains results for keys that did completeAerospikeException
public final void execute(EventLoop eventLoop, BatchRecordArrayListener listener, BatchPolicy batchPolicy, BatchUDFPolicy udfPolicy, Key[] keys, String packageName, String functionName, Value... functionArgs) throws AerospikeException
The package name is used to locate the udf file location:
udf file = <server udf dir>/<package name>.lua
Requires server version 6.0+
execute
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultsbatchPolicy
- batch configuration parameters, pass in null for defaultsudfPolicy
- udf configuration parameters, pass in null for defaultskeys
- array of unique record identifierspackageName
- server package name where user defined function residesfunctionName
- user defined functionfunctionArgs
- arguments passed in to user defined functionAerospikeException
- if command failspublic final void execute(EventLoop eventLoop, BatchRecordSequenceListener listener, BatchPolicy batchPolicy, BatchUDFPolicy udfPolicy, Key[] keys, String packageName, String functionName, Value... functionArgs) throws AerospikeException
The package name is used to locate the udf file location:
udf file = <server udf dir>/<package name>.lua
Requires server version 6.0+
execute
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultsbatchPolicy
- batch configuration parameters, pass in null for defaultsudfPolicy
- udf configuration parameters, pass in null for defaultskeys
- array of unique record identifierspackageName
- server package name where user defined function residesfunctionName
- user defined functionfunctionArgs
- arguments passed in to user defined functionAerospikeException
- if command failspublic final ExecuteTask execute(WritePolicy policy, Statement statement, String packageName, String functionName, Value... functionArgs) throws AerospikeException
execute
in interface IAerospikeClient
policy
- write configuration parameters, pass in null for defaultsstatement
- background query definitionpackageName
- server package where user defined function residesfunctionName
- function namefunctionArgs
- to pass to function name, if anyAerospikeException
- if command failspublic final ExecuteTask execute(WritePolicy policy, Statement statement, Operation... operations) throws AerospikeException
execute
in interface IAerospikeClient
policy
- write configuration parameters, pass in null for defaultsstatement
- background query definitionoperations
- list of operations to be performed on selected recordsAerospikeException
- if command failspublic final RecordSet query(QueryPolicy policy, Statement statement) throws AerospikeException
This method is not recommended for paginated queries when the user does not iterate through
all records in the RecordSet. In this case, there is a lag between when the client marks the
last record retrieved from the server and when the record is retrieved from the RecordSet.
For this case, use query(QueryPolicy, Statement, QueryListener)
which uses a listener
callback (without a buffer) instead of a RecordSet.
query
in interface IAerospikeClient
policy
- query configuration parameters, pass in null for defaultsstatement
- query definitionAerospikeException
- if query failspublic final void query(EventLoop eventLoop, RecordSequenceListener listener, QueryPolicy policy, Statement statement) throws AerospikeException
Each record result is returned in separate onRecord() calls.
query
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- query configuration parameters, pass in null for defaultsstatement
- query definitionAerospikeException
- if event loop registration failspublic final void query(QueryPolicy policy, Statement statement, QueryListener listener) throws AerospikeException
If QueryPolicy.maxConcurrentNodes
is not 1, the supplied
listener must handle shared data in a thread-safe manner, because the listener will be called
by multiple query threads (one thread per node) in parallel.
Requires server version 6.0+ if using a secondary index query.
query
in interface IAerospikeClient
policy
- query configuration parameters, pass in null for defaultsstatement
- query definitionlistener
- where to send resultsAerospikeException
- if query failspublic final void query(QueryPolicy policy, Statement statement, PartitionFilter partitionFilter, QueryListener listener) throws AerospikeException
If QueryPolicy.maxConcurrentNodes
is not 1, the supplied
listener must handle shared data in a thread-safe manner, because the listener will be called
by multiple query threads (one thread per node) in parallel.
The completion status of all partitions is stored in the partitionFilter when the query terminates. This partitionFilter can then be used to resume an incomplete query at a later time. This is the preferred method for query terminate/resume functionality.
Requires server version 6.0+ if using a secondary index query.
query
in interface IAerospikeClient
policy
- query configuration parameters, pass in null for defaultsstatement
- query definitionpartitionFilter
- data partition filter. Set to
PartitionFilter.all()
for all partitions.listener
- where to send resultsAerospikeException
- if query failspublic final RecordSet queryNode(QueryPolicy policy, Statement statement, Node node) throws AerospikeException
queryNode
in interface IAerospikeClient
policy
- query configuration parameters, pass in null for defaultsstatement
- query definitionnode
- server node to execute queryAerospikeException
- if query failspublic final RecordSet queryPartitions(QueryPolicy policy, Statement statement, PartitionFilter partitionFilter) throws AerospikeException
Requires server version 6.0+ if using a secondary index query.
queryPartitions
in interface IAerospikeClient
policy
- query configuration parameters, pass in null for defaultsstatement
- query definitionpartitionFilter
- filter on a subset of data partitionsAerospikeException
- if query failspublic final void queryPartitions(EventLoop eventLoop, RecordSequenceListener listener, QueryPolicy policy, Statement statement, PartitionFilter partitionFilter) throws AerospikeException
Each record result is returned in separate onRecord() calls.
Requires server version 6.0+ if using a secondary index query.
queryPartitions
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- where to send resultspolicy
- query configuration parameters, pass in null for defaultsstatement
- query definitionpartitionFilter
- filter on a subset of data partitionsAerospikeException
- if query failspublic final ResultSet queryAggregate(QueryPolicy policy, Statement statement, String packageName, String functionName, Value... functionArgs) throws AerospikeException
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
queryAggregate
in interface IAerospikeClient
policy
- query configuration parameters, pass in null for defaultsstatement
- query definitionpackageName
- server package where user defined function residesfunctionName
- aggregation function namefunctionArgs
- arguments to pass to function name, if anyAerospikeException
- if query failspublic final ResultSet queryAggregate(QueryPolicy policy, Statement statement) throws AerospikeException
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.
queryAggregate
in interface IAerospikeClient
policy
- query configuration parameters, pass in null for defaultsstatement
- query definitionAerospikeException
- if query failspublic final ResultSet queryAggregateNode(QueryPolicy policy, Statement statement, Node node) throws AerospikeException
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.
queryAggregateNode
in interface IAerospikeClient
policy
- query configuration parameters, pass in null for defaultsstatement
- query definitionnode
- server node to execute queryAerospikeException
- if query failspublic final IndexTask createIndex(Policy policy, String namespace, String setName, String indexName, String binName, IndexType indexType) throws AerospikeException
createIndex
in interface IAerospikeClient
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 indexAerospikeException
- if index create failspublic final IndexTask createIndex(Policy policy, String namespace, String setName, String indexName, String binName, IndexType indexType, IndexCollectionType indexCollectionType, CTX... ctx) throws AerospikeException
createIndex
in interface IAerospikeClient
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 typectx
- optional context to index on elements within a CDTAerospikeException
- if index create failspublic final void createIndex(EventLoop eventLoop, IndexListener listener, Policy policy, String namespace, String setName, String indexName, String binName, IndexType indexType, IndexCollectionType indexCollectionType, CTX... ctx) throws AerospikeException
createIndex
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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 typectx
- optional context to index on elements within a CDTAerospikeException
- if index create failspublic final IndexTask dropIndex(Policy policy, String namespace, String setName, String indexName) throws AerospikeException
dropIndex
in interface IAerospikeClient
policy
- generic configuration parameters, pass in null for defaultsnamespace
- namespace - equivalent to database namesetName
- optional set name - equivalent to database tableindexName
- name of secondary indexAerospikeException
- if index drop failspublic final void dropIndex(EventLoop eventLoop, IndexListener listener, Policy policy, String namespace, String setName, String indexName) throws AerospikeException
dropIndex
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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 indexAerospikeException
- if index drop failspublic final void info(EventLoop eventLoop, InfoListener listener, InfoPolicy policy, Node node, String... commands) throws AerospikeException
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
info
in interface IAerospikeClient
eventLoop
- event loop that will process the command. If NULL, the event
loop will be chosen by round-robin.listener
- 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 commandsAerospikeException
- if info commands failpublic final void setXDRFilter(InfoPolicy policy, String datacenter, String namespace, Expression filter) throws AerospikeException
setXDRFilter
in interface IAerospikeClient
policy
- info configuration parameters, pass in null for defaultsdatacenter
- XDR datacenter namenamespace
- namespace - equivalent to database namefilter
- expression filterAerospikeException
- if command failspublic final void createUser(AdminPolicy policy, String user, String password, List<String> roles) throws AerospikeException
createUser
in interface IAerospikeClient
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 in Role
AerospikeException
- if command failspublic final void dropUser(AdminPolicy policy, String user) throws AerospikeException
dropUser
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsuser
- user nameAerospikeException
- if command failspublic final void changePassword(AdminPolicy policy, String user, String password) throws AerospikeException
changePassword
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsuser
- user namepassword
- user password in clear-text formatAerospikeException
- if command failspublic final void grantRoles(AdminPolicy policy, String user, List<String> roles) throws AerospikeException
grantRoles
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsuser
- user nameroles
- role names. Predefined roles are listed in Role
AerospikeException
- if command failspublic final void revokeRoles(AdminPolicy policy, String user, List<String> roles) throws AerospikeException
revokeRoles
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsuser
- user nameroles
- role names. Predefined roles are listed in Role
AerospikeException
- if command failspublic final void createRole(AdminPolicy policy, String roleName, List<Privilege> privileges) throws AerospikeException
createRole
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsroleName
- role nameprivileges
- privileges assigned to the role.AerospikeException
- if command failspublic final void createRole(AdminPolicy policy, String roleName, List<Privilege> privileges, List<String> whitelist) throws AerospikeException
createRole
in interface IAerospikeClient
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).AerospikeException
- if command failspublic final void createRole(AdminPolicy policy, String roleName, List<Privilege> privileges, List<String> whitelist, int readQuota, int writeQuota) throws AerospikeException
createRole
in interface IAerospikeClient
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).readQuota
- optional maximum reads per second limit, pass in zero for no limit.writeQuota
- optional maximum writes per second limit, pass in zero for no limit.AerospikeException
- if command failspublic final void dropRole(AdminPolicy policy, String roleName) throws AerospikeException
dropRole
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsroleName
- role nameAerospikeException
- if command failspublic final void grantPrivileges(AdminPolicy policy, String roleName, List<Privilege> privileges) throws AerospikeException
grantPrivileges
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsroleName
- role nameprivileges
- privileges assigned to the role.AerospikeException
- if command failspublic final void revokePrivileges(AdminPolicy policy, String roleName, List<Privilege> privileges) throws AerospikeException
revokePrivileges
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsroleName
- role nameprivileges
- privileges assigned to the role.AerospikeException
- if command failspublic final void setWhitelist(AdminPolicy policy, String roleName, List<String> whitelist) throws AerospikeException
setWhitelist
in interface IAerospikeClient
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).AerospikeException
- if command failspublic final void setQuotas(AdminPolicy policy, String roleName, int readQuota, int writeQuota) throws AerospikeException
setQuotas
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsroleName
- role namereadQuota
- maximum reads per second limit, pass in zero for no limit.writeQuota
- maximum writes per second limit, pass in zero for no limit.AerospikeException
- if command failspublic final User queryUser(AdminPolicy policy, String user) throws AerospikeException
queryUser
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsuser
- user name filterAerospikeException
- if command failspublic final List<User> queryUsers(AdminPolicy policy) throws AerospikeException
queryUsers
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsAerospikeException
- if command failspublic final Role queryRole(AdminPolicy policy, String roleName) throws AerospikeException
queryRole
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsroleName
- role name filterAerospikeException
- if command failspublic final List<Role> queryRoles(AdminPolicy policy) throws AerospikeException
queryRoles
in interface IAerospikeClient
policy
- admin configuration parameters, pass in null for defaultsAerospikeException
- if command failsCopyright © 2012–2023 Aerospike, Inc. All rights reserved.