summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
diff options
context:
space:
mode:
authorVenky Shankar <vshankar@redhat.com>2012-11-21 12:06:26 +0530
committerAnand Avati <avati@redhat.com>2012-11-21 16:49:04 -0800
commit1f64e5e3dd7f871e112ad9d3e9fae3cc5e15fd88 (patch)
treed8e025a02706520ca8b424dc0d266d1a19413b3d /xlators/mgmt/glusterd/src/glusterd-geo-rep.c
parenta64a0d89d5256386f6773709477aea87823e2e68 (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/glusterd-geo-rep.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c47
1 files changed, 36 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, &param);
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);