diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2022-09-07 15:28:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-07 15:28:30 +0300 |
commit | 3f6a75250d8251b0142248ed2f33f7d857ee21c8 (patch) | |
tree | f8fd7544a2fb509b295e6bd5267baab6014bc787 | |
parent | 17e0676b5bb6b11ad9aec705ade05163dcc2de31 (diff) |
Obsolete RRDSET state (#13635)
* move chart_labels to rrdset
* rename chart_labels to rrdlabels
* renamed hash_id to uuid
* turned is_ar_chart into an rrdset flag
* removed rrdset state
* removed unused senders_connected member of rrdhost
* removed unused host flag RRDHOST_FLAG_MULTIHOST
* renamed rrdhost host_labels to rrdlabels
* Update exporting unit tests
Co-authored-by: Vladimir Kobal <vlad@prokk.net>
39 files changed, 115 insertions, 119 deletions
diff --git a/aclk/aclk.c b/aclk/aclk.c index 4b8750064a..63aa4ad386 100644 --- a/aclk/aclk.c +++ b/aclk/aclk.c @@ -1231,7 +1231,7 @@ char *aclk_state_json(void) } void add_aclk_host_labels(void) { - DICTIONARY *labels = localhost->host_labels; + DICTIONARY *labels = localhost->rrdlabels; #ifdef ENABLE_ACLK rrdlabels_add(labels, "_aclk_available", "true", RRDLABEL_SRC_AUTO|RRDLABEL_SRC_ACLK); diff --git a/collectors/plugins.d/pluginsd_parser.c b/collectors/plugins.d/pluginsd_parser.c index 3f0a5ae8bb..3dffde5acc 100644 --- a/collectors/plugins.d/pluginsd_parser.c +++ b/collectors/plugins.d/pluginsd_parser.c @@ -197,10 +197,10 @@ PARSER_RC pluginsd_overwrite_action(void *user, RRDHOST *host, DICTIONARY *new_h { UNUSED(user); - if(!host->host_labels) - host->host_labels = rrdlabels_create(); + if(!host->rrdlabels) + host->rrdlabels = rrdlabels_create(); - rrdlabels_migrate_to_these(host->host_labels, new_host_labels); + rrdlabels_migrate_to_these(host->rrdlabels, new_host_labels); sql_store_host_labels(host); return PARSER_RC_OK; diff --git a/collectors/proc.plugin/proc_diskstats.c b/collectors/proc.plugin/proc_diskstats.c index 4c2dcdb330..945ca25216 100644 --- a/collectors/proc.plugin/proc_diskstats.c +++ b/collectors/proc.plugin/proc_diskstats.c @@ -853,25 +853,25 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis } static void add_labels_to_disk(struct disk *d, RRDSET *st) { - rrdlabels_add(st->state->chart_labels, "device", d->disk, RRDLABEL_SRC_AUTO); - rrdlabels_add(st->state->chart_labels, "mount_point", d->mount_point, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device", d->disk, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "mount_point", d->mount_point, RRDLABEL_SRC_AUTO); switch (d->type) { default: case DISK_TYPE_UNKNOWN: - rrdlabels_add(st->state->chart_labels, "device_type", "unknown", RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device_type", "unknown", RRDLABEL_SRC_AUTO); break; case DISK_TYPE_PHYSICAL: - rrdlabels_add(st->state->chart_labels, "device_type", "physical", RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device_type", "physical", RRDLABEL_SRC_AUTO); break; case DISK_TYPE_PARTITION: - rrdlabels_add(st->state->chart_labels, "device_type", "partition", RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device_type", "partition", RRDLABEL_SRC_AUTO); break; case DISK_TYPE_VIRTUAL: - rrdlabels_add(st->state->chart_labels, "device_type", "virtual", RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device_type", "virtual", RRDLABEL_SRC_AUTO); break; } diff --git a/collectors/proc.plugin/proc_interrupts.c b/collectors/proc.plugin/proc_interrupts.c index 804fab88a5..db2a20b5df 100644 --- a/collectors/proc.plugin/proc_interrupts.c +++ b/collectors/proc.plugin/proc_interrupts.c @@ -228,7 +228,7 @@ int do_proc_interrupts(int update_every, usec_t dt) { char core[50+1]; snprintfz(core, 50, "cpu%d", c); - rrdlabels_add(core_st[c]->state->chart_labels, "cpu", core, RRDLABEL_SRC_AUTO); + rrdlabels_add(core_st[c]->rrdlabels, "cpu", core, RRDLABEL_SRC_AUTO); } else rrdset_next(core_st[c]); diff --git a/collectors/proc.plugin/proc_mdstat.c b/collectors/proc.plugin/proc_mdstat.c index c50c462adc..77b75d3139 100644 --- a/collectors/proc.plugin/proc_mdstat.c +++ b/collectors/proc.plugin/proc_mdstat.c @@ -78,8 +78,8 @@ static inline void make_chart_obsolete(char *name, const char *id_modifier) } static void add_labels_to_mdstat(struct raid *raid, RRDSET *st) { - rrdlabels_add(st->state->chart_labels, "device", raid->name, RRDLABEL_SRC_AUTO); - rrdlabels_add(st->state->chart_labels, "raid_level", raid->level, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device", raid->name, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "raid_level", raid->level, RRDLABEL_SRC_AUTO); rrdcalc_update_rrdlabels(st); } diff --git a/collectors/proc.plugin/proc_net_wireless.c b/collectors/proc.plugin/proc_net_wireless.c index dac8344895..328ab1ca05 100644 --- a/collectors/proc.plugin/proc_net_wireless.c +++ b/collectors/proc.plugin/proc_net_wireless.c @@ -199,7 +199,7 @@ static void configure_device(int do_status, int do_quality, int do_discarded_pac } static void add_labels_to_wireless(struct netwireless *w, RRDSET *st) { - rrdlabels_add(st->state->chart_labels, "device", w->name, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device", w->name, RRDLABEL_SRC_AUTO); rrdcalc_update_rrdlabels(st); } diff --git a/collectors/proc.plugin/proc_pagetypeinfo.c b/collectors/proc.plugin/proc_pagetypeinfo.c index 017edc49a9..c4957cafa2 100644 --- a/collectors/proc.plugin/proc_pagetypeinfo.c +++ b/collectors/proc.plugin/proc_pagetypeinfo.c @@ -261,9 +261,9 @@ int do_proc_pagetypeinfo(int update_every, usec_t dt) { char node[50+1]; snprintfz(node, 50, "node%d", pgl->node); - rrdlabels_add(st_nodezonetype[p]->state->chart_labels, "node_id", node, RRDLABEL_SRC_AUTO); - rrdlabels_add(st_nodezonetype[p]->state->chart_labels, "node_zone", pgl->zone, RRDLABEL_SRC_AUTO); - rrdlabels_add(st_nodezonetype[p]->state->chart_labels, "node_type", pgl->type, RRDLABEL_SRC_AUTO); + rrdlabels_add(st_nodezonetype[p]->rrdlabels, "node_id", node, RRDLABEL_SRC_AUTO); + rrdlabels_add(st_nodezonetype[p]->rrdlabels, "node_zone", pgl->zone, RRDLABEL_SRC_AUTO); + rrdlabels_add(st_nodezonetype[p]->rrdlabels, "node_type", pgl->type, RRDLABEL_SRC_AUTO); for (o = 0; o < pageorders_cnt; o++) { char dimid[3+1]; diff --git a/collectors/proc.plugin/proc_softirqs.c b/collectors/proc.plugin/proc_softirqs.c index feefa98855..d6389161a2 100644 --- a/collectors/proc.plugin/proc_softirqs.c +++ b/collectors/proc.plugin/proc_softirqs.c @@ -220,7 +220,7 @@ int do_proc_softirqs(int update_every, usec_t dt) { char core[50+1]; snprintfz(core, 50, "cpu%d", c); - rrdlabels_add(core_st[c]->state->chart_labels, "cpu", core, RRDLABEL_SRC_AUTO); + rrdlabels_add(core_st[c]->rrdlabels, "cpu", core, RRDLABEL_SRC_AUTO); } else rrdset_next(core_st[c]); diff --git a/collectors/proc.plugin/proc_stat.c b/collectors/proc.plugin/proc_stat.c index 6faba55a91..5086ff2c7d 100644 --- a/collectors/proc.plugin/proc_stat.c +++ b/collectors/proc.plugin/proc_stat.c @@ -1041,7 +1041,7 @@ int do_proc_stat(int update_every, usec_t dt) { char corebuf[50+1]; snprintfz(corebuf, 50, "cpu%zu", core); - rrdlabels_add(cpuidle_charts[core].st->state->chart_labels, "cpu", corebuf, RRDLABEL_SRC_AUTO); + rrdlabels_add(cpuidle_charts[core].st->rrdlabels, "cpu", corebuf, RRDLABEL_SRC_AUTO); char cpuidle_dim_id[RRD_ID_LENGTH_MAX + 1]; cpuidle_charts[core].active_time_rd = rrddim_add(cpuidle_charts[core].st, "active", "C0 (active)", 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL); diff --git a/collectors/proc.plugin/sys_block_zram.c b/collectors/proc.plugin/sys_block_zram.c index ddd1e7ae01..42c467630c 100644 --- a/collectors/proc.plugin/sys_block_zram.c +++ b/collectors/proc.plugin/sys_block_zram.c @@ -75,7 +75,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every) , RRDSET_TYPE_AREA); d->rd_compr_data_size = rrddim_add(d->st_usage, "compressed", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); d->rd_metadata_size = rrddim_add(d->st_usage, "metadata", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); - rrdlabels_add(d->st_usage->state->chart_labels, "device", name, RRDLABEL_SRC_AUTO); + rrdlabels_add(d->st_usage->rrdlabels, "device", name, RRDLABEL_SRC_AUTO); snprintfz(chart_name, RRD_ID_LENGTH_MAX, "zram_savings.%s", name); d->st_savings = rrdset_create_localhost( @@ -93,7 +93,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every) , RRDSET_TYPE_AREA); d->rd_savings_size = rrddim_add(d->st_savings, "savings", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); d->rd_original_size = rrddim_add(d->st_savings, "original", NULL, 1, 1024 * 1024, RRD_ALGORITHM_ABSOLUTE); - rrdlabels_add(d->st_savings->state->chart_labels, "device", name, RRDLABEL_SRC_AUTO); + rrdlabels_add(d->st_savings->rrdlabels, "device", name, RRDLABEL_SRC_AUTO); snprintfz(chart_name, RRD_ID_LENGTH_MAX, "zram_ratio.%s", name); d->st_comp_ratio = rrdset_create_localhost( @@ -110,7 +110,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every) , update_every , RRDSET_TYPE_LINE); d->rd_comp_ratio = rrddim_add(d->st_comp_ratio, "ratio", NULL, 1, 100, RRD_ALGORITHM_ABSOLUTE); - rrdlabels_add(d->st_comp_ratio->state->chart_labels, "device", name, RRDLABEL_SRC_AUTO); + rrdlabels_add(d->st_comp_ratio->rrdlabels, "device", name, RRDLABEL_SRC_AUTO); snprintfz(chart_name, RRD_ID_LENGTH_MAX, "zram_efficiency.%s", name); d->st_alloc_efficiency = rrdset_create_localhost( @@ -127,7 +127,7 @@ static inline void init_rrd(const char *name, ZRAM_DEVICE *d, int update_every) , update_every , RRDSET_TYPE_LINE); d->rd_alloc_efficiency = rrddim_add(d->st_alloc_efficiency, "percent", NULL, 1, 10000, RRD_ALGORITHM_ABSOLUTE); - rrdlabels_add(d->st_alloc_efficiency->state->chart_labels, "device", name, RRDLABEL_SRC_AUTO); + rrdlabels_add(d->st_alloc_efficiency->rrdlabels, "device", name, RRDLABEL_SRC_AUTO); } static int init_devices(DICTIONARY *devices, unsigned int zram_id, int update_every) { diff --git a/collectors/proc.plugin/sys_class_power_supply.c b/collectors/proc.plugin/sys_class_power_supply.c index e8a7924b09..40731b5d5f 100644 --- a/collectors/proc.plugin/sys_class_power_supply.c +++ b/collectors/proc.plugin/sys_class_power_supply.c @@ -113,7 +113,7 @@ void power_supply_free(struct power_supply *ps) { } static void add_labels_to_power_supply(struct power_supply *ps, RRDSET *st) { - rrdlabels_add(st->state->chart_labels, "device", ps->name, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device", ps->name, RRDLABEL_SRC_AUTO); rrdcalc_update_rrdlabels(st); } diff --git a/collectors/proc.plugin/sys_devices_system_node.c b/collectors/proc.plugin/sys_devices_system_node.c index fd33943097..72362a987f 100644 --- a/collectors/proc.plugin/sys_devices_system_node.c +++ b/collectors/proc.plugin/sys_devices_system_node.c @@ -115,7 +115,7 @@ int do_proc_sys_devices_system_node(int update_every, usec_t dt) { , RRDSET_TYPE_LINE ); - rrdlabels_add(m->numastat_st->state->chart_labels, "numa_node", m->name, RRDLABEL_SRC_AUTO); + rrdlabels_add(m->numastat_st->rrdlabels, "numa_node", m->name, RRDLABEL_SRC_AUTO); rrdset_flag_set(m->numastat_st, RRDSET_FLAG_DETAIL); diff --git a/collectors/proc.plugin/sys_fs_btrfs.c b/collectors/proc.plugin/sys_fs_btrfs.c index 83a2dee376..323bb69671 100644 --- a/collectors/proc.plugin/sys_fs_btrfs.c +++ b/collectors/proc.plugin/sys_fs_btrfs.c @@ -449,8 +449,8 @@ static inline int find_all_btrfs_pools(const char *path) { } static void add_labels_to_btrfs(BTRFS_NODE *n, RRDSET *st) { - rrdlabels_add(st->state->chart_labels, "device", n->id, RRDLABEL_SRC_AUTO); - rrdlabels_add(st->state->chart_labels, "device_label", n->label, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device", n->id, RRDLABEL_SRC_AUTO); + rrdlabels_add(st->rrdlabels, "device_label", n->label, RRDLABEL_SRC_AUTO); rrdcalc_update_rrdlabels(st); } diff --git a/daemon/commands.c b/daemon/commands.c index 13d8dbd40d..577f716e3b 100644 --- a/daemon/commands.c +++ b/daemon/commands.c @@ -217,7 +217,7 @@ static cmd_status_t cmd_reload_labels_execute(char *args, char **message) reload_host_labels(); BUFFER *wb = buffer_create(10); - rrdlabels_log_to_buffer(localhost->host_labels, wb); + rrdlabels_log_to_buffer(localhost->rrdlabels, wb); (*message)=strdupz(buffer_tostring(wb)); buffer_free(wb); diff --git a/database/rrd.h b/database/rrd.h index 4c3b13dfb1..f473e308ac 100644 --- a/database/rrd.h +++ b/database/rrd.h @@ -445,14 +445,6 @@ struct rrddim_tier { extern void rrdr_fill_tier_gap_from_smaller_tiers(RRDDIM *rd, int tier, time_t now); // ---------------------------------------------------------------------------- -// volatile state per chart -struct rrdset_volatile { - uuid_t hash_id; - DICTIONARY *chart_labels; - bool is_ar_chart; -}; - -// ---------------------------------------------------------------------------- // these loop macros make sure the linked list is accessed with the right lock #define rrddim_foreach_read(rd, st) \ @@ -491,15 +483,21 @@ typedef enum rrdset_flags { RRDSET_FLAG_ACLK = (1 << 16), RRDSET_FLAG_PENDING_FOREACH_ALARMS = (1 << 17), // contains dims with uninitialized foreach alarms RRDSET_FLAG_ANOMALY_DETECTION = (1 << 18), // flag to identify anomaly detection charts. - RRDSET_FLAG_INDEXED_ID = (1 << 19), - RRDSET_FLAG_INDEXED_NAME = (1 << 20), + RRDSET_FLAG_INDEXED_ID = (1 << 19), // the rrdset is indexed by its id + RRDSET_FLAG_INDEXED_NAME = (1 << 20), // the rrdset is indexed by its name + + RRDSET_FLAG_ANOMALY_RATE_CHART = (1 << 21), // the rrdset is for storing anomaly rates for all dimensions } RRDSET_FLAGS; #define rrdset_flag_check(st, flag) (__atomic_load_n(&((st)->flags), __ATOMIC_SEQ_CST) & (flag)) #define rrdset_flag_set(st, flag) __atomic_or_fetch(&((st)->flags), flag, __ATOMIC_SEQ_CST) #define rrdset_flag_clear(st, flag) __atomic_and_fetch(&((st)->flags), ~(flag), __ATOMIC_SEQ_CST) +#define rrdset_is_ar_chart(st) rrdset_flag_check(st, RRDSET_FLAG_ANOMALY_RATE_CHART) + struct rrdset { + uuid_t uuid; + // ------------------------------------------------------------------------ // the set configuration @@ -550,8 +548,6 @@ struct rrdset { uuid_t *chart_uuid; // Store the global GUID for this chart // this object. - struct rrdset_volatile *state; // volatile state that is not persistently stored - size_t rrddim_page_alignment; // keeps metric pages in alignment when using dbengine usec_t usec_since_last_update; // the time in microseconds since the last collection of data @@ -585,6 +581,11 @@ struct rrdset { void *st_on_file; // compatibility with V019 RRDSET files // ------------------------------------------------------------------------ + // chart labels + + DICTIONARY *rrdlabels; + + // ------------------------------------------------------------------------ // the dimensions DICTIONARY *rrddim_root_index; // the root of the dimensions index @@ -638,7 +639,6 @@ typedef enum rrdhost_flags { RRDHOST_FLAG_EXPORTING_SEND = (1 << 3), // send it to external databases RRDHOST_FLAG_EXPORTING_DONT_SEND = (1 << 4), // don't send it to external databases RRDHOST_FLAG_ARCHIVED = (1 << 5), // The host is archived, no collected charts yet - RRDHOST_FLAG_MULTIHOST = (1 << 6), // Host belongs to localhost/megadb RRDHOST_FLAG_PENDING_FOREACH_ALARMS = (1 << 7), // contains dims with uninitialized foreach alarms RRDHOST_FLAG_STREAM_LABELS_UPDATE = (1 << 8), RRDHOST_FLAG_STREAM_LABELS_STOP = (1 << 9), @@ -842,9 +842,6 @@ struct rrdhost { // ------------------------------------------------------------------------ // streaming of data from remote hosts - rrdpush - volatile size_t connected_senders; // when remote hosts are streaming to this - // host, this is the counter of connected clients - time_t senders_connect_time; // the time the last sender was connected time_t senders_last_chart_command; // the time of the last CHART streaming command time_t senders_disconnected_time; // the time the last sender was disconnected @@ -903,7 +900,7 @@ struct rrdhost { // ------------------------------------------------------------------------ // Support for host-level labels - DICTIONARY *host_labels; + DICTIONARY *rrdlabels; // ------------------------------------------------------------------------ // indexes diff --git a/database/rrdcalc.c b/database/rrdcalc.c index 808e74952a..83dd527325 100644 --- a/database/rrdcalc.c +++ b/database/rrdcalc.c @@ -67,8 +67,8 @@ static STRING *rrdcalc_replace_variables(const char *line, RRDCALC *rc) { temp = buf; } else if (!strncmp(var, RRDCALC_VAR_LABEL, RRDCALC_VAR_LABEL_LEN)) { - if(likely(rc->rrdset && rc->rrdset->state && rc->rrdset->state->chart_labels)) { - rrdlabels_get_value_to_char_or_null(rc->rrdset->state->chart_labels, &lbl_value, var+RRDCALC_VAR_LABEL_LEN); + if(likely(rc->rrdset && rc->rrdset->rrdlabels)) { + rrdlabels_get_value_to_char_or_null(rc->rrdset->rrdlabels, &lbl_value, var+RRDCALC_VAR_LABEL_LEN); if (lbl_value) { char *buf = find_and_replace(temp, var, lbl_value, m); freez(temp); @@ -191,7 +191,7 @@ static inline int rrdcalc_is_matching_rrdset(RRDCALC *rc, RRDSET *st) { if (rc->plugin_pattern && !simple_pattern_matches(rc->plugin_pattern, rrdset_plugin_name(st))) return 0; - if (st->rrdhost->host_labels && rc->host_labels_pattern && !rrdlabels_match_simple_pattern_parsed(st->rrdhost->host_labels, rc->host_labels_pattern, '=')) + if (st->rrdhost->rrdlabels && rc->host_labels_pattern && !rrdlabels_match_simple_pattern_parsed(st->rrdhost->rrdlabels, rc->host_labels_pattern, '=')) return 0; return 1; @@ -672,7 +672,7 @@ static void rrdcalc_labels_unlink_alarm_loop(RRDHOST *host, RRDCALC *alarms) { continue; } - if(!rrdlabels_match_simple_pattern_parsed(host->host_labels, rc->host_labels_pattern, '=')) { + if(!rrdlabels_match_simple_pattern_parsed(host->rrdlabels, rc->host_labels_pattern, '=')) { info("Health configuration for alarm '%s' cannot be applied, because the host %s does not have the label(s) '%s'", rrdcalc_name(rc), rrdhost_hostname(host), @@ -700,7 +700,7 @@ void rrdcalc_labels_unlink() { if (unlikely(!host->health_enabled)) continue; - if (host->host_labels) { + if (host->rrdlabels) { rrdhost_wrlock(host); rrdcalc_labels_unlink_alarm_from_host(host); diff --git a/database/rrdcalctemplate.c b/database/rrdcalctemplate.c index 4ba96082ac..0db76d6c04 100644 --- a/database/rrdcalctemplate.c +++ b/database/rrdcalctemplate.c @@ -27,7 +27,7 @@ void rrdcalctemplate_check_conditions_and_link(RRDCALCTEMPLATE *rt, RRDSET *st, if (rt->plugin_pattern && !simple_pattern_matches(rt->plugin_pattern, rrdset_plugin_name(st))) return; - if(host->host_labels && rt->host_labels_pattern && !rrdlabels_match_simple_pattern_parsed(host->host_labels, rt->host_labels_pattern, '=')) + if(host->rrdlabels && rt->host_labels_pattern && !rrdlabels_match_simple_pattern_parsed(host->rrdlabels, rt->host_labels_pattern, '=')) return; RRDCALC *rc = rrdcalc_create_from_template(host, rt, rrdset_id(st)); diff --git a/database/rrdcontext.c b/database/rrdcontext.c index dcf8b94e22..8a560b03a0 100644 --- a/database/rrdcontext.c +++ b/database/rrdcontext.c @@ -268,7 +268,7 @@ typedef struct rrdinstance { int update_every; // data collection frequency RRDSET *rrdset; // pointer to RRDSET when collected, or NULL - DICTIONARY *rrdlabels; // linked to RRDSET->state->chart_labels or own version + DICTIONARY *rrdlabels; // linked to RRDSET->chart_labels or own version struct rrdcontext *rc; DICTIONARY *rrdmetrics; @@ -705,8 +705,8 @@ static void rrdinstance_insert_callback(const char *id __maybe_unused, void *val if(!ri->name) ri->name = string_dup(ri->id); - if(ri->rrdset && ri->rrdset->state) { - ri->rrdlabels = ri->rrdset->state->chart_labels; + if(ri->rrdset) { + ri->rrdlabels = ri->rrdset->rrdlabels; ri->flags &= ~RRD_FLAG_OWN_LABELS; // no need of atomics at the constructor } else { @@ -715,7 +715,7 @@ static void rrdinstance_insert_callback(const char *id __maybe_unused, void *val } if(ri->rrdset) { - if(unlikely((rrdset_flag_check(ri->rrdset, RRDSET_FLAG_HIDDEN)) || (ri->rrdset->state && ri->rrdset->state->is_ar_chart))) + if(unlikely((rrdset_flag_check(ri->rrdset, RRDSET_FLAG_HIDDEN)) || rrdset_is_ar_chart(ri->rrdset))) ri->flags |= RRD_FLAG_HIDDEN; // no need of atomics at the constructor else ri->flags &= ~RRD_FLAG_HIDDEN; // no need of atomics at the constructor @@ -814,7 +814,7 @@ static void rrdinstance_conflict_callback(const char *id __maybe_unused, void *o if(ri->rrdset && rrd_flag_check(ri, RRD_FLAG_OWN_LABELS)) { DICTIONARY *old = ri->rrdlabels; - ri->rrdlabels = ri->rrdset->state->chart_labels; + ri->rrdlabels = ri->rrdset->rrdlabels; rrd_flag_clear(ri, RRD_FLAG_OWN_LABELS); rrdlabels_destroy(old); } @@ -825,7 +825,7 @@ static void rrdinstance_conflict_callback(const char *id __maybe_unused, void *o } if(ri->rrdset) { - if(unlikely((rrdset_flag_check(ri->rrdset, RRDSET_FLAG_HIDDEN)) || (ri->rrdset->state && ri->rrdset->state->is_ar_chart))) + if(unlikely((rrdset_flag_check(ri->rrdset, RRDSET_FLAG_HIDDEN)) || rrdset_is_ar_chart(ri->rrdset))) rrd_flag_set(ri, RRD_FLAG_HIDDEN); else rrd_flag_clear(ri, RRD_FLAG_HIDDEN); @@ -1034,7 +1034,7 @@ static inline void rrdinstance_rrdset_is_freed(RRDSET *st) { if(!rrd_flag_check(ri, RRD_FLAG_OWN_LABELS)) { ri->rrdlabels = rrdlabels_create(); - rrdlabels_copy(ri->rrdlabels, st->state->chart_labels); + rrdlabels_copy(ri->rrdlabels, st->rrdlabels); rrd_flag_set(ri, RRD_FLAG_OWN_LABELS); } @@ -1995,7 +1995,7 @@ int rrdcontexts_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, if(options & RRDCONTEXT_OPTION_SHOW_LABELS) { buffer_sprintf(wb, ",\n\t\"host_labels\": {\n"); - rrdlabels_to_buffer(host->host_labels, wb, "\t\t", ":", "\"", ",\n", NULL, NULL, NULL, NULL); + rrdlabels_to_buffer(host->rrdlabels, wb, "\t\t", ":", "\"", ",\n", NULL, NULL, NULL, NULL); buffer_strcat(wb, "\n\t}"); } diff --git a/database/rrddim.c b/database/rrddim.c index 73b83684ce..b1ebeed49a 100644 --- a/database/rrddim.c +++ b/database/rrddim.c @@ -64,7 +64,7 @@ inline int rrddim_set_name(RRDSET *st, RRDDIM *rd, const char *name) { string_freez(rd->name); rd->name = rrd_string_strdupz(name); - if (!st->state->is_ar_chart) + if (!rrdset_is_ar_chart(st)) rrddimvar_rename_all(rd); rd->exposed = 0; @@ -340,7 +340,7 @@ RRDDIM *rrddim_add_custom(RRDSET *st // append this dimension DOUBLE_LINKED_LIST_APPEND_UNSAFE(st->dimensions, rd, prev, next); - if(host->health_enabled && !st->state->is_ar_chart) { + if(host->health_enabled && !rrdset_is_ar_chart(st)) { rrddimvar_create(rd, RRDVAR_TYPE_CALCULATED, NULL, NULL, &rd->last_stored_value, RRDVAR_OPTION_DEFAULT); rrddimvar_create(rd, RRDVAR_TYPE_COLLECTED, NULL, "_raw", &rd->last_collected_value, RRDVAR_OPTION_DEFAULT); < |