diff options
author | Kaushik BV <kaushikbv@gluster.com> | 2011-04-13 22:14:37 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-04-14 01:00:55 -0700 |
commit | 93cb168fb362c7aea3c10371574a5c5566bb0222 (patch) | |
tree | 44f7fd323980d3c073498c81be34ddc6f739b0ef /xlators/mgmt/glusterd/src/glusterd-store.c | |
parent | 77cd50a12887b13db4c49be6a979a5ecb8239570 (diff) |
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 <kaushikbv@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2536 (gsync service introspection)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2536
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 8058adcd0f9..836c9d12cf5 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; |