summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-rpc-ops.c
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2011-03-31 04:56:10 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-31 05:04:36 -0700
commit58974b02b6ebb65ee1f7baf23b0fe6c3e7fcf8cd (patch)
tree20cfa527ff37e8a6b2a17aa871e2f0bdca939db2 /cli/src/cli-rpc-ops.c
parent3b5195cfa4976e1d83646b70b0f08f583a7a1094 (diff)
TOP: handle list-cnt behaviour uniformly.
Valid range is 0-100. if list-cnt is 0 or there are no files in the list, handle it uniformly. Signed-off-by: shishir gowda <shishirng@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2622 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2622
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r--cli/src/cli-rpc-ops.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 92658af4735..e1f51d306ec 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -3184,7 +3184,7 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,
dict_t *dict = NULL;
gf1_cli_stats_op op = GF_CLI_STATS_NONE;
char key[256] = {0};
- int i = 1;
+ int i = 0;
int32_t brick_count = 0;
char brick[1024];
int32_t members = 0;
@@ -3251,16 +3251,20 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,
ret = dict_get_int32 (dict, "count", &brick_count);
if (ret)
goto out;
- snprintf (key, sizeof (key), "%d-top-op", i);
+ snprintf (key, sizeof (key), "%d-top-op", 1);
ret = dict_get_int32 (dict, key, (int32_t*)&top_op);
if (ret)
goto out;
while (i <= brick_count) {
+ i++;
snprintf (brick, sizeof (brick), "%d-brick", i);
ret = dict_get_str (dict, brick, &bricks);
if (ret)
goto out;
cli_out ("Brick: %s", bricks);
+ snprintf(key, sizeof (key), "%d-members", i);
+ ret = dict_get_int32 (dict, key, &members);
+
switch (top_op) {
case GF_CLI_TOP_OPEN:
snprintf (key, sizeof (key), "%d-current-open", i);
@@ -3277,6 +3281,10 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,
case GF_CLI_TOP_WRITE:
case GF_CLI_TOP_OPENDIR:
case GF_CLI_TOP_READDIR:
+ if (!members) {
+ cli_out ("No entries in list");
+ continue;
+ }
cli_out ("Count\t\tfilename\n=======================");
break;
case GF_CLI_TOP_READ_PERF:
@@ -3291,13 +3299,16 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,
cli_out ("Throughput %.2f MBps time %.4f secs", throughput,
time / 1e6);
+ if (!members) {
+ cli_out ("No entries in list");
+ continue;
+ }
cli_out ("MBps\t\tfilename\t\t time\n========================");
break;
default:
goto out;
}
- snprintf(key, sizeof (key), "%d-members", i);
- ret = dict_get_int32 (dict, key, &members);
+
for (j = 1; j <= members; j++) {
snprintf (key, sizeof (key), "%d-filename-%d", i, j);
ret = dict_get_str (dict, key, &filename);
@@ -3329,7 +3340,6 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,
cli_out ("%"PRIu64"\t\t%s", value, filename);
}
}
- i++;
}
ret = rsp.op_ret;