From cd23242b8953040b231f402c334f16520ac8029f Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Mon, 5 Sep 2016 21:51:19 +0530 Subject: 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 Reviewed-on: http://review.gluster.org/15232 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Dan Lambright Tested-by: Dan Lambright --- xlators/cluster/dht/src/Makefile.am | 1 + xlators/cluster/dht/src/dht-common.h | 2 ++ xlators/cluster/dht/src/dht-rebalance.c | 5 +++ xlators/cluster/dht/src/tier.c | 64 +++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) (limited to 'xlators/cluster/dht/src') diff --git a/xlators/cluster/dht/src/Makefile.am b/xlators/cluster/dht/src/Makefile.am index 29be5ce4776..9c38221a148 100644 --- a/xlators/cluster/dht/src/Makefile.am +++ b/xlators/cluster/dht/src/Makefile.am @@ -36,6 +36,7 @@ noinst_HEADERS = dht-common.h dht-mem-types.h dht-messages.h dht-helper.h tier-c AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \ -I$(top_srcdir)/libglusterfs/src/gfdb \ -I$(top_srcdir)/xlators/lib/src \ + -I$(top_srcdir)/rpc/rpc-lib/src \ -DDATADIR=\"$(localstatedir)\" \ -DLIBDIR=\"$(libdir)\" \ -DLIBGFDB_VERSION=\"$(LIBGFDB_VERSION)\" diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index da1bcb6a4a1..9230681541f 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -18,6 +18,7 @@ #include "syncop.h" #include "refcount.h" #include "timer.h" +#include "protocol-common.h" #ifndef _DHT_H #define _DHT_H @@ -432,6 +433,7 @@ typedef struct gf_tier_conf { * in the last cycle of promote or demote */ int32_t last_promote_qfile_index; int32_t last_demote_qfile_index; + char volname[GD_VOLUME_NAME_MAX + 1]; } gf_tier_conf_t; struct gf_defrag_info_ { diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 7275b114745..f7fa267b7f5 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -16,6 +16,7 @@ #include #include #include +#include "events.h" #define GF_DISK_SECTOR_SIZE 512 @@ -4078,6 +4079,8 @@ gf_defrag_check_pause_tier (gf_tier_conf_t *tier_conf) gf_msg ("tier", GF_LOG_DEBUG, 0, DHT_MSG_TIER_PAUSED, "woken %d", woke); + + gf_event (EVENT_TIER_PAUSE, "vol=%s", tier_conf->volname); out: state = tier_conf->pause_state; @@ -4174,6 +4177,8 @@ gf_defrag_resume_tier (xlator_t *this, gf_defrag_info_t *defrag) gf_defrag_set_pause_state (&defrag->tier_conf, TIER_RUNNING); + gf_event (EVENT_TIER_RESUME, "vol=%s", defrag->tier_conf.volname); + return 0; } 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: -- cgit