diff options
author | Milind Changire <mchangir@redhat.com> | 2016-09-05 21:51:19 +0530 |
---|---|---|
committer | Dan Lambright <dlambrig@redhat.com> | 2016-09-08 05:32:20 -0700 |
commit | cd23242b8953040b231f402c334f16520ac8029f (patch) | |
tree | 38c2c11f64765dabfaaeccd332f8859feb39d44c /xlators/cluster/dht/src/tier.c | |
parent | 6f182733d943aff5212175c58dd59b2da64b9d8b (diff) |
cluster/tier: add tiering events
Add events for:
* tier attach and detach
* tier pause and resume
* tier rising and dropping hi and lo watermarks
Update eventskeygen.py with tiering events.
Update cli help with:
* attach: add optional force argument
* detach: make force available as non-optional argument on its own
Change-Id: I43990d3a8742151a4a7889bafa19cb572fe661bd
BUG: 1368336
Signed-off-by: Milind Changire <mchangir@redhat.com>
Reviewed-on: http://review.gluster.org/15232
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Tested-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/tier.c')
-rw-r--r-- | xlators/cluster/dht/src/tier.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index 7e5e1004b84..f54d4f6cdc6 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -14,6 +14,7 @@ #include "tier.h" #include "tier-common.h" #include "syscall.h" +#include "events.h" /*Hard coded DB info*/ static gfdb_db_type_t dht_tier_db_type = GFDB_SQLITE3; @@ -321,6 +322,36 @@ exit: return ret; } +static void +tier_send_watermark_event (const char *volname, + tier_watermark_op_t old_wm, + tier_watermark_op_t new_wm) +{ + if (old_wm == TIER_WM_LOW || old_wm == TIER_WM_NONE) { + if (new_wm == TIER_WM_MID) { + gf_event (EVENT_TIER_WATERMARK_RAISED_TO_MID, + "vol=%s", volname); + } else if (new_wm == TIER_WM_HI) { + gf_event (EVENT_TIER_WATERMARK_HI, "vol=%s", volname); + } + } else if (old_wm == TIER_WM_MID) { + if (new_wm == TIER_WM_LOW) { + gf_event (EVENT_TIER_WATERMARK_DROPPED_TO_LOW, + "vol=%s", volname); + } else if (new_wm == TIER_WM_HI) { + gf_event (EVENT_TIER_WATERMARK_HI, "vol=%s", volname); + } + } else if (old_wm == TIER_WM_HI) { + if (new_wm == TIER_WM_MID) { + gf_event (EVENT_TIER_WATERMARK_DROPPED_TO_MID, + "vol=%s", volname); + } else if (new_wm == TIER_WM_LOW) { + gf_event (EVENT_TIER_WATERMARK_DROPPED_TO_LOW, + "vol=%s", volname); + } + } +} + int tier_check_watermark (xlator_t *this) { @@ -352,6 +383,10 @@ tier_check_watermark (xlator_t *this) if (wm != tier_conf->watermark_last) { + tier_send_watermark_event (tier_conf->volname, + tier_conf->watermark_last, + wm); + tier_conf->watermark_last = wm; gf_msg (this->name, GF_LOG_INFO, 0, DHT_MSG_LOG_TIER_STATUS, @@ -2623,6 +2658,33 @@ err: return ret; } + +static void +tier_save_vol_name (xlator_t *this) +{ + dht_conf_t *conf = NULL; + gf_defrag_info_t *defrag = NULL; + char *suffix = NULL; + int name_len = 0; + + + conf = this->private; + defrag = conf->defrag; + + suffix = strstr (this->name, "-tier-dht"); + + if (suffix) + name_len = suffix - this->name; + else + name_len = strlen (this->name); + + if (name_len > GD_VOLUME_NAME_MAX) + name_len = GD_VOLUME_NAME_MAX; + + strncpy (defrag->tier_conf.volname, this->name, name_len); + defrag->tier_conf.volname[name_len] = 0; +} + int tier_init (xlator_t *this) { @@ -2860,6 +2922,8 @@ tier_init (xlator_t *this) defrag->write_freq_threshold, defrag->read_freq_threshold); + tier_save_vol_name (this); + ret = 0; out: |