summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-cmd-volume.c23
-rw-r--r--events/eventskeygen.py13
-rw-r--r--xlators/cluster/dht/src/Makefile.am1
-rw-r--r--xlators/cluster/dht/src/dht-common.h2
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c5
-rw-r--r--xlators/cluster/dht/src/tier.c64
6 files changed, 106 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 003c95395ef..6d0fdf765b4 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1117,6 +1117,7 @@ cli_cmd_volume_tier_cbk (struct cli_state *state,
rpc_clnt_procedure_t *proc = NULL;
cli_local_t *local = NULL;
int i = 0;
+ eventtypes_t event = EVENT_LAST;
if (wordcount < 4) {
cli_usage_out (word->pattern);
@@ -1135,6 +1136,15 @@ cli_cmd_volume_tier_cbk (struct cli_state *state,
ret = do_cli_cmd_volume_detach_tier (state, word,
words, wordcount-1);
+ if (!strcmp (words[wordcount-2], "commit")) {
+ event = EVENT_TIER_DETACH_COMMIT;
+ } else if (!strcmp (words[wordcount-2], "start")) {
+ event = EVENT_TIER_DETACH_START;
+ } else if (!strcmp (words[wordcount-2], "stop")) {
+ event = EVENT_TIER_DETACH_STOP;
+ } else if (!strcmp (words[wordcount-2], "force")) {
+ event = EVENT_TIER_DETACH_FORCE;
+ }
goto out;
} else if (!strcmp(words[1], "attach-tier")) {
@@ -1147,6 +1157,11 @@ cli_cmd_volume_tier_cbk (struct cli_state *state,
ret = do_cli_cmd_volume_attach_tier (state, word,
words, wordcount-1);
+ if (!strcmp (words[wordcount-2], "force")) {
+ event = EVENT_TIER_ATTACH_FORCE;
+ } else {
+ event = EVENT_TIER_ATTACH;
+ }
goto out;
}
@@ -1171,6 +1186,10 @@ cli_cmd_volume_tier_cbk (struct cli_state *state,
out:
if (ret) {
cli_out ("Tier command failed");
+ } else {
+ if (event != EVENT_LAST) {
+ gf_event (event, "vol=%s", words[2]);
+ }
}
if (options)
dict_unref (options);
@@ -2941,8 +2960,8 @@ struct cli_cmd volume_cmds[] = {
#if !defined(__NetBSD__)
{ "volume tier <VOLNAME> status\n"
"volume tier <VOLNAME> start [force]\n"
- "volume tier <VOLNAME> attach [<replica COUNT>] <NEW-BRICK>...\n"
- "volume tier <VOLNAME> detach <start|stop|status|commit|[force]>\n",
+ "volume tier <VOLNAME> attach [<replica COUNT>] <NEW-BRICK>... [force]\n"
+ "volume tier <VOLNAME> detach <start|stop|status|commit|force>\n",
cli_cmd_volume_tier_cbk,
"Tier translator specific operations."},
diff --git a/events/eventskeygen.py b/events/eventskeygen.py
index 7f3f6572a04..1e7b6b6958a 100644
--- a/events/eventskeygen.py
+++ b/events/eventskeygen.py
@@ -149,6 +149,19 @@ keys = (
"EVENT_AFR_SUBVOL_UP",
"EVENT_AFR_SUBVOLS_DOWN",
"EVENT_AFR_SPLIT_BRAIN",
+
+ "EVENT_TIER_ATTACH",
+ "EVENT_TIER_ATTACH_FORCE",
+ "EVENT_TIER_DETACH_START",
+ "EVENT_TIER_DETACH_STOP",
+ "EVENT_TIER_DETACH_COMMIT",
+ "EVENT_TIER_DETACH_FORCE",
+ "EVENT_TIER_PAUSE",
+ "EVENT_TIER_RESUME",
+ "EVENT_TIER_WATERMARK_HI",
+ "EVENT_TIER_WATERMARK_DROPPED_TO_MID",
+ "EVENT_TIER_WATERMARK_RAISED_TO_MID",
+ "EVENT_TIER_WATERMARK_DROPPED_TO_LOW",
)
LAST_EVENT = "EVENT_LAST"
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 <signal.h>
#include <fnmatch.h>
#include <signal.h>
+#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: