All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Fields | Related Functions
as_config Struct Reference

Detailed Description

The as_config contains the settings for the aerospike client. Including default policies, seed hosts in the cluster and other settings.

Initialization

Before using as_config, you must first initialize it. This will setup the default values.

as_config config;
as_config_init(&config);

Once initialized, you can populate the values.

Seed Hosts

The client will require at least one seed host defined in the configuration. The seed host is defined in as_config.hosts.

as_config_add_host(&config, "127.0.0.1", 3000);

The client will iterate over the list until it connects with one of the hosts.

Policies

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:

User-Defined Function Settings

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.

strcpy(config.mod_lua.user_path, "/home/me/lua");

Definition at line 311 of file as_config.h.

#include "as_config.h"

+ Collaboration diagram for as_config:

Data Fields

uint32_t async_max_conns_per_node
 
char * cluster_id
 
uint32_t conn_timeout_ms
 
bool fail_if_not_connected
 
as_vectorhosts
 
as_addr_mapip_map
 
uint32_t ip_map_size
 
as_config_lua lua
 
uint32_t max_conns_per_node
 
char password [AS_PASSWORD_HASH_SIZE]
 
uint32_t pipe_max_conns_per_node
 
as_policies policies
 
int shm_key
 
uint32_t shm_max_namespaces
 
uint32_t shm_max_nodes
 
uint32_t shm_takeover_threshold_sec
 
uint32_t tender_interval
 
uint32_t thread_pool_size
 
as_config_tls tls
 
bool use_services_alternate
 
bool use_shm
 
char user [AS_USER_SIZE]
 

Related Functions

(Note that these are not member functions.)

void as_config_add_host (as_config *config, const char *address, uint16_t port)
 
bool as_config_add_hosts (as_config *config, const char *string, uint16_t default_port)
 
as_configas_config_init (as_config *config)
 
bool as_config_set_user (as_config *config, const char *user, const char *password)
 

Friends And Related Function Documentation

void as_config_add_host ( as_config config,
const char *  address,
uint16_t  port 
)
related

Add host to seed the cluster. The host address will be copied. The caller is responsible for the original address string.

as_config config;
as_config_init(&config);
as_config_add_host(&config, "127.0.0.1", 3000);
bool as_config_add_hosts ( as_config config,
const char *  string,
uint16_t  default_port 
)
related

Add seed host(s) from a string with format: hostname1[:tlsname1][:port1],... Hostname may also be an IP address in the following formats.

IPv4: xxx.xxx.xxx.xxx
IPv6: [xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]
IPv6: [xxxx::xxxx]

The host addresses will be copied. The caller is responsible for the original string.

as_config config;
as_config_init(&config);
as_config_add_hosts(&config, "host1,host2:3010,192.168.20.1:3020,[2001::1000]:3030", 3000);
as_config * as_config_init ( as_config config)
related

Initialize the configuration to default values.

You should do this to ensure the configuration has valid values, before populating it with custom options.

as_config config;
as_config_init(&config);
as_config_add_host(&config, "127.0.0.1", 3000);
bool as_config_set_user ( as_config config,
const char *  user,
const char *  password 
)
related

User authentication for servers with restricted access. The password will be stored by the client and sent to server in hashed format.

as_config config;
as_config_init(&config);
as_config_set_user(&config, "charlie", "mypassword");

Field Documentation

uint32_t as_config::async_max_conns_per_node

Maximum number of asynchronous (non-pipeline) connections allowed for each node. This limit will be enforced at the node/event loop level. If the value is 100 and 2 event loops are created, then each node/event loop asynchronous (non-pipeline) connection pool will have a limit of 50. Async transactions will be rejected if the limit would be exceeded. This variable is ignored if asynchronous event loops are not created. Default: 300

Definition at line 377 of file as_config.h.

char* as_config::cluster_id

Expected cluster ID. If not null, server nodes must return this cluster ID in order to join the client's view of the cluster. Should only be set when connecting to servers that support the "cluster-id" info command. Use as_config_set_cluster_id() to set this field. Default: NULL

Definition at line 335 of file as_config.h.

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 394 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 458 of file as_config.h.

as_vector* as_config::hosts

Seed hosts. Populate with one or more hosts in the cluster that you intend to connect with. Do not set directly. Use as_config_add_hosts() or as_config_add_host() to add seed hosts.

