diff options
| author | N Balachandran <nbalacha@redhat.com> | 2016-09-16 22:23:51 +0530 | 
|---|---|---|
| committer | Atin Mukherjee <amukherj@redhat.com> | 2016-09-17 03:51:48 -0700 | 
| commit | c6f1e2983c709f625e8634228b0c701b14e63d72 (patch) | |
| tree | 9a10ea0b14e223aaeee65e33e399257a1336e3cf | |
| parent | b7bb059865c43e3098bd5682aedd0b9b716d9d23 (diff) | |
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 <nbalacha@redhat.com>
> Reviewed-on: http://review.gluster.org/15501
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
(cherry picked from commit e872917dbf4563703b8f396d7d30f8168ed646cd)
Change-Id: Ia24038c04548a98aac899df10414585b988caa76
BUG: 1376477
Signed-off-by: N Balachandran <nbalacha@redhat.com>
Reviewed-on: http://review.gluster.org/15520
Smoke: Gluster Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
| -rw-r--r-- | 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 f7fa267b7f5..2fe786ec6ba 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)  { @@ -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)  | 
