From 5f467f9f83c0fe81b0f54bcd23ad1f6aa86cd548 Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Fri, 16 Sep 2016 22:23:51 +0530 Subject: [PATCH 70/86] 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 > Reviewed-by: Raghavendra G > Reviewed-by: Shyamsundar Ranganathan >Reviewed-on: http://review.gluster.org/15520 >Smoke: Gluster Build System >CentOS-regression: Gluster Build System >NetBSD-regression: NetBSD Build System >Reviewed-by: Atin Mukherjee Change-Id: Ia24038c04548a98aac899df10414585b988caa76 BUG: 1361066 Signed-off-by: N Balachandran Reviewed-on: https://code.engineering.redhat.com/gerrit/84875 Reviewed-by: Atin Mukherjee Tested-by: Atin Mukherjee --- xlators/cluster/dht/src/dht-rebalance.c | 56 +++++++++++++++++++++++++++--- 1 files changed, 50 insertions(+), 6 deletions(-) diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 58b0d74..194fbb0 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -74,6 +74,49 @@ dht_set_global_defrag_error (gf_defrag_info_t *defrag, int ret) } 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) { @@ -3823,6 +3866,8 @@ out: defrag->defrag_status = GF_DEFRAG_STATUS_COMPLETE; } + dht_send_rebalance_event (this, defrag->defrag_status); + LOCK (&defrag->lock); { status = dict_new (); @@ -3973,12 +4018,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) -- 1.7.1