diff options
author | Timotej S <6674623+underhood@users.noreply.github.com> | 2020-11-26 17:26:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-26 17:26:01 +0100 |
commit | f1db235a36d85f81c5a19a7087567405771874f7 (patch) | |
tree | f99084d252e0af0496bf4776fa2c118f15dbee1a /database | |
parent | 4f867a58e5287e54aa5ecae023868615cafb9f93 (diff) |
ACLK Child Availability Messages (#9918)
* new ACLK messages for Claiming MVP1
Diffstat (limited to 'database')
-rw-r--r-- | database/rrd.h | 8 | ||||
-rw-r--r-- | database/rrdhost.c | 6 | ||||
-rw-r--r-- | database/rrdset.c | 10 |
3 files changed, 14 insertions, 10 deletions
diff --git a/database/rrd.h b/database/rrd.h index c7bdb98e6d..fd4cae81aa 100644 --- a/database/rrd.h +++ b/database/rrd.h @@ -33,6 +33,7 @@ struct pg_cache_page_index; #include "rrdcalc.h" #include "rrdcalctemplate.h" #include "../streaming/rrdpush.h" +#include "../aclk/aclk_common.h" struct context_param { RRDDIM *rd; @@ -825,8 +826,8 @@ struct rrdhost { struct netdata_ssl stream_ssl; //Structure used to encrypt the stream #endif - netdata_mutex_t claimed_id_lock; - char *claimed_id; // Claimed ID if host has one otherwise NULL + netdata_mutex_t aclk_state_lock; + aclk_rrdhost_state aclk_state; struct rrdhost *next; }; @@ -836,6 +837,9 @@ extern RRDHOST *localhost; #define rrdhost_wrlock(host) netdata_rwlock_wrlock(&((host)->rrdhost_rwlock)) #define rrdhost_unlock(host) netdata_rwlock_unlock(&((host)->rrdhost_rwlock)) +#define rrdhost_aclk_state_lock(host) netdata_mutex_lock(&((host)->aclk_state_lock)) +#define rrdhost_aclk_state_unlock(host) netdata_mutex_unlock(&((host)->aclk_state_lock)) + // ---------------------------------------------------------------------------- // these loop macros make sure the linked list is accessed with the right lock diff --git a/database/rrdhost.c b/database/rrdhost.c index 54af0390e0..c3940c29b2 100644 --- a/database/rrdhost.c +++ b/database/rrdhost.c @@ -189,7 +189,7 @@ RRDHOST *rrdhost_create(const char *hostname, netdata_rwlock_init(&host->rrdhost_rwlock); netdata_rwlock_init(&host->labels_rwlock); - netdata_mutex_init(&host->claimed_id_lock); + netdata_mutex_init(&host->aclk_state_lock); host->system_info = system_info; @@ -870,8 +870,8 @@ void rrdhost_free(RRDHOST *host) { // ------------------------------------------------------------------------ // free it - pthread_mutex_destroy(&host->claimed_id_lock); - freez(host->claimed_id); + pthread_mutex_destroy(&host->aclk_state_lock); + freez(host->aclk_state.claimed_id); freez((void *)host->tags); free_host_labels(host->labels); freez((void *)host->os); diff --git a/database/rrdset.c b/database/rrdset.c index 24e5a5d8c2..72f216f2ee 100644 --- a/database/rrdset.c +++ b/database/rrdset.c @@ -442,7 +442,7 @@ void rrdset_delete_custom(RRDSET *st, int db_rotated) { recursively_delete_dir(st->cache_dir, "left-over chart"); #ifdef ENABLE_ACLK if ((netdata_cloud_setting) && (db_rotated || RRD_MEMORY_MODE_DBENGINE != st->rrd_memory_mode)) { - aclk_del_collector(st->rrdhost->hostname, st->plugin_name, st->module_name); + aclk_del_collector(st->rrdhost, st->plugin_name, st->module_name); aclk_update_chart(st->rrdhost, st->id, ACLK_CMD_CHARTDEL); } #endif @@ -626,14 +626,14 @@ RRDSET *rrdset_create_custom( #ifdef ENABLE_ACLK if (netdata_cloud_setting) { if (mark_rebuild & META_CHART_ACTIVATED) { - aclk_add_collector(host->hostname, st->plugin_name, st->module_name); + aclk_add_collector(host, st->plugin_name, st->module_name); } else { if (mark_rebuild & (META_PLUGIN_UPDATED | META_MODULE_UPDATED)) { aclk_del_collector( - host->hostname, mark_rebuild & META_PLUGIN_UPDATED ? old_plugin : st->plugin_name, + host, mark_rebuild & META_PLUGIN_UPDATED ? old_plugin : st->plugin_name, mark_rebuild & META_MODULE_UPDATED ? old_module : st->module_name); - aclk_add_collector(host->hostname, st->plugin_name, st->module_name); + aclk_add_collector(host, st->plugin_name, st->module_name); } } aclk_update_chart(host, st->id, ACLK_CMD_CHART); @@ -933,7 +933,7 @@ RRDSET *rrdset_create_custom( rrdhost_unlock(host); #ifdef ENABLE_ACLK if (netdata_cloud_setting) { - aclk_add_collector(host->hostname, plugin, module); + aclk_add_collector(host, plugin, module); aclk_update_chart(host, st->id, ACLK_CMD_CHART); } #endif |