![]() |
The as_config
contains the settings for the aerospike
client. Including default policies, seed hosts in the cluster and other settings.
Before using as_config, you must first initialize it. This will setup the default values.
Once initialized, you can populate the values.
The client will require at least one seed host defined in the configuration. The seed host is defined in as_config.hosts
.
You can define up to 256 hosts for the seed. The client will iterate over the list until it connects with one of the hosts.
The configuration also defines default policies for the application. The as_config_init()
function already presets default values for the policies.
Policies define the behavior of the client, which can be global across operations, global to a single operation, or local to a single use of an operation.
Each database operation accepts a policy for that operation as an a argument. This is considered a local policy, and is a single use policy. This policy supersedes any global policy defined.
If a value of the policy is not defined, then the rule is to fallback to the global policy for that operation. If the global policy for that operation is undefined, then the global default value will be used.
If you find that you have behavior that you want every use of an operation to utilize, then you can specify the default policy in as_config.policies.
For example, the aerospike_key_put()
operation takes an as_policy_write
policy. If you find yourself setting the key
policy value for every call to aerospike_key_put()
, then you may find it beneficial to set the global as_policy_write
in as_policies.write
, which all write operations will use.
If you find that you want to use a policy value across all operations, then you may find it beneficial to set the default policy value for that policy value.
For example, if you keep setting the key policy value to AS_POLICY_KEY_SEND
, then you may want to just set as_policies.key
. This will set the global default value for the policy value. So, if an global operation policy or a local operation policy does not define a value, then this value will be used.
Global default policy values:
Global operation policies:
If you are using using user-defined functions (UDF) for processing query results (i.e aggregations), then you will find it useful to set the mod_lua
settings. Of particular importance is the mod_lua.user_path
, which allows you to define a path to where the client library will look for Lua files for processing.
Definition at line 244 of file as_config.h.
#include "as_config.h"
Data Fields | |
uint32_t | conn_timeout_ms |
bool | fail_if_not_connected |
as_config_host | hosts [AS_CONFIG_HOSTS_SIZE] |
uint32_t | hosts_size |
as_addr_map * | ip_map |
uint32_t | ip_map_size |
as_config_lua | lua |
uint32_t | max_threads |
char | password [AS_PASSWORD_HASH_SIZE] |
as_policies | policies |
uint32_t | tender_interval |
char | user [AS_USER_SIZE] |
Private Attributes | |
uint32_t | max_socket_idle_sec |
Related Functions | |
(Note that these are not member functions.) | |
static void | as_config_add_host (as_config *config, const char *addr, uint16_t port) |
as_config * | as_config_init (as_config *c) |
bool | as_config_set_user (as_config *config, const char *user, const char *password) |
|
related |
Add host to seed the cluster.
Definition at line 375 of file as_config.h.
References as_config_host::addr, hosts, hosts_size, and as_config_host::port.
Initialize the configuration to default values.
You should do this to ensure the configuration has valid values, before populating it with custom options.
c | The configuration to initialize. |
|
related |
User authentication for servers with restricted access. The password will be stored by the client and sent to server in hashed format.
uint32_t as_config::conn_timeout_ms |
Initial host connection timeout in milliseconds. The timeout when opening a connection to the server host for the first time. Default: 1000
Definition at line 297 of file as_config.h.
bool as_config::fail_if_not_connected |
Action to perform if client fails to connect to seed hosts.
If fail_if_not_connected is true (default), the cluster creation will fail when all seed hosts are not reachable.
If fail_if_not_connected is false, an empty cluster will be created and the client will automatically connect when Aerospike server becomes available.
Definition at line 336 of file as_config.h.
as_config_host as_config::hosts[AS_CONFIG_HOSTS_SIZE] |
(seed) hosts Populate with one or more hosts in the cluster that you intend to connect with.
Definition at line 315 of file as_config.h.
uint32_t as_config::hosts_size |
Count of entries in hosts array.
Definition at line 308 of file as_config.h.
as_addr_map* as_config::ip_map |
A IP translation table is used in cases where different clients use different server IP addresses. This may be necessary when using clients from both inside and outside a local area network. Default is no translation.
The key is the IP address returned from friend info requests to other servers. The value is the real IP address used to connect to the server.
A deep copy of ip_map is performed in aerospike_connect(). The caller is responsible for memory deallocation of the original data structure.
Definition at line 268 of file as_config.h.
uint32_t as_config::ip_map_size |
Length of ip_map array. Default: 0
Definition at line 274 of file as_config.h.
as_config_lua as_config::lua |
lua config
Definition at line 325 of file as_config.h.
|
private |
Not currently used. Maximum socket idle in seconds. Socket connection pools will discard sockets that have been idle longer than the maximum. Default: 14
Definition at line 290 of file as_config.h.
uint32_t as_config::max_threads |
Estimate of incoming threads concurrently using synchronous methods in the client instance. This field is used to size the synchronous connection pool for each server node. Default: 300
Definition at line 281 of file as_config.h.
char as_config::password[AS_PASSWORD_HASH_SIZE] |
Password authentication to cluster. The password will be stored by the client and sent to server in hashed format. Leave empty for clusters running without restricted access.
Definition at line 255 of file as_config.h.
as_policies as_config::policies |
Client policies
Definition at line 320 of file as_config.h.
uint32_t as_config::tender_interval |
Polling interval in milliseconds for cluster tender Default: 1000
Definition at line 303 of file as_config.h.
char as_config::user[AS_USER_SIZE] |
User authentication to cluster. Leave empty for clusters running without restricted access.
Definition at line 249 of file as_config.h.