Skip to content

Commit

Permalink
Merge pull request #154 from aerospike/stage
Browse files Browse the repository at this point in the history
C client 6.6.4
  • Loading branch information
BrianNichols authored Oct 29, 2024
2 parents 9cfb73b + c0732fa commit b4f8861
Show file tree
Hide file tree
Showing 18 changed files with 181 additions and 101 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ are also included.

### Red Hat Enterprise Linux, CentOS and Amazon Linux

$ sudo yum install openssl-devel glibc-devel autoconf automake libtool
$ sudo yum install openssl-devel glibc-devel autoconf automake libtool libz-devel

[Optional:]
$ sudo yum install gcc-c++ graphviz rpm-build

### Fedora

$ sudo yum install openssl-devel glibc-devel autoconf automake libtool
$ sudo yum install openssl-devel glibc-devel autoconf automake libtool libz-devel

[Optional:]
$ sudo yum install gcc-c++ graphviz rpm-build
Expand Down
37 changes: 21 additions & 16 deletions src/include/aerospike/as_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ as_policy_event_init(as_policy_event* policy)
}

/**
* Create new event loops with default event policy.
* Create new aerospike internal event loops with default event policy. These event loops are used
* exclusively for aerospike database commands and are not shared with the application for other
* tasks. If shared event loops are desired, use as_event_set_external_loop_capacity() and
* as_event_set_external_loop() instead.
*
* This method should only be called when async client commands will be used and the calling program
* itself is not async. If this method is used, it must be called before aerospike_connect().
* This function must be called before aerospike_connect().
*
* @param capacity Number of event loops to create.
* @return Event loop array.
Expand All @@ -178,10 +180,12 @@ AS_EXTERN as_event_loop*
as_event_create_loops(uint32_t capacity);

/**
* Create new event loops with specified event policy.
*
* This method should only be called when async client commands will be used and the calling program
* itself is not async. If this method is used, it must be called before aerospike_connect().
* Create new aerospike internal event loops with specified event policy. These event loops are used
* exclusively for aerospike database commands and are not shared with the application for other
* tasks. If shared event loops are desired, use as_event_set_external_loop_capacity() and
* as_set_external_event_loop() instead.
*
* This function must be called before aerospike_connect().
*
* @param err The as_error to be populated if an error occurs.
* @param policy Event loop configuration. Pass in NULL for default configuration.
Expand All @@ -195,12 +199,13 @@ AS_EXTERN as_status
as_create_event_loops(as_error* err, as_policy_event* policy, uint32_t capacity, as_event_loop** event_loops);

/**
* Set the number of externally created event loops. This method should be called when the
* calling program wants to share event loops with the client. This reduces resource usage and
* Set the number of aerospike external event loops. This method should be called when the
* application wants to share event loops with the client. This reduces resource usage and
* can increase performance.
*
* This method is used in conjunction with as_event_set_external_loop() to fully define the
* the external loop to the client and obtain a reference the client's event loop abstraction.
* This method is used in conjunction with as_event_set_external_loop() or
* as_set_external_event_loop() to fully define the the external loop to the client and obtain a
* reference to the client's event loop abstraction.
*
* ~~~~~~~~~~{.c}
* struct {
Expand Down Expand Up @@ -238,15 +243,15 @@ AS_EXTERN bool
as_event_set_external_loop_capacity(uint32_t capacity);

/**
* Register an external event loop with the client with default event policy.
*
* Register an aerospike external event loop with the client with default event policy.
*
* This method should be called when the calling program wants to share event loops with the client.
* This reduces resource usage and can increase performance.
*
* This method must be called in the same thread as the event loop that is being registered.
*
* This method is used in conjunction with as_event_set_external_loop_capacity() to fully define
* the external loop to the client and obtain a reference the client's event loop abstraction.
* the external loop to the client and obtain a reference to the client's event loop abstraction.
*
* ~~~~~~~~~~{.c}
* struct {
Expand Down Expand Up @@ -285,15 +290,15 @@ AS_EXTERN as_event_loop*
as_event_set_external_loop(void* loop);

/**
* Register an external event loop with the client with specified event policy.
* Register an aerospike external event loop with the client with specified event policy.
*
* This method should be called when the calling program wants to share event loops with the client.
* This reduces resource usage and can increase performance.
*
* This method must be called in the same thread as the event loop that is being registered.
*
* This method is used in conjunction with as_event_set_external_loop_capacity() to fully define
* the external loop to the client and obtain a reference the client's event loop abstraction.
* the external loop to the client and obtain a reference to the client's event loop abstraction.
*
* ~~~~~~~~~~{.c}
* struct {
Expand Down
3 changes: 2 additions & 1 deletion src/include/aerospike/as_peers.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2021 Aerospike, Inc.
* Copyright 2008-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements.
Expand Down Expand Up @@ -32,6 +32,7 @@ extern "C" {

typedef struct as_peers_s {
as_vector /* as_node* */ nodes;
as_vector /* as_node */ nodes_to_remove;
as_vector /* as_host */ invalid_hosts;
uint32_t refresh_count;
bool gen_changed;
Expand Down
8 changes: 7 additions & 1 deletion src/include/aerospike/as_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,13 @@ as_query_apply(as_query* query, const char* module, const char* function, const

/**
* Set if records should be read in pages in conjunction with max_records policy.
*
* If true, the client will save the status of all partitions after the query completes.
* The partition status can be used to resume the query if terminated early by
* error, user callback, or max_records being reached. Use as_query_set_partitions()
* or as_partition_filter_set_partitions() to resume a query.
*
* The partition status will be destroyed when as_query_destroy() is called.
*
* @relates as_query
* @ingroup query_operations
*/
Expand Down
7 changes: 6 additions & 1 deletion src/include/aerospike/as_status.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 Aerospike, Inc.
* Copyright 2008-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements.
Expand Down Expand Up @@ -280,6 +280,11 @@ typedef enum as_status_e {
*/
AEROSPIKE_LOST_CONFLICT = 28,

/**
* Write can't complete until XDR finishes shipping.
*/
AEROSPIKE_XDR_KEY_BUSY = 32,

/**
* There are no more records left for query.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/include/aerospike/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
// N: minor
// P: patch
// B: build id
#define AEROSPIKE_CLIENT_VERSION 606030000L
#define AEROSPIKE_CLIENT_VERSION 606040000L

extern char* aerospike_client_version;
16 changes: 8 additions & 8 deletions src/main/aerospike/as_cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,10 @@ as_cluster_seed_node(as_cluster* cluster, as_error* err, as_peers* peers, bool e
}

static void
as_cluster_find_nodes_to_remove(as_cluster* cluster, uint32_t refresh_count, as_vector* /* <as_node*> */ nodes_to_remove)
as_cluster_find_nodes_to_remove(as_cluster* cluster, as_peers* peers)
{
uint32_t refresh_count = peers->refresh_count;
as_vector* nodes_to_remove = &peers->nodes_to_remove;
as_nodes* nodes = cluster->nodes;

for (uint32_t i = 0; i < nodes->size; i++) {
Expand Down Expand Up @@ -810,6 +812,7 @@ static void
as_cluster_destroy_peers(as_peers* peers)
{
as_vector_destroy(&peers->nodes);
as_vector_destroy(&peers->nodes_to_remove);

as_vector* invalid_hosts = &peers->invalid_hosts;

Expand Down Expand Up @@ -860,6 +863,7 @@ as_cluster_tend(as_cluster* cluster, as_error* err, bool is_init)
as_error error_local;
as_peers peers;
as_vector_inita(&peers.nodes, sizeof(as_node*), 16);
as_vector_inita(&peers.nodes_to_remove, sizeof(as_node*), 8);
as_vector_inita(&peers.invalid_hosts, sizeof(as_host), 4);
peers.refresh_count = 0;
peers.gen_changed = false;
Expand Down Expand Up @@ -953,17 +957,13 @@ as_cluster_tend(as_cluster* cluster, as_error* err, bool is_init)
}

// Remove nodes determined by refreshed peers.
as_vector nodes_to_remove;
as_vector_inita(&nodes_to_remove, sizeof(as_node*), nodes->size);
as_cluster_find_nodes_to_remove(cluster, &peers);

as_cluster_find_nodes_to_remove(cluster, peers.refresh_count, &nodes_to_remove);

// Remove nodes in a batch.
if (nodes_to_remove.size > 0) {
as_cluster_remove_nodes(cluster, &nodes_to_remove);
if (peers.nodes_to_remove.size > 0) {
as_cluster_remove_nodes(cluster, &peers.nodes_to_remove);
nodes = cluster->nodes;
}
as_vector_destroy(&nodes_to_remove);
}

// Add peer nodes to cluster.
Expand Down
3 changes: 2 additions & 1 deletion src/main/aerospike/as_error.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 Aerospike, Inc.
* Copyright 2008-2024 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements.
Expand Down Expand Up @@ -77,6 +77,7 @@ as_error_string(as_status status)
CASE_ASSIGN(AEROSPIKE_ERR_OP_NOT_APPLICABLE);
CASE_ASSIGN(AEROSPIKE_FILTERED_OUT);
CASE_ASSIGN(AEROSPIKE_LOST_CONFLICT);
CASE_ASSIGN(AEROSPIKE_XDR_KEY_BUSY);
CASE_ASSIGN(AEROSPIKE_SECURITY_NOT_SUPPORTED);
CASE_ASSIGN(AEROSPIKE_SECURITY_NOT_ENABLED);
CASE_ASSIGN(AEROSPIKE_SECURITY_SCHEME_NOT_SUPPORTED);
Expand Down
46 changes: 27 additions & 19 deletions src/main/aerospike/as_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@
* STATIC FUNCTIONS
*****************************************************************************/

static void
as_info_decode_error(char* begin)
{
// Decode base64 message in place.
// UDF error format: <error message>;file=<file>;line=<line>;message=<base64 message>\n
char* msg = strstr(begin, "message=");

if (msg) {
msg += 8;

uint32_t src_len = (uint32_t)strlen(msg);

if (msg[src_len-1] == '\n') {
src_len--; // Ignore newline '\n' at the end
}

uint32_t trg_len = 0;

if (cf_b64_validate_and_decode_in_place((uint8_t*)msg, src_len, &trg_len)) {
msg[trg_len] = 0;
}
}
}

static as_status
as_info_parse_error(char* begin, char** message)
{
Expand Down Expand Up @@ -60,6 +84,9 @@ as_info_parse_error(char* begin, char** message)
if (rc == 0) {
rc = AEROSPIKE_ERR_SERVER;
}

// Handle new error format for "udf-put" command.
as_info_decode_error(p);
}
else {
*message = begin;
Expand All @@ -68,25 +95,6 @@ as_info_parse_error(char* begin, char** message)
return rc;
}

static void
as_info_decode_error(char* begin)
{
// Decode base64 message in place.
// UDF error format: <error message>;file=<file>;line=<line>;message=<base64 message>\n
char* msg = strstr(begin, "message=");

if (msg) {
msg += 8;

uint32_t src_len = (uint32_t)strlen(msg) - 1; // Ignore newline '\n' at the end
uint32_t trg_len = 0;

if (cf_b64_validate_and_decode_in_place((uint8_t*)msg, src_len, &trg_len)) {
msg[trg_len] = 0;
}
}
}

static bool
as_info_keep_connection(as_status status)
{
Expand Down
Loading

0 comments on commit b4f8861

Please sign in to comment.