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 --- xlators/mgmt/glusterd/src/glusterd-store.c | 49 +++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 8058adcd0..836c9d12c 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -448,6 +448,40 @@ out: return ret; } +static void +_storeslaves (dict_t *this, char *key, data_t *value, void *data) +{ + int32_t ret = 0; + glusterd_store_handle_t *shandle = NULL; + + shandle = (glusterd_store_handle_t*)data; + + GF_ASSERT (shandle); + GF_ASSERT (shandle->fd > 0); + GF_ASSERT (shandle->path); + GF_ASSERT (key); + GF_ASSERT (value && value->data); + + if ((!shandle) || (shandle->fd <= 0) || (!shandle->path)) + return; + + if (!key) + return; + if (!value || !value->data) + return; + + gf_log ("", GF_LOG_DEBUG, "Storing in volinfo:key= %s, val=%s", + key, value->data); + + ret = glusterd_store_save_value (shandle->fd, key, (char*)value->data); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Unable to write into store" + " handle for path: %s", shandle->path); + return; + } +} + + void _storeopts (dict_t *this, char *key, data_t *value, void *data) { int32_t ret = 0; @@ -587,6 +621,8 @@ glusterd_store_volinfo_write (int fd, glusterd_volinfo_t *volinfo) shandle->fd = fd; dict_foreach (volinfo->dict, _storeopts, shandle); + + dict_foreach (volinfo->gsync_slaves, _storeslaves, shandle); shandle->fd = 0; out: gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); @@ -1479,7 +1515,18 @@ glusterd_store_retrieve_volume (char *volname) if (ret) gf_log ("", GF_LOG_WARNING, "failed to parse uuid"); - } else { + } else if (strstr (key, "slave")) { + ret = dict_set_str(volinfo->gsync_slaves, key, + gf_strdup (value)); + if (ret) { + gf_log ("",GF_LOG_ERROR, "Error in " + "dict_set_str"); + goto out; + } + gf_log ("", GF_LOG_DEBUG, "Parsed as Gsync-" + "skave:key=%s,value:%s", key, value); + } + else { exists = glusterd_check_option_exists (key, NULL); if (exists == -1) { ret = -1; -- cgit