Skip to content

Commit

Permalink
Inline short cluster/node metrics functions.
Browse files Browse the repository at this point in the history
Call as_node_add_timeout() on timeout.
  • Loading branch information
BrianNichols committed Feb 23, 2024
1 parent a12161d commit 1f0e5ef
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 95 deletions.
51 changes: 37 additions & 14 deletions src/include/aerospike/as_cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,50 +612,73 @@ as_cluster_disable_metrics(as_error* err, as_cluster* cluster);
* @private
* Increment transaction count when metrics are enabled.
*/
void
as_cluster_add_tran(as_cluster* cluster);
static inline void
as_cluster_add_tran(as_cluster* cluster)
{
if (cluster->metrics_enabled) {
as_incr_uint64(&cluster->tran_count);
}
}

/**
* @private
* Return transaction count. The value is cumulative and not reset per metrics interval.
*/
uint64_t
as_cluster_get_tran_count(const as_cluster* cluster);
static inline uint64_t
as_cluster_get_tran_count(const as_cluster* cluster)
{
return as_load_uint64(&cluster->tran_count);
}

/**
* @private
* Increment async delay queue timeout count.
*/
void
as_cluster_add_retry(as_cluster* cluster);
static inline void
as_cluster_add_retry(as_cluster* cluster)
{
as_incr_uint64(&cluster->retry_count);
}

/**
* @private
* Add transaction retry count. There can be multiple retries for a single transaction.
*/
void
as_cluster_add_retries(as_cluster* cluster, uint32_t count);
static inline void
as_cluster_add_retries(as_cluster* cluster, uint32_t count)
{
as_faa_uint64(&cluster->retry_count, count);
}

/**
* @private
* Return transaction retry count. The value is cumulative and not reset per metrics interval.
*/
uint64_t
as_cluster_get_retry_count(const as_cluster* cluster);
static inline uint64_t
as_cluster_get_retry_count(const as_cluster* cluster)
{
return as_load_uint64(&cluster->retry_count);
}

/**
* @private
* Increment async delay queue timeout count.
*/
void
as_cluster_add_delay_queue_timeout(as_cluster* cluster);
static inline void
as_cluster_add_delay_queue_timeout(as_cluster* cluster)
{
as_incr_uint64(&cluster->delay_queue_timeout_count);
}

/**
* @private
* Return async delay queue timeout count.
*/
uint64_t
as_cluster_get_delay_queue_timeout_count(const as_cluster* cluster);
static inline uint64_t
as_cluster_get_delay_queue_timeout_count(const as_cluster* cluster)
{
return as_load_uint64(&cluster->delay_queue_timeout_count);
}

/**
* @private
Expand Down
28 changes: 20 additions & 8 deletions src/include/aerospike/as_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,28 +688,40 @@ as_node_enable_metrics(as_node* node, const struct as_metrics_policy_s* policy);
/**
* Return transaction error count. The value is cumulative and not reset per metrics interval.
*/
uint64_t
as_node_get_error_count(as_node* node);
static inline uint64_t
as_node_get_error_count(as_node* node)
{
return as_load_uint64(&node->error_count);
}

/**
* Increment transaction error count. If the error is retryable, multiple errors per
* transaction may occur.
*/
void
as_node_add_error(as_node* node);
static inline void
as_node_add_error(as_node* node)
{
as_incr_uint64(&node->error_count);
}

/**
* Return transaction timeout count. The value is cumulative and not reset per metrics interval.
*/
uint64_t
as_node_get_timeout_count(as_node* node);
static inline uint64_t
as_node_get_timeout_count(as_node* node)
{
return as_load_uint64(&node->timeout_count);
}

/**
* Increment transaction timeout count. If the timeout is retryable (ie socketTimeout),
* multiple timeouts per transaction may occur.
*/
void
as_node_add_timeout(as_node* node);
static inline void
as_node_add_timeout(as_node* node)
{
as_incr_uint64(&node->timeout_count);
}

