summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2015-04-22 20:07:11 +0530
committerVijay Bellur <vbellur@redhat.com>2015-05-10 03:38:39 -0700
commit4b7914384e2613e5ec7c618071cb89187ed6f870 (patch)
tree6d89a1e3f8a788b484dbcf36d37613f52d5f72c1 /cli
parent7c1415fa591172765ab1e7dc1b049bf162d53788 (diff)
cli/tiering: volume info should display details about tier
>> gluster volume info patchy Volume Name: patchy Type: Tier Volume ID: 8bf1a1ca-6417-484f-821f-18973a7502a8 Status: Created Number of Bricks: 8 Transport-type: tcp Hot Tier : Hot Tier Type : Replicate Number of Bricks: 1 x 2 = 2 Brick1: hostname:/home/brick30 Brick2: hostname:/home/brick31 Cold Bricks: Cold Tier Type : Disperse Number of Bricks: 1 x (4 + 2) = 6 Brick3: hostname:/home/brick20 Brick4: hostname:/home/brick21 Brick5: hostname:/home/brick23 Brick6: hostname:/home/brick24 Brick7: hostname:/home/brick25 Brick8: hostname:/home/brick26 Change-Id: I7b9025af81263ebecd641b4b6897b20db8b67195 BUG: 1212400 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com> Reviewed-on: http://review.gluster.org/10339 Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-rpc-ops.c182
1 files changed, 148 insertions, 34 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index e81e8b0828f..f3ed8adfdc2 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -581,6 +581,150 @@ print_brick_details (dict_t *dict, int volcount, int start_index,
out:
return ret;
}
+void
+gf_cli_print_number_of_bricks (int type, int brick_count, int dist_count,
+ int stripe_count, int replica_count,
+ int disperse_count, int redundancy_count)
+{
+ if (type == GF_CLUSTER_TYPE_STRIPE_REPLICATE) {
+ cli_out ("Number of Bricks: %d x %d x %d = %d",
+ (brick_count / dist_count),
+ stripe_count,
+ replica_count,
+ brick_count);
+ } else if (type == GF_CLUSTER_TYPE_NONE ||
+ type == GF_CLUSTER_TYPE_TIER) {
+ cli_out ("Number of Bricks: %d", brick_count);
+ } else if (type == GF_CLUSTER_TYPE_DISPERSE) {
+ cli_out ("Number of Bricks: %d x (%d + %d) = %d",
+ (brick_count / dist_count),
+ disperse_count - redundancy_count,
+ redundancy_count, brick_count);
+ } else {
+ /* For both replicate and stripe, dist_count is
+ good enough */
+ cli_out ("Number of Bricks: %d x %d = %d",
+ (brick_count / dist_count),
+ dist_count, brick_count);
+ }
+
+}
+
+int
+gf_cli_print_tier_info (dict_t *dict, int i, int brick_count)
+{
+
+ int hot_brick_count = -1;
+ int cold_type = 0;
+ int cold_brick_count = 0;
+ int cold_replica_count = 0;
+ int cold_disperse_count = 0;
+ int cold_redundancy_count = 0;
+ int cold_dist_count = 0;
+ int hot_type = 0;
+ int hot_replica_count = 0;
+ int hot_dist_count = 0;
+ int ret = -1;
+ int vol_type = -1;
+ char key[256] = {0,};
+
+ GF_ASSERT (dict);
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, 256, "volume%d.cold_brick_count", i);
+ ret = dict_get_int32 (dict, key, &cold_brick_count);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, 256, "volume%d.cold_type", i);
+ ret = dict_get_int32 (dict, key, &cold_type);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, 256, "volume%d.cold_dist_count", i);
+ ret = dict_get_int32 (dict, key, &cold_dist_count);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, 256, "volume%d.cold_replica_count", i);
+ ret = dict_get_int32 (dict, key, &cold_replica_count);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, 256, "volume%d.cold_disperse_count", i);
+ ret = dict_get_int32 (dict, key, &cold_disperse_count);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, 256,
+ "volume%d.cold_redundancy_count", i);
+ ret = dict_get_int32 (dict, key,
+ &cold_redundancy_count);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, 256, "volume%d.hot_brick_count", i);
+ ret = dict_get_int32 (dict, key, &hot_brick_count);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, 256, "volume%d.hot_type", i);
+ ret = dict_get_int32 (dict, key, &hot_type);
+ if (ret)
+ goto out;
+ memset (key, 0, sizeof (key));
+ snprintf (key, 256, "volume%d.hot_replica_count", i);
+ ret = dict_get_int32 (dict, key, &hot_replica_count);
+ if (ret)
+ goto out;
+
+ cli_out ("Hot Tier :");
+ vol_type = hot_type;
+ hot_dist_count = (hot_replica_count ?
+ hot_replica_count : 1);
+ if ((hot_type != GF_CLUSTER_TYPE_TIER) &&
+ (hot_type > 0) &&
+ (hot_dist_count < hot_brick_count))
+ vol_type = hot_type + GF_CLUSTER_TYPE_MAX - 1;
+
+ cli_out ("Hot Tier Type : %s",
+ cli_vol_type_str[vol_type]);
+ gf_cli_print_number_of_bricks (hot_type,
+ hot_brick_count, hot_dist_count, 0,
+ hot_replica_count, 0, 0);
+
+ ret = print_brick_details (dict, i, 1, hot_brick_count);
+ if (ret)
+ goto out;
+
+ cli_out ("Cold Bricks:");
+ vol_type = cold_type;
+ if ((cold_type != GF_CLUSTER_TYPE_TIER) &&
+ (cold_type > 0) &&
+ (cold_dist_count < cold_brick_count))
+ vol_type = cold_type + GF_CLUSTER_TYPE_MAX - 1;
+
+ cli_out ("Cold Tier Type : %s",
+ cli_vol_type_str[vol_type]);
+ gf_cli_print_number_of_bricks (cold_type,
+ cold_brick_count,
+ cold_dist_count, 0, cold_replica_count,
+ cold_disperse_count, cold_redundancy_count);
+
+ ret = print_brick_details (dict, i, hot_brick_count+1,
+ brick_count);
+ if (ret)
+ goto out;
+out:
+ return ret;
+}
int
gf_cli_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
@@ -593,7 +737,6 @@ gf_cli_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
int32_t status = 0;
int32_t type = 0;
int32_t brick_count = 0;
- int32_t hot_brick_count = -1;
int32_t dist_count = 0;
int32_t stripe_count = 0;
int32_t replica_count = 0;
@@ -737,11 +880,6 @@ xml_output:
if (ret)
goto out;
- snprintf (key, 256, "volume%d.hot_brick_count", i);
- ret = dict_get_int32 (dict, key, &hot_brick_count);
- if (ret)
- goto out;
-
snprintf (key, 256, "volume%d.dist_count", i);
ret = dict_get_int32 (dict, key, &dist_count);
if (ret)
@@ -822,27 +960,9 @@ next:
#else
caps = 0; /* Avoid compiler warnings when BD not enabled */
#endif
-
- if (type == GF_CLUSTER_TYPE_STRIPE_REPLICATE) {
- cli_out ("Number of Bricks: %d x %d x %d = %d",
- (brick_count / dist_count),
- stripe_count,
- replica_count,
- brick_count);
- } else if (type == GF_CLUSTER_TYPE_NONE) {
- cli_out ("Number of Bricks: %d", brick_count);
- } else if (type == GF_CLUSTER_TYPE_DISPERSE) {
- cli_out ("Number of Bricks: %d x (%d + %d) = %d",
- (brick_count / dist_count),
- disperse_count - redundancy_count,
- redundancy_count, brick_count);
- } else {
- /* For both replicate and stripe, dist_count is
- good enough */
- cli_out ("Number of Bricks: %d x %d = %d",
- (brick_count / dist_count),
- dist_count, brick_count);
- }
+ gf_cli_print_number_of_bricks (type, brick_count,
+ dist_count, stripe_count, replica_count,
+ disperse_count, redundancy_count);
cli_out ("Transport-type: %s",
((transport == 0)?"tcp":
@@ -854,13 +974,7 @@ next:
local->get_vol.volname = gf_strdup (volname);
if (type == GF_CLUSTER_TYPE_TIER) {
- cli_out ("Hot Bricks:");
- ret = print_brick_details (dict, i, j, hot_brick_count);
- if (ret)
- goto out;
- cli_out ("Cold Bricks:");
- ret = print_brick_details (dict, i, hot_brick_count+1,
- brick_count);
+ ret = gf_cli_print_tier_info (dict, i, brick_count);
if (ret)
goto out;