From 93cb168fb362c7aea3c10371574a5c5566bb0222 Mon Sep 17 00:00:00 2001 From: Kaushik BV Date: Wed, 13 Apr 2011 22:14:37 +0000 Subject: mgmt/glusterd: Implementation of volume gsync status [master [slave]] Changes made in the path of gsync start/stop as well, where we maintain a list of active gsync sessions, hence gsync stop could be executed at all nodes. A new dict in glusterd_volinfo_t added to maintain an active list of gsync slaves running on each master. Signed-off-by: Kaushik BV Signed-off-by: Anand Avati BUG: 2536 (gsync service introspection) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2536 --- cli/src/cli-cmd-parser.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'cli/src/cli-cmd-parser.c') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 1cfba3561..e8b0e778a 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -1120,13 +1120,14 @@ out: int32_t cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options) { - int32_t ret = 0; + int32_t ret = -1; int32_t config_type = 0; dict_t *dict = NULL; gf1_cli_gsync_set type = GF_GSYNC_OPTION_TYPE_NONE; char *append_str = NULL; size_t append_len = 0; int i = 0; + int32_t status_type = 0; GF_ASSERT (words); GF_ASSERT (options); @@ -1138,6 +1139,43 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options) if (!dict) goto out; + if (wordcount < 3) + goto out; + + if ((strcmp (words[2], "status")) == 0) { + type = GF_GSYNC_OPTION_TYPE_STATUS; + + if (wordcount == 3) + status_type = GF_GSYNC_OPTION_TYPE_STATUS_ALL; + else if (wordcount == 4) + status_type = GF_GSYNC_OPTION_TYPE_STATUS_MASTER; + else if (wordcount == 5) + status_type = GF_GSYNC_OPTION_TYPE_STATUS_MST_SLV; + else + goto out; + + + ret = dict_set_int32 (dict, "status-type", status_type); + if (ret < 0) + goto out; + + if (wordcount < 4) + goto set_type; + ret = dict_set_str (dict, "master", (char *)words[3]); + if (ret < 0) + goto out; + + if (wordcount < 5) + goto set_type; + ret = dict_set_str (dict, "slave", (char *)words[4]); + if (ret < 0) + goto out; + + + + goto set_type; + } + if (wordcount < 5) goto out; @@ -1150,12 +1188,18 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options) goto out; if ((strcmp (words[2], "start")) == 0) { + if (wordcount != 5) + goto out; + type = GF_GSYNC_OPTION_TYPE_START; goto set_type; } if ((strcmp (words[2], "stop")) == 0) { + if (wordcount != 5) + goto out; + type = GF_GSYNC_OPTION_TYPE_STOP; goto set_type; @@ -1219,6 +1263,9 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options) ret = dict_set_int32 (dict, "config_type", config_type); if (ret < 0) goto out; + } else { + ret = -1; + goto out; } set_type: -- cgit