/**
* @private
Expand Down
44 changes: 0 additions & 44 deletions src/main/aerospike/as_cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,50 +655,6 @@ as_cluster_disable_metrics(as_error* err, as_cluster* cluster)
return status;
}

void
as_cluster_add_tran(as_cluster* cluster)
{
if (cluster->metrics_enabled) {
as_incr_uint64(&cluster->tran_count);
}
}

uint64_t
as_cluster_get_tran_count(const as_cluster* cluster)
{
return as_load_uint64(&cluster->tran_count);
}

void
as_cluster_add_retry(as_cluster* cluster)
{
as_incr_uint64(&cluster->retry_count);
}

void
as_cluster_add_retries(as_cluster* cluster, uint32_t count)
{
as_faa_uint64(&cluster->retry_count, count);
}

uint64_t
as_cluster_get_retry_count(const as_cluster* cluster)
{
return as_load_uint64(&cluster->retry_count);
}

void
as_cluster_add_delay_queue_timeout(as_cluster* cluster)
{
as_incr_uint64(&cluster->delay_queue_timeout_count);
}

uint64_t
as_cluster_get_delay_queue_timeout_count(const as_cluster* cluster)
{
return as_load_uint64(&cluster->delay_queue_timeout_count);
}

static as_status
as_cluster_remove_nodes(as_error* err, as_cluster* cluster, as_vector* /* <as_node*> */ nodes_to_remove)
{
Expand Down
2 changes: 2 additions & 0 deletions src/main/aerospike/as_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,8 @@ as_command_execute(as_command* cmd, as_error* err)
goto Retry;

case AEROSPIKE_ERR_TIMEOUT:
as_node_add_timeout(node);

if (is_server_timeout(err)) {
as_node_put_conn_error(node, &socket);
}
Expand Down
19 changes: 14 additions & 5 deletions src/main/aerospike/as_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,8 @@ as_event_socket_timeout(as_event_command* cmd)
return;
}

as_node_add_timeout(cmd->node);

if (cmd->pipe_listener) {
as_pipe_timeout(cmd, true);
return;
Expand All @@ -847,15 +849,15 @@ as_event_delay_timeout(as_event_command* cmd)
{
cmd->state = AS_ASYNC_STATE_QUEUE_ERROR;

if (cmd->latency_type != AS_LATENCY_TYPE_NONE) {
as_cluster_add_delay_queue_timeout(cmd->cluster);
}

as_error err;
as_error_set_message(&err, AEROSPIKE_ERR_TIMEOUT, "Delay queue timeout");

// Notify user, but do not destroy command.
as_event_notify_error(cmd, &err);
if (cmd->latency_type != AS_LATENCY_TYPE_NONE)
{
as_cluster_add_delay_queue_timeout(cmd->cluster);
}
}

void
Expand Down Expand Up @@ -887,12 +889,14 @@ as_event_process_timer(as_event_command* cmd)
void
as_event_total_timeout(as_event_command* cmd)
{
// Node should not be null at this point.
as_node_add_timeout(cmd->node);

if (cmd->pipe_listener) {
as_pipe_timeout(cmd, false);
return;
}

// Node should not be null at this point.
as_event_connection_timeout(cmd, &cmd->node->async_conn_pools[cmd->event_loop->index]);

as_error err;
Expand Down Expand Up @@ -1312,6 +1316,11 @@ as_event_response_error(as_event_command* cmd, as_error* err)
as_event_release_connection(cmd->conn, pool);
as_node_incr_error_rate(cmd->node);
break;

case AEROSPIKE_ERR_TIMEOUT:
as_node_add_timeout(cmd->node);
as_event_put_connection(cmd, pool);
break;

default:
as_event_put_connection(cmd, pool);
Expand Down
24 changes: 0 additions & 24 deletions src/main/aerospike/as_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,30 +1400,6 @@ as_node_enable_metrics(as_node* node, const as_metrics_policy* policy)
node->metrics = as_node_metrics_init(policy->latency_columns, policy->latency_shift);
}

uint64_t
as_node_get_error_count(as_node* node)
{
return as_load_uint64(&node->error_count);
}

void
as_node_add_error(as_node* node)
{
as_incr_uint64(&node->error_count);
}

uint64_t
as_node_get_timeout_count(as_node* node)
{
return as_load_uint64(&node->timeout_count);
}

void
as_node_add_timeout(as_node* node)
{
as_incr_uint64(&node->timeout_count);
}

static as_status
as_node_process_racks(as_cluster* cluster, as_error* err, as_node* node, as_vector* values)
{
Expand Down

0 comments on commit 1f0e5ef

Please sign in to comment.