Definition at line 316 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 348 of file as_config.h.

uint32_t as_config::ip_map_size

Length of ip_map array. Default: 0

Definition at line 354 of file as_config.h.

as_config_lua as_config::lua

lua config. This is a global config even though it's located here in cluster config. This config has been left here to avoid breaking the API.

The global lua config will only be changed once on first cluster initialization. A better method for initializing lua configuration is to leave this field alone and instead call aerospike_init_lua():

// Get default global lua configuration.
// Optionally modify lua defaults.
lua.cache_enabled = <enable lua cache>;
strcpy(lua.system_path, <lua system directory>);
strcpy(lua.user_path, <lua user directory>);
// Initialize global lua configuration.

Definition at line 442 of file as_config.h.

uint32_t as_config::max_conns_per_node

Maximum number of synchronous connections allowed per server node. Synchronous transactions will go through retry logic and potentially fail with error code "AEROSPIKE_ERR_NO_MORE_CONNECTIONS" if the maximum number of connections would be exceeded.

The number of connections used per node depends on how many concurrent threads issue database commands plus sub-threads used for parallel multi-node commands (batch, scan, and query). One connection will be used for each thread.

Default: 300

Definition at line 367 of file as_config.h.

char as_config::password[AS_PASSWORD_HASH_SIZE]

Password authentication to cluster. The hashed value of password will be stored by the client and sent to server in same format. Leave empty for clusters running without restricted access.

Definition at line 327 of file as_config.h.

uint32_t as_config::pipe_max_conns_per_node

Maximum number of pipeline connections allowed for each node. This limit will be enforced at the node/event loop level. If the value is 100 and 2 event loops are created, then each node/event loop pipeline connection pool will have a limit of 50. Async transactions will be rejected if the limit would be exceeded. This variable is ignored if asynchronous event loops are not created. Default: 64

Definition at line 387 of file as_config.h.

as_policies as_config::policies

Client policies

Definition at line 418 of file as_config.h.

int as_config::shm_key

Shared memory identifier. This identifier should be the same for all applications that use the Aerospike C client. Default: 0xA6000000

Definition at line 483 of file as_config.h.

uint32_t as_config::shm_max_namespaces

Shared memory maximum number of namespaces allowed. This value is used to size the fixed shared memory segment. Leave a cushion between actual namespaces and shm_max_namespaces so new namespaces can be added without having to reboot the client. Default: 8

Definition at line 499 of file as_config.h.

uint32_t as_config::shm_max_nodes

Shared memory maximum number of server nodes allowed. This value is used to size the fixed shared memory segment. Leave a cushion between actual server node count and shm_max_nodes so new nodes can be added without having to reboot the client. Default: 16

Definition at line 491 of file as_config.h.

uint32_t as_config::shm_takeover_threshold_sec

Take over shared memory cluster tending if the cluster hasn't been tended by this threshold in seconds. Default: 30

Definition at line 506 of file as_config.h.

uint32_t as_config::tender_interval

Polling interval in milliseconds for cluster tender Default: 1000

Definition at line 400 of file as_config.h.

uint32_t as_config::thread_pool_size

Number of threads stored in underlying thread pool used by synchronous batch/scan/query commands. These commands are often sent to multiple server nodes in parallel threads. A thread pool improves performance because threads do not have to be created/destroyed for each command. Calculate your value using the following formula:

thread_pool_size = (concurrent synchronous batch/scan/query commands) * (server nodes)

If your application only uses async commands, this field can be set to zero. Default: 16

Definition at line 413 of file as_config.h.

as_config_tls as_config::tls

Definition at line 447 of file as_config.h.

bool as_config::use_services_alternate

Flag to signify if "services-alternate" should be used instead of "services" Default : false

Definition at line 464 of file as_config.h.

bool as_config::use_shm

Indicates if shared memory should be used for cluster tending. Shared memory is useful when operating in single threaded mode with multiple client processes. This model is used by wrapper languages such as PHP and Python. When enabled, the data partition maps are maintained by only one process and all other processes use these shared memory maps.

Shared memory should not be enabled for multi-threaded programs. Default: false

Definition at line 476 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 321 of file as_config.h.


The documentation for this struct was generated from the following file: