diff options
author | Venky Shankar <vshankar@redhat.com> | 2012-11-21 12:06:26 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-11-21 16:49:04 -0800 |
commit | 1f64e5e3dd7f871e112ad9d3e9fae3cc5e15fd88 (patch) | |
tree | d8e025a02706520ca8b424dc0d266d1a19413b3d /xlators/mgmt/glusterd/src | |
parent | a64a0d89d5256386f6773709477aea87823e2e68 (diff) |
gsyncd / geo-rep: include hostname in status cmd
Including hostname of the node where geo-rep start was
initiated from. This helps any consumers of the status
command to identify and possibly issue commands on those
node(s).
Change-Id: I005083878a3a4794da3b7f3f7d2cc9d28f004e3f
BUG: 858218
Signed-off-by: Venky Shankar <vshankar@redhat.com>
Reviewed-on: http://review.gluster.org/4218
Reviewed-by: Csaba Henk <csaba@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 47 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.h | 1 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 12 |
3 files changed, 49 insertions, 11 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index 3dcb12f39ef..3661d9d01de 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -730,7 +730,7 @@ gsync_verify_config_options (dict_t *dict, char **op_errstr) static int glusterd_get_gsync_status_mst_slv (glusterd_volinfo_t *volinfo, - char *slave, dict_t *rsp_dict); + char *slave, dict_t *rsp_dict, char *node); static int _get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data) @@ -751,7 +751,8 @@ _get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data) return 0; ret = glusterd_get_gsync_status_mst_slv(param->volinfo, - slave, param->rsp_dict); + slave, param->rsp_dict, + param->node); return 0; } @@ -1463,12 +1464,13 @@ dict_get_param (dict_t *dict, char *key, char **param) static int glusterd_read_status_file (char *master, char *slave, - dict_t *dict) + dict_t *dict, char *node) { glusterd_conf_t *priv = NULL; int ret = 0; char *statefile = NULL; char buf[1024] = {0, }; + char nds[1024] = {0, }; char mst[1024] = {0, }; char slv[1024] = {0, }; char sts[1024] = {0, }; @@ -1476,6 +1478,7 @@ glusterd_read_status_file (char *master, char *slave, dict_t *confd = NULL; int gsync_count = 0; int status = 0; + char *dyn_node = NULL; GF_ASSERT (THIS); GF_ASSERT (THIS->private); @@ -1544,6 +1547,16 @@ glusterd_read_status_file (char *master, char *slave, else gsync_count++; + (void) snprintf (nds, sizeof (nds), "node%d", gsync_count); + dyn_node = gf_strdup (node); + if (!dyn_node) + goto out; + ret = dict_set_dynstr (dict, nds, dyn_node); + if (ret) { + GF_FREE (dyn_node); + goto out; + } + snprintf (mst, sizeof (mst), "master%d", gsync_count); master = gf_strdup (master); if (!master) @@ -1691,7 +1704,8 @@ out: static int glusterd_get_gsync_status_mst_slv (glusterd_volinfo_t *volinfo, - char *slave, dict_t *rsp_dict) + char *slave, dict_t *rsp_dict, + char *node) { uuid_t uuid = {0, }; glusterd_conf_t *priv = NULL; @@ -1715,14 +1729,16 @@ glusterd_get_gsync_status_mst_slv (glusterd_volinfo_t *volinfo, goto out; } - ret = glusterd_read_status_file (volinfo->volname, slave, rsp_dict); + ret = glusterd_read_status_file (volinfo->volname, + slave, rsp_dict, node); out: gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); return ret; } static int -glusterd_get_gsync_status_mst (glusterd_volinfo_t *volinfo, dict_t *rsp_dict) +glusterd_get_gsync_status_mst (glusterd_volinfo_t *volinfo, dict_t *rsp_dict, + char *node) { glusterd_gsync_status_temp_t param = {0, }; @@ -1730,13 +1746,14 @@ glusterd_get_gsync_status_mst (glusterd_volinfo_t *volinfo, dict_t *rsp_dict) param.rsp_dict = rsp_dict; param.volinfo = volinfo; + param.node = node; dict_foreach (volinfo->gsync_slaves, _get_status_mst_slv, ¶m); return 0; } static int -glusterd_get_gsync_status_all ( dict_t *rsp_dict) +glusterd_get_gsync_status_all (dict_t *rsp_dict, char *node) { int32_t ret = 0; @@ -1749,7 +1766,7 @@ glusterd_get_gsync_status_all ( dict_t *rsp_dict) GF_ASSERT (priv); list_for_each_entry (volinfo, &priv->volumes, vol_list) { - ret = glusterd_get_gsync_status_mst (volinfo, rsp_dict); + ret = glusterd_get_gsync_status_mst (volinfo, rsp_dict, node); if (ret) goto out; } @@ -1769,11 +1786,17 @@ glusterd_get_gsync_status (dict_t *dict, char **op_errstr, dict_t *rsp_dict) gf_boolean_t exists = _gf_false; glusterd_volinfo_t *volinfo = NULL; int ret = 0; + char my_hostname[256] = {0,}; + ret = gethostname(my_hostname, 256); + if (ret) { + /* stick to N/A */ + (void) strcpy (my_hostname, "N/A"); + } ret = dict_get_str (dict, "master", &volname); if (ret < 0){ - ret = glusterd_get_gsync_status_all (rsp_dict); + ret = glusterd_get_gsync_status_all (rsp_dict, my_hostname); goto out; } @@ -1791,11 +1814,13 @@ glusterd_get_gsync_status (dict_t *dict, char **op_errstr, dict_t *rsp_dict) ret = dict_get_str (dict, "slave", &slave); if (ret < 0) { - ret = glusterd_get_gsync_status_mst (volinfo, rsp_dict); + ret = glusterd_get_gsync_status_mst (volinfo, + rsp_dict, my_hostname); goto out; } - ret = glusterd_get_gsync_status_mst_slv (volinfo, slave, rsp_dict); + ret = glusterd_get_gsync_status_mst_slv (volinfo, slave, + rsp_dict, my_hostname); out: gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h index 558c2d1f755..610b6471a08 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h @@ -160,6 +160,7 @@ typedef struct glusterd_status_rsp_conv_ { typedef struct glusterd_gsync_status_temp { dict_t *rsp_dict; glusterd_volinfo_t *volinfo; + char *node; }glusterd_gsync_status_temp_t; int glusterd_op_sm_new_event (glusterd_op_sm_event_type_t event_type, diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index fab405c7f7d..8dc83d5ef0e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -5799,9 +5799,11 @@ glusterd_append_status_dicts (dict_t *dst, dict_t *src) char mst[PATH_MAX] = {0,}; char slv[PATH_MAX] = {0, }; char sts[PATH_MAX] = {0, }; + char nds[PATH_MAX] = {0, }; char *mst_val = NULL; char *slv_val = NULL; char *sts_val = NULL; + char *nds_val = NULL; GF_ASSERT (dst); @@ -5820,10 +5822,15 @@ glusterd_append_status_dicts (dict_t *dst, dict_t *src) } for (i = 1; i <= src_count; i++) { + snprintf (nds, sizeof(nds), "node%d", i); snprintf (mst, sizeof(mst), "master%d", i); snprintf (slv, sizeof(slv), "slave%d", i); snprintf (sts, sizeof(sts), "status%d", i); + ret = dict_get_str (src, nds, &nds_val); + if (ret) + goto out; + ret = dict_get_str (src, mst, &mst_val); if (ret) goto out; @@ -5836,10 +5843,15 @@ glusterd_append_status_dicts (dict_t *dst, dict_t *src) if (ret) goto out; + snprintf (nds, sizeof(nds), "node%d", i+dst_count); snprintf (mst, sizeof(mst), "master%d", i+dst_count); snprintf (slv, sizeof(slv), "slave%d", i+dst_count); snprintf (sts, sizeof(sts), "status%d", i+dst_count); + ret = dict_set_dynstr (dst, nds, gf_strdup (nds_val)); + if (ret) + goto out; + ret = dict_set_dynstr (dst, mst, gf_strdup (mst_val)); if (ret) goto out; |