summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-rpc-ops.c
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2017-01-17 15:43:47 +0530
committerRaghavendra G <rgowdapp@redhat.com>2017-01-19 20:01:47 -0800
commit2edd75ec8de17da89004859375844f60890a4df0 (patch)
tree4ff010534660c47c2475e2af27478f2c4a2c920f /cli/src/cli-rpc-ops.c
parent7b5b7111c9d9a2a65e4f4d0abf832a88e021c576 (diff)
dht/rebalance Estimate time to complete rebalance
The estimates will be logged to the rebalance log on running gluster v rebalance <vol> status Change-Id: I9d51b139cd4c8dfde1ff2c2050720ae606c13fc6 BUG: 1396004 Signed-off-by: N Balachandran <nbalacha@redhat.com> Reviewed-on: http://review.gluster.org/15893 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r--cli/src/cli-rpc-ops.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 59a1a4c1266..b56457ecf63 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -1608,6 +1608,9 @@ gf_cli_print_rebalance_status (dict_t *dict, enum gf_task_types task_type,
int sec = 0;
gf_boolean_t down = _gf_false;
gf_boolean_t fix_layout = _gf_false;
+ uint64_t max_time = 0;
+ uint64_t time_left = 0;
+
ret = dict_get_int32 (dict, "count", &count);
if (ret) {
@@ -1660,6 +1663,7 @@ gf_cli_print_rebalance_status (dict_t *dict, enum gf_task_types task_type,
skipped = 0;
status_str = NULL;
elapsed = 0;
+ time_left = 0;
/* Check if status is NOT_STARTED, and continue early */
memset (key, 0, 256);
@@ -1737,6 +1741,15 @@ gf_cli_print_rebalance_status (dict_t *dict, enum gf_task_types task_type,
if (ret)
gf_log ("cli", GF_LOG_TRACE, "failed to get run-time");
+ memset (key, 0, 256);
+ snprintf (key, 256, "time-left-%d", i);
+ ret = dict_get_uint64 (dict, key, &time_left);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE,
+ "failed to get time left");
+ if (time_left > max_time)
+ max_time = time_left;
+
/* Check for array bound */
if (status_rcd >= GF_DEFRAG_STATUS_MAX)
status_rcd = GF_DEFRAG_STATUS_MAX;
@@ -1754,15 +1767,15 @@ gf_cli_print_rebalance_status (dict_t *dict, enum gf_task_types task_type,
if (size_str) {
cli_out ("%40s %16"PRIu64 " %13s" " %13"PRIu64
" %13" PRIu64" %13"PRIu64 " %20s "
- "%8d:%d:%d", node_name, files,
+ "%8d:%02d:%02d", node_name, files,
size_str, lookup, failures, skipped,
status_str, hrs, min, sec);
} else {
cli_out ("%40s %16"PRIu64 " %13"PRIu64 " %13"
PRIu64 " %13"PRIu64" %13"PRIu64 " %20s"
- " %8d:%d:%d", node_name, files, size,
- lookup, failures, skipped, status_str,
- hrs, min, sec);
+ " %8d:%02d:%02d", node_name, files,
+ size, lookup, failures, skipped,
+ status_str, hrs, min, sec);
}
}
GF_FREE(size_str);
@@ -1772,6 +1785,13 @@ gf_cli_print_rebalance_status (dict_t *dict, enum gf_task_types task_type,
" Please check the nodes that are down using \'gluster"
" peer status\' and start the glusterd on those nodes,"
" else tier detach commit might fail!");
+ if (max_time) {
+ hrs = max_time / 3600;
+ min = ((int) max_time % 3600) / 60;
+ sec = ((int) max_time % 3600) % 60;
+ cli_out ("Estimated time left for rebalance to complete :"
+ " %8d:%02d:%02d", hrs, min, sec);
+ }
out:
return ret;
}