diff options
Diffstat (limited to 'database/sqlite')
-rw-r--r-- | database/sqlite/sqlite_aclk.c | 24 | ||||
-rw-r--r-- | database/sqlite/sqlite_aclk.h | 2 | ||||
-rw-r--r-- | database/sqlite/sqlite_aclk_alert.c | 63 | ||||
-rw-r--r-- | database/sqlite/sqlite_aclk_chart.c | 26 | ||||
-rw-r--r-- | database/sqlite/sqlite_aclk_node.c | 4 |
5 files changed, 28 insertions, 91 deletions
diff --git a/database/sqlite/sqlite_aclk.c b/database/sqlite/sqlite_aclk.c index 950856d9a1..4cc364a48e 100644 --- a/database/sqlite/sqlite_aclk.c +++ b/database/sqlite/sqlite_aclk.c @@ -6,7 +6,7 @@ #include "sqlite_aclk_chart.h" #include "sqlite_aclk_node.h" -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK #include "../../aclk/aclk.h" #endif @@ -36,7 +36,7 @@ uv_mutex_t aclk_async_lock; struct aclk_database_worker_config *aclk_thread_head = NULL; int retention_running = 0; -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK static void stop_retention_run() { uv_mutex_lock(&aclk_async_lock); @@ -276,7 +276,7 @@ int aclk_start_sync_thread(void *data, int argc, char **argv, char **column) void sql_aclk_sync_init(void) { -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK char *err_msg = NULL; int rc; @@ -323,7 +323,7 @@ static void timer_cb(uv_timer_t* handle) uv_stop(handle->loop); uv_update_time(handle->loop); -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK struct aclk_database_worker_config *wc = handle->data; struct aclk_database_cmd cmd; memset(&cmd, 0, sizeof(cmd)); @@ -338,7 +338,7 @@ static void timer_cb(uv_timer_t* handle) wc->cleanup_after += ACLK_DATABASE_CLEANUP_INTERVAL; } - if (aclk_use_new_cloud_arch && aclk_connected) { + if (aclk_connected) { if (wc->rotation_after && wc->rotation_after < now) { cmd.opcode = ACLK_DATABASE_UPD_RETENTION; if (!aclk_database_enq_cmd_noblock(wc, &cmd)) @@ -373,7 +373,7 @@ static void timer_cb(uv_timer_t* handle) } -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK void after_send_retention(uv_work_t *req, int status) { struct aclk_database_worker_config *wc = req->data; @@ -410,7 +410,6 @@ void aclk_database_worker(void *arg) { worker_register("ACLKSYNC"); worker_register_job_name(ACLK_DATABASE_NOOP, "noop"); -#ifdef ENABLE_NEW_CLOUD_PROTOCOL worker_register_job_name(ACLK_DATABASE_ADD_CHART, "chart add"); worker_register_job_name(ACLK_DATABASE_ADD_DIMENSION, "dimension add"); worker_register_job_name(ACLK_DATABASE_PUSH_CHART, "chart push"); @@ -420,7 +419,6 @@ void aclk_database_worker(void *arg) worker_register_job_name(ACLK_DATABASE_UPD_RETENTION, "retention check"); worker_register_job_name(ACLK_DATABASE_DIM_DELETION, "dimension delete"); worker_register_job_name(ACLK_DATABASE_ORPHAN_HOST, "node orphan"); -#endif worker_register_job_name(ACLK_DATABASE_ALARM_HEALTH_LOG, "alert log"); worker_register_job_name(ACLK_DATABASE_CLEANUP, "cleanup"); worker_register_job_name(ACLK_DATABASE_DELETE_HOST, "node delete"); @@ -479,7 +477,7 @@ void aclk_database_worker(void *arg) info("Starting ACLK sync thread for host %s -- scratch area %lu bytes", wc->host_guid, sizeof(*wc)); memset(&cmd, 0, sizeof(cmd)); -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK uv_work_t retention_work; sql_get_last_chart_sequence(wc); wc->chart_payload_count = sql_get_pending_count(wc); @@ -532,7 +530,7 @@ void aclk_database_worker(void *arg) break; // CHART / DIMENSION OPERATIONS -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK case ACLK_DATABASE_ADD_CHART: debug(D_ACLK_SYNC, "Adding chart event for %s", wc->host_guid); aclk_add_chart_event(wc, cmd); @@ -585,7 +583,7 @@ void aclk_database_worker(void *arg) debug(D_ACLK_SYNC,"Sending node info for %s", wc->uuid_str); sql_build_node_info(wc, cmd); break; -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK case ACLK_DATABASE_DIM_DELETION: debug(D_ACLK_SYNC,"Sending dimension deletion information %s", wc->uuid_str); aclk_process_dimension_deletion(wc, cmd); @@ -918,9 +916,9 @@ void sql_check_aclk_table_list(struct aclk_database_worker_config *wc) void aclk_data_rotated(void) { -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK - if (!aclk_use_new_cloud_arch || !aclk_connected) + if (!aclk_connected) return; time_t next_rotation_time = now_realtime_sec()+ACLK_DATABASE_ROTATION_DELAY; diff --git a/database/sqlite/sqlite_aclk.h b/database/sqlite/sqlite_aclk.h index 37e3d4530d..53a6b798e8 100644 --- a/database/sqlite/sqlite_aclk.h +++ b/database/sqlite/sqlite_aclk.h @@ -115,7 +115,6 @@ static inline char *get_str_from_uuid(uuid_t *uuid) enum aclk_database_opcode { ACLK_DATABASE_NOOP = 0, -#ifdef ENABLE_NEW_CLOUD_PROTOCOL ACLK_DATABASE_ADD_CHART, ACLK_DATABASE_ADD_DIMENSION, ACLK_DATABASE_PUSH_CHART, @@ -125,7 +124,6 @@ enum aclk_database_opcode { ACLK_DATABASE_UPD_RETENTION, ACLK_DATABASE_DIM_DELETION, ACLK_DATABASE_ORPHAN_HOST, -#endif ACLK_DATABASE_ALARM_HEALTH_LOG, ACLK_DATABASE_CLEANUP, ACLK_DATABASE_DELETE_HOST, diff --git a/database/sqlite/sqlite_aclk_alert.c b/database/sqlite/sqlite_aclk_alert.c index 53c6c2a651..9bbb1dc232 100644 --- a/database/sqlite/sqlite_aclk_alert.c +++ b/database/sqlite/sqlite_aclk_alert.c @@ -3,7 +3,7 @@ #include "sqlite_functions.h" #include "sqlite_aclk_alert.h" -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK #include "../../aclk/aclk_alarm_api.h" #include "../../aclk/aclk.h" #endif @@ -123,21 +123,6 @@ done: // and handle both cases int sql_queue_alarm_to_aclk(RRDHOST *host, ALARM_ENTRY *ae, int skip_filter) { - //check aclk architecture and handle old json alarm update to cloud - //include also the valid statuses for this case -#ifdef ENABLE_ACLK -#ifdef ENABLE_NEW_CLOUD_PROTOCOL - if (!aclk_use_new_cloud_arch && aclk_connected) { -#endif - - if ((ae->new_status == RRDCALC_STATUS_WARNING || ae->new_status == RRDCALC_STATUS_CRITICAL) || - ((ae->old_status == RRDCALC_STATUS_WARNING || ae->old_status == RRDCALC_STATUS_CRITICAL))) { - aclk_update_alarm(host, ae); - } -#endif -#ifdef ENABLE_NEW_CLOUD_PROTOCOL - } - if (!claimed()) return 0; @@ -196,17 +181,11 @@ bind_fail: buffer_free(sql); return 0; -#else - UNUSED(host); - UNUSED(ae); - UNUSED(skip_filter); -#endif - return 0; } int rrdcalc_status_to_proto_enum(RRDCALC_STATUS status) { -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK switch(status) { case RRDCALC_STATUS_REMOVED: return ALARM_STATUS_REMOVED; @@ -234,7 +213,7 @@ int rrdcalc_status_to_proto_enum(RRDCALC_STATUS status) void aclk_push_alert_event(struct aclk_database_worker_config *wc, struct aclk_database_cmd cmd) { -#ifndef ENABLE_NEW_CLOUD_PROTOCOL +#ifndef ENABLE_ACLK UNUSED(wc); UNUSED(cmd); #else @@ -470,7 +449,7 @@ void aclk_send_alarm_health_log(char *node_id) void aclk_push_alarm_health_log(struct aclk_database_worker_config *wc, struct aclk_database_cmd cmd) { UNUSED(cmd); -#ifndef ENABLE_NEW_CLOUD_PROTOCOL +#ifndef ENABLE_ACLK UNUSED(wc); #else int rc; @@ -595,7 +574,7 @@ void aclk_send_alarm_configuration(char *config_hash) int aclk_push_alert_config_event(struct aclk_database_worker_config *wc, struct aclk_database_cmd cmd) { UNUSED(wc); -#ifndef ENABLE_NEW_CLOUD_PROTOCOL +#ifndef ENABLE_ACLK UNUSED(cmd); #else int rc = 0; @@ -708,7 +687,6 @@ bind_fail: // Start streaming alerts void aclk_start_alert_streaming(char *node_id, uint64_t batch_id, uint64_t start_seq_id) { -#ifdef ENABLE_NEW_CLOUD_PROTOCOL if (unlikely(!node_id)) return; @@ -749,20 +727,13 @@ void aclk_start_alert_streaming(char *node_id, uint64_t batch_id, uint64_t start else log_access("ACLK STA [%s (N/A)]: ACLK synchronization thread is not active.", node_id); -#else - UNUSED(node_id); - UNUSED(start_seq_id); - UNUSED(batch_id); -#endif return; } void sql_process_queue_removed_alerts_to_aclk(struct aclk_database_worker_config *wc, struct aclk_database_cmd cmd) { UNUSED(cmd); -#ifndef ENABLE_NEW_CLOUD_PROTOCOL - UNUSED(wc); -#else + BUFFER *sql = buffer_create(1024); buffer_sprintf(sql,"insert into aclk_alert_%s (alert_unique_id, date_created) " \ @@ -778,13 +749,11 @@ void sql_process_queue_removed_alerts_to_aclk(struct aclk_database_worker_config buffer_free(sql); wc->pause_alert_updates = 0; -#endif return; } void sql_queue_removed_alerts_to_aclk(RRDHOST *host) { -#ifdef ENABLE_NEW_CLOUD_PROTOCOL if (unlikely(!host->dbsync_worker)) return; @@ -798,15 +767,11 @@ void sql_queue_removed_alerts_to_aclk(RRDHOST *host) cmd.data_param = NULL; cmd.completion = NULL; aclk_database_enq_cmd((struct aclk_database_worker_config *) host->dbsync_worker, &cmd); -#else - UNUSED(host); -#endif } void aclk_process_send_alarm_snapshot(char *node_id, char *claim_id, uint64_t snapshot_id, uint64_t sequence_id) { UNUSED(claim_id); -#ifdef ENABLE_NEW_CLOUD_PROTOCOL if (unlikely(!node_id)) return; @@ -843,11 +808,7 @@ void aclk_process_send_alarm_snapshot(char *node_id, char *claim_id, uint64_t sn aclk_database_enq_cmd(wc, &cmd); } else log_access("ACLK STA [%s (N/A)]: ACLK synchronization thread is not active.", node_id); -#else - UNUSED(node_id); - UNUSED(snapshot_id); - UNUSED(sequence_id); -#endif + return; } @@ -867,7 +828,7 @@ void aclk_mark_alert_cloud_ack(char *uuid_str, uint64_t alerts_ack_sequence_id) buffer_free(sql); } -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK void health_alarm_entry2proto_nolock(struct alarm_log_entry *alarm_log, ALARM_ENTRY *ae, RRDHOST *host) { char *edit_command = ae->source ? health_edit_command_from_source(ae->source) : strdupz("UNKNOWN=0=UNKNOWN"); @@ -917,7 +878,7 @@ void health_alarm_entry2proto_nolock(struct alarm_log_entry *alarm_log, ALARM_EN } #endif -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK static int have_recent_alarm(RRDHOST *host, uint32_t alarm_id, time_t mark) { ALARM_ENTRY *ae = host->health_log.alarms; @@ -936,7 +897,7 @@ static int have_recent_alarm(RRDHOST *host, uint32_t alarm_id, time_t mark) #define ALARM_EVENTS_PER_CHUNK 10 void aclk_push_alert_snapshot_event(struct aclk_database_worker_config *wc, struct aclk_database_cmd cmd) { -#ifndef ENABLE_NEW_CLOUD_PROTOCOL +#ifndef ENABLE_ACLK UNUSED(wc); UNUSED(cmd); #else @@ -1055,7 +1016,6 @@ void aclk_push_alert_snapshot_event(struct aclk_database_worker_config *wc, stru void sql_aclk_alert_clean_dead_entries(RRDHOST *host) { -#ifdef ENABLE_NEW_CLOUD_PROTOCOL if (!claimed()) return; @@ -1075,9 +1035,6 @@ void sql_aclk_alert_clean_dead_entries(RRDHOST *host) sqlite3_free(err_msg); } buffer_free(sql); -#else - UNUSED(host); -#endif } int get_proto_alert_status(RRDHOST *host, struct proto_alert_status *proto_alert_status) diff --git a/database/sqlite/sqlite_aclk_chart.c b/database/sqlite/sqlite_aclk_chart.c index 6679aba5a0..a71348641f 100644 --- a/database/sqlite/sqlite_aclk_chart.c +++ b/database/sqlite/sqlite_aclk_chart.c @@ -3,7 +3,7 @@ #include "sqlite_functions.h" #include "sqlite_aclk_chart.h" -#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL) +#ifdef ENABLE_ACLK #include "../../aclk/aclk_charts_api.h" #include "../../aclk/aclk.h" @@ -212,7 +212,7 @@ void aclk_process_dimension_deletion(struct aclk_database_worker_config *wc, str int rc = 0; sqlite3_stmt *res = NULL; - if (!aclk_use_new_cloud_arch || !aclk_connected) + if (!aclk_connected) return; if (unlikely(!db_meta)) @@ -843,7 +843,7 @@ void aclk_update_retention(struct aclk_database_worker_config *wc) { int rc; - if (!aclk_use_new_cloud_arch || !aclk_connected) + if (!aclk_connected) return; char *claim_id = is_agent_claimed(); @@ -1146,9 +1146,6 @@ void queue_dimension_to_aclk(RRDDIM *rd, time_t last_updated) void aclk_send_dimension_update(RRDDIM *rd) { - if (!aclk_use_new_cloud_arch) - return; - char *claim_id = is_agent_claimed(); if (unlikely(!claim_id)) return; @@ -1316,24 +1313,11 @@ void sql_check_chart_liveness(RRDSET *st) { rrdset_unlock(st); } -#endif //ENABLE_NEW_CLOUD_PROTOCOL - // ST is read locked int queue_chart_to_aclk(RRDSET *st) { -#ifndef ENABLE_NEW_CLOUD_PROTOCOL -#ifdef ENABLE_ACLK - aclk_update_chart(st->rrdhost, st->id, 1); -#else - UNUSED(st); -#endif - return 0; -#else - if (!aclk_use_new_cloud_arch && aclk_connected) { - aclk_update_chart(st->rrdhost, st->id, 1); - return 0; - } return sql_queue_chart_payload((struct aclk_database_worker_config *) st->rrdhost->dbsync_worker, st, ACLK_DATABASE_ADD_CHART); -#endif } + +#endif //ENABLE_ACLK diff --git a/database/sqlite/sqlite_aclk_node.c b/database/sqlite/sqlite_aclk_node.c index 6c7312c57f..31519f9f92 100644 --- a/database/sqlite/sqlite_aclk_node.c +++ b/database/sqlite/sqlite_aclk_node.c @@ -3,7 +3,7 @@ #include "sqlite_functions.h" #include "sqlite_aclk_node.h" -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK #include "../../aclk/aclk_charts_api.h" #endif @@ -11,7 +11,7 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat { UNUSED(cmd); -#ifdef ENABLE_NEW_CLOUD_PROTOCOL +#ifdef ENABLE_ACLK struct update_node_info node_info; if (!wc->host) |