From e872917dbf4563703b8f396d7d30f8168ed646cd Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Thu, 15 Sep 2016 11:20:54 +0530 Subject: dht/events: Added rebalance events The rebalance process will now send an event when it is complete. Also fixed a problem where the run-time was not always set causing spurious rebalance failure events to be sent. Change-Id: Ib445171c78c9560940022bca20c887d31a9bb1ca BUG: 1371874 Signed-off-by: N Balachandran Reviewed-on: http://review.gluster.org/15501 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Raghavendra G CentOS-regression: Gluster Build System Reviewed-by: Shyamsundar Ranganathan --- xlators/cluster/dht/src/dht-rebalance.c | 56 +++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 6 deletions(-) (limited to 'xlators/cluster/dht/src') diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 6d93cf24d1d..170fb102462 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -73,6 +73,49 @@ dht_set_global_defrag_error (gf_defrag_info_t *defrag, int ret) return; } +static int +dht_send_rebalance_event (xlator_t *this, gf_defrag_status_t status) +{ + int ret = -1; + char *volname = NULL; + char *tmpstr = NULL; + + eventtypes_t event = EVENT_LAST; + + switch (status) { + case GF_DEFRAG_STATUS_COMPLETE: + event = EVENT_VOLUME_REBALANCE_COMPLETE; + break; + case GF_DEFRAG_STATUS_FAILED: + event = EVENT_VOLUME_REBALANCE_FAILED; + break; + case GF_DEFRAG_STATUS_STOPPED: + event = EVENT_VOLUME_REBALANCE_STOP; + break; + default: + break; + + } + + tmpstr = gf_strdup (this->name); + if (tmpstr) { + volname = strtok(tmpstr, "-dht"); + } + + if (!volname) + volname = this->name; + + if (event != EVENT_LAST) { + ret = gf_event (event, "volume=%s", volname); + } + GF_FREE (tmpstr); + return ret; +} + + + + + static int dht_write_with_holes (xlator_t *to, fd_t *fd, struct iovec *vec, int count, int32_t size, off_t offset, struct iobref *iobref) @@ -3830,6 +3873,8 @@ out: defrag->defrag_status = GF_DEFRAG_STATUS_COMPLETE; } + dht_send_rebalance_event (this, defrag->defrag_status); + LOCK (&defrag->lock); { status = dict_new (); @@ -3980,12 +4025,11 @@ gf_defrag_status_get (gf_defrag_info_t *defrag, dict_t *dict) if (ret) gf_log (THIS->name, GF_LOG_WARNING, "failed to set status"); - if (elapsed) { - ret = dict_set_double (dict, "run-time", elapsed); - if (ret) - gf_log (THIS->name, GF_LOG_WARNING, - "failed to set run-time"); - } + + ret = dict_set_double (dict, "run-time", elapsed); + if (ret) + gf_log (THIS->name, GF_LOG_WARNING, + "failed to set run-time"); ret = dict_set_uint64 (dict, "failures", failures); if (ret) -- cgit