public interface IAerospikeClient extends Closeable
Modifier and Type | Method and Description |
---|---|
void |
add(WritePolicy policy,
Key key,
Bin... bins)
Add integer bin 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.
|
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 |
createUser(AdminPolicy policy,
String user,
String password,
List<String> roles)
Create user with password and roles.
|
boolean |
delete(WritePolicy policy,
Key key)
Delete record for specified key.
|
void |
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.
|
Object |
execute(WritePolicy policy,
Key key,
String packageName,
String functionName,
Value... args)
Execute user defined function on server and return results.
|
ExecuteTask |
execute(WritePolicy policy,
Statement statement,
String packageName,
String functionName,
Value... functionArgs)
Apply user defined function on records that match the statement filter.
|
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.
|
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() |
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() |
LargeList |
getLargeList(WritePolicy policy,
Key key,
String binName)
Initialize large list operator.
|
LargeMap |
getLargeMap(WritePolicy policy,
Key key,
String binName,
String userModule)
Initialize large map operator.
|
LargeSet |
getLargeSet(WritePolicy policy,
Key key,
String binName,
String userModule)
Initialize large set operator.
|
LargeStack |
getLargeStack(WritePolicy policy,
Key key,
String binName,
String userModule)
Initialize large stack operator.
|
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.
|
boolean |
isConnected()
Determine if we are ready to talk to the database server cluster.
|
Record |
operate(WritePolicy policy,
Key key,
Operation... operations)
Perform multiple read/write operations on a single key in one batch call.
|
void |
prepend(WritePolicy policy,
Key key,
Bin... bins)
Prepend bin string values to existing record bin values.
|
void |
put(WritePolicy policy,
Key key,
Bin... bins)
Write record bin(s).
|
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.
|
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(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 |
touch(WritePolicy policy,
Key key)
Reset record's time to expiration using the policy's expiration.
|
Policy getReadPolicyDefault()
WritePolicy getWritePolicyDefault()
ScanPolicy getScanPolicyDefault()
QueryPolicy getQueryPolicyDefault()
BatchPolicy getBatchPolicyDefault()
InfoPolicy getInfoPolicyDefault()
void close()
close
in interface AutoCloseable
close
in interface Closeable
boolean isConnected()
true
if cluster is ready,
false
if cluster is not readyNode[] getNodes()
List<String> getNodeNames()
Node getNode(String nodeName) throws AerospikeException.InvalidNode
AerospikeException.InvalidNode
- if node does not exist.void put(WritePolicy policy, Key key, Bin... bins) throws AerospikeException
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairsAerospikeException
- if write failsvoid append(WritePolicy policy, Key key, Bin... bins) throws AerospikeException
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairsAerospikeException
- if append failsvoid prepend(WritePolicy policy, Key key, Bin... bins) throws AerospikeException
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairsAerospikeException
- if prepend failsvoid add(WritePolicy policy, Key key, Bin... bins) throws AerospikeException
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbins
- array of bin name/value pairsAerospikeException
- if add failsboolean delete(WritePolicy policy, Key key) throws AerospikeException
policy
- delete configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if delete failsvoid touch(WritePolicy policy, Key key) throws AerospikeException
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if touch failsboolean exists(Policy policy, Key key) throws AerospikeException
policy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if command failsboolean[] exists(BatchPolicy policy, Key[] keys) throws AerospikeException
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException
- if command failsRecord get(Policy policy, Key key) throws AerospikeException
policy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if read failsRecord get(Policy policy, Key key, String... binNames) throws AerospikeException
policy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierbinNames
- bins to retrieveAerospikeException
- if read failsRecord getHeader(Policy policy, Key key) throws AerospikeException
policy
- generic configuration parameters, pass in null for defaultskey
- unique record identifierAerospikeException
- if read failsvoid get(BatchPolicy policy, List<BatchRead> records) throws AerospikeException
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 failsRecord[] get(BatchPolicy policy, Key[] keys) throws AerospikeException
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException
- if read failsRecord[] get(BatchPolicy policy, Key[] keys, String... binNames) throws AerospikeException
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersbinNames
- array of bins to retrieveAerospikeException
- if read failsRecord[] getHeader(BatchPolicy policy, Key[] keys) throws AerospikeException
policy
- batch configuration parameters, pass in null for defaultskeys
- array of unique record identifiersAerospikeException
- if read failsRecord operate(WritePolicy policy, Key key, Operation... operations) throws AerospikeException
Write operations are always performed first, regardless of operation order relative to read operations.
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifieroperations
- database operations to performAerospikeException
- if command failsvoid 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.
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.
Aerospike 2 servers ignore this parameter.AerospikeException
- if scan failsvoid 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.
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.
Aerospike 2 servers ignore this parameter.AerospikeException
- if scan failsvoid 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.
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.
Aerospike 2 servers ignore this parameter.AerospikeException
- if transaction failsLargeList getLargeList(WritePolicy policy, Key key, String binName)
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbinName
- bin nameLargeMap getLargeMap(WritePolicy policy, Key key, String binName, String userModule)
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbinName
- bin nameuserModule
- Lua function name that initializes list configuration parameters, pass null for defaultLargeSet getLargeSet(WritePolicy policy, Key key, String binName, String userModule)
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbinName
- bin nameuserModule
- Lua function name that initializes list configuration parameters, pass null for defaultLargeStack getLargeStack(WritePolicy policy, Key key, String binName, String userModule)
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierbinName
- bin nameuserModule
- Lua function name that initializes list configuration parameters, pass null for defaultRegisterTask register(Policy policy, String clientPath, String serverPath, Language language) throws AerospikeException
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 failsRegisterTask register(Policy policy, ClassLoader resourceLoader, String resourcePath, String serverPath, Language language) throws AerospikeException
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 failsRegisterTask 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.
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 failsvoid removeUdf(InfoPolicy policy, String serverPath) throws AerospikeException
policy
- info configuration parameters, pass in null for defaultsserverPath
- location of UDF on server nodes. Example: mylua.luaAerospikeException
- if remove failsObject execute(WritePolicy policy, Key key, String packageName, String functionName, Value... args) throws AerospikeException
udf file =
policy
- write configuration parameters, pass in null for defaultskey
- unique record identifierpackageName
- server package name where user defined function residesfunctionName
- user defined functionargs
- arguments passed in to user defined functionAerospikeException
- if transaction failsExecuteTask execute(WritePolicy policy, Statement statement, String packageName, String functionName, Value... functionArgs) throws AerospikeException
policy
- write configuration parameters, pass in null for defaultsstatement
- record filterpackageName
- server package where user defined function residesfunctionName
- function namefunctionArgs
- to pass to function name, if anyAerospikeException
- if command failsRecordSet query(QueryPolicy policy, Statement statement) throws AerospikeException
policy
- generic configuration parameters, pass in null for defaultsstatement
- database query commandAerospikeException
- if query failsRecordSet queryNode(QueryPolicy policy, Statement statement, Node node) throws AerospikeException
policy
- generic configuration parameters, pass in null for defaultsstatement
- database query commandnode
- server node to execute queryAerospikeException
- if query failsResultSet 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 =
policy
- generic configuration parameters, pass in null for defaultsstatement
- database query commandpackageName
- server package where user defined function residesfunctionName
- aggregation function namefunctionArgs
- arguments to pass to function name, if anyAerospikeException
- if query failsResultSet 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.
policy
- generic configuration parameters, pass in null for defaultsstatement
- database query commandAerospikeException
- if query failsResultSet 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.
policy
- generic configuration parameters, pass in null for defaultsstatement
- database query commandnode
- server node to execute queryAerospikeException
- if query failsIndexTask createIndex(Policy policy, String namespace, String setName, String indexName, String binName, IndexType indexType) throws AerospikeException
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 failsIndexTask createIndex(Policy policy, String namespace, String setName, String indexName, String binName, IndexType indexType, IndexCollectionType indexCollectionType) throws AerospikeException
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 typeAerospikeException
- if index create failsvoid dropIndex(Policy policy, String namespace, String setName, String indexName) throws AerospikeException
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 create failsvoid createUser(AdminPolicy policy, String user, String password, List<String> roles) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsuser
- user namepassword
- user password in clear-text formatroles
- variable arguments array of role names. Valid roles are listed in Role.csAerospikeException
- if command failsvoid dropUser(AdminPolicy policy, String user) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsuser
- user nameAerospikeException
- if command failsvoid changePassword(AdminPolicy policy, String user, String password) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsuser
- user namepassword
- user password in clear-text formatAerospikeException
- if command failsvoid grantRoles(AdminPolicy policy, String user, List<String> roles) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsuser
- user nameroles
- role names. Valid roles are listed in Role.csAerospikeException
- if command failsvoid revokeRoles(AdminPolicy policy, String user, List<String> roles) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsuser
- user nameroles
- role names. Valid roles are listed in Role.csAerospikeException
- if command failsvoid createRole(AdminPolicy policy, String roleName, List<Privilege> privileges) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsroleName
- role nameprivileges
- privileges assigned to the role.AerospikeException
- if command failsvoid dropRole(AdminPolicy policy, String roleName) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsroleName
- role nameAerospikeException
- if command failsvoid grantPrivileges(AdminPolicy policy, String roleName, List<Privilege> privileges) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsroleName
- role nameprivileges
- privileges assigned to the role.AerospikeException
- if command failsvoid revokePrivileges(AdminPolicy policy, String roleName, List<Privilege> privileges) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsroleName
- role nameprivileges
- privileges assigned to the role.AerospikeException
- if command failsUser queryUser(AdminPolicy policy, String user) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsuser
- user name filterAerospikeException
- if command failsList<User> queryUsers(AdminPolicy policy) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsAerospikeException
- if command failsRole queryRole(AdminPolicy policy, String roleName) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsroleName
- role name filterAerospikeException
- if command failsList<Role> queryRoles(AdminPolicy policy) throws AerospikeException
policy
- admin configuration parameters, pass in null for defaultsAerospikeException
- if command failsCopyright © 2012–2016 Aerospike, Inc. All rights reserved.