summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2013-01-23 14:11:44 +0530
committerAnand Avati <avati@redhat.com>2013-02-04 14:24:55 -0800
commitc6116f744fe4791a8fa54778840316275e473587 (patch)
tree22b28f8c059a77695de1682443d23134a1d22de1 /xlators/mgmt/glusterd/src
parent99c86cc5aefab052c924b2ff31197d02602da4f1 (diff)
glusterd: Indexed node information in dict to retain consistency.
Problem: -------- Depending on the response time from different nodes, the response dict for rebalance status was populated in a FIFO manner, and hence the output for the CLI was never consistent. Fix: ---- Irrespective of the response time of the nodes, we now index the entries in the response dict for rebalance status, in reference to the peerlist. So, the order of the entries and hence the CLI output is always consistent. Change-Id: Ica7e89e5d95aa9860a6f3c7eff58ca2052e05bd6 BUG: 888390 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/4416 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c94
1 files changed, 55 insertions, 39 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 97081355df2..f99758d5f51 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -6761,21 +6761,25 @@ out:
int
glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
{
- int ret = 0;
- dict_t *ctx_dict = NULL;
- glusterd_op_t op = GD_OP_NONE;
- uint64_t value = 0;
- int32_t value32 = 0;
- char *volname = NULL;
- glusterd_volinfo_t *volinfo = NULL;
- char key[256] = {0,};
- int32_t index = 0;
- int32_t i = 0;
- char *node_uuid = NULL;
- char *node_uuid_str = NULL;
- double elapsed_time = 0;
+ char key[256] = {0,};
+ char *node_uuid = NULL;
+ char *node_uuid_str = NULL;
+ char *volname = NULL;
+ dict_t *ctx_dict = NULL;
+ double elapsed_time = 0;
+ glusterd_conf_t *conf = NULL;
+ glusterd_op_t op = GD_OP_NONE;
+ glusterd_peerinfo_t *peerinfo = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ int ret = 0;
+ int32_t index = 0;
+ int32_t count = 0;
+ int32_t current_index = 2;
+ int32_t value32 = 0;
+ uint64_t value = 0;
GF_ASSERT (rsp_dict);
+ conf = THIS->private;
op = glusterd_op_get_op ();
GF_ASSERT ((GD_OP_REBALANCE == op) ||
@@ -6792,12 +6796,6 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
if (!ctx_dict)
goto out;
- ret = dict_get_int32 (ctx_dict, "count", &i);
- i++;
- ret = dict_set_int32 (ctx_dict, "count", i);
- if (ret)
- gf_log ("", GF_LOG_ERROR, "Failed to set index");
-
ret = dict_get_str (ctx_dict, "volname", &volname);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to get volume name");
@@ -6813,11 +6811,43 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
if (ret)
gf_log ("", GF_LOG_ERROR, "failed to get index");
+ memset (key, 0, 256);
+ snprintf (key, 256, "node-uuid-%d", index);
+ ret = dict_get_str (rsp_dict, key, &node_uuid);
+ if (!ret) {
+ node_uuid_str = gf_strdup (node_uuid);
+
+ /* Finding the index of the node-uuid in the peer-list */
+ list_for_each_entry (peerinfo, &conf->peers, uuid_list) {
+ if (!strcmp(peerinfo->uuid_str, node_uuid_str)){
+ break;
+ }
+ current_index++;
+ }
+
+ /* Setting the largest index value as the total count. */
+ ret = dict_get_int32 (ctx_dict, "count", &count);
+ if (count < current_index) {
+ ret = dict_set_int32 (ctx_dict, "count", current_index);
+ if (ret)
+ gf_log ("", GF_LOG_ERROR, "Failed to set count");
+ }
+
+ /* Setting the same index for the node, as is in the peerlist.*/
+ memset (key, 0, 256);
+ snprintf (key, 256, "node-uuid-%d", current_index);
+ ret = dict_set_dynstr (ctx_dict, key, node_uuid_str);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_DEBUG,
+ "failed to set node-uuid");
+ }
+ }
+
snprintf (key, 256, "files-%d", index);
ret = dict_get_uint64 (rsp_dict, key, &value);
if (!ret) {
memset (key, 0, 256);
- snprintf (key, 256, "files-%d", i);
+ snprintf (key, 256, "files-%d", current_index);
ret = dict_set_uint64 (ctx_dict, key, value);
if (ret) {
gf_log (THIS->name, GF_LOG_DEBUG,
@@ -6830,7 +6860,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
ret = dict_get_uint64 (rsp_dict, key, &value);
if (!ret) {
memset (key, 0, 256);
- snprintf (key, 256, "size-%d", i);
+ snprintf (key, 256, "size-%d", current_index);
ret = dict_set_uint64 (ctx_dict, key, value);
if (ret) {
gf_log (THIS->name, GF_LOG_DEBUG,
@@ -6843,7 +6873,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
ret = dict_get_uint64 (rsp_dict, key, &value);
if (!ret) {
memset (key, 0, 256);
- snprintf (key, 256, "lookups-%d", i);
+ snprintf (key, 256, "lookups-%d", current_index);
ret = dict_set_uint64 (ctx_dict, key, value);
if (ret) {
gf_log (THIS->name, GF_LOG_DEBUG,
@@ -6856,7 +6886,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
ret = dict_get_int32 (rsp_dict, key, &value32);
if (!ret) {
memset (key, 0, 256);
- snprintf (key, 256, "status-%d", i);
+ snprintf (key, 256, "status-%d", current_index);
ret = dict_set_int32 (ctx_dict, key, value32);
if (ret) {
gf_log (THIS->name, GF_LOG_DEBUG,
@@ -6865,25 +6895,11 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
}
memset (key, 0, 256);
- snprintf (key, 256, "node-uuid-%d", index);
- ret = dict_get_str (rsp_dict, key, &node_uuid);
- if (!ret) {
- memset (key, 0, 256);
- snprintf (key, 256, "node-uuid-%d", i);
- node_uuid_str = gf_strdup (node_uuid);
- ret = dict_set_dynstr (ctx_dict, key, node_uuid_str);
- if (ret) {
- gf_log (THIS->name, GF_LOG_DEBUG,
- "failed to set node-uuid");
- }
- }
-
- memset (key, 0, 256);
snprintf (key, 256, "failures-%d", index);
ret = dict_get_uint64 (rsp_dict, key, &value);
if (!ret) {
memset (key, 0, 256);
- snprintf (key, 256, "failures-%d", i);
+ snprintf (key, 256, "failures-%d", current_index);
ret = dict_set_uint64 (ctx_dict, key, value);
if (ret) {
gf_log (THIS->name, GF_LOG_DEBUG,
@@ -6896,7 +6912,7 @@ glusterd_volume_rebalance_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
ret = dict_get_double (rsp_dict, key, &elapsed_time);
if (!ret) {
memset (key, 0, 256);
- snprintf (key, 256, "run-time-%d", i);
+ snprintf (key, 256, "run-time-%d", current_index);
ret = dict_set_double (ctx_dict, key, elapsed_time);
if (ret) {
gf_log (THIS->name, GF_LOG_DEBUG,