diff options
| author | Ravishankar N <ravishankar@redhat.com> | 2016-01-18 12:19:35 +0530 | 
|---|---|---|
| committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2016-01-19 22:31:36 -0800 | 
| commit | 67b7752eccd8eae6a91f3bc3ff55d65dcf858dc7 (patch) | |
| tree | 0c28eb2bc9e2407a7ce72a225690d13ef2882916 | |
| parent | c535059299785f7d050482c257f10389c218048b (diff) | |
cli: Add arbiter details to volinfo xml output
The following are added:
1. "<arbiterCount>1</arbiterCount>" and
"<coldarbiterCount>1</coldarbiterCount>"
2. "<isArbiter>0</isArbiter>" on the brick info, like so:
<brick
uuid="cafa8612-d7d4-4007-beea-72ae7477f3bb">127.0.0.2:/home/ravi/bricks/brick1
<name>127.0.0.2:/home/ravi/bricks/brick1</name>
<hostUuid>cafa8612-d7d4-4007-beea-72ae7477f3bb</hostUuid>
<isArbiter>0</isArbiter>
</brick>
Also fix a bug in gluster vol info where the abiter brick was shown the
wrong brick of the cold tier after performing a tier-attach.
Change-Id: Id978325d02b04f1a08856427827320e169169810
BUG: 1297750
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Reviewed-on: http://review.gluster.org/13229
Smoke: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
| -rw-r--r-- | cli/src/cli-rpc-ops.c | 20 | ||||
| -rw-r--r-- | cli/src/cli-xml-output.c | 50 | ||||
| -rw-r--r-- | cli/src/cli.h | 1 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 50 | 
4 files changed, 112 insertions, 9 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 741fb42b83e..62a113a4dd8 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -547,10 +547,11 @@ out:  static int  print_brick_details (dict_t *dict, int volcount, int start_index, -                     int end_index, int replica_count, int arbiter_count) +                     int end_index, int replica_count)  {          char           key[1024]   = {0,};          int            index       = start_index; +        int            isArbiter   = 0;          int            ret         = -1;          char          *brick       = NULL;  #ifdef HAVE_BD_XLATOR @@ -558,12 +559,20 @@ print_brick_details (dict_t *dict, int volcount, int start_index,  #endif          while (index <= end_index) { +                memset (key, 0, sizeof (key));                  snprintf (key, 1024, "volume%d.brick%d", volcount, index);                  ret = dict_get_str (dict, key, &brick);                  if (ret)                          goto out; +                memset (key, 0, sizeof(key)); +                snprintf (key, sizeof (key), "volume%d.brick%d.isArbiter", +                          volcount, index); +                if (dict_get (dict, key)) +                        isArbiter = 1; +                else +                        isArbiter = 0; -                if (arbiter_count && index % replica_count == 0) +                if (isArbiter)                          cli_out ("Brick%d: %s (arbiter)", index, brick);                  else                          cli_out ("Brick%d: %s", index, brick); @@ -721,7 +730,7 @@ gf_cli_print_tier_info (dict_t *dict, int i, int brick_count)                          hot_replica_count, 0, 0, 0);          ret = print_brick_details (dict, i, 1, hot_brick_count, -                                   hot_replica_count, 0); +                                   hot_replica_count);          if (ret)                  goto out; @@ -740,8 +749,7 @@ gf_cli_print_tier_info (dict_t *dict, int i, int brick_count)                  cold_disperse_count, cold_redundancy_count, cold_arbiter_count);          ret = print_brick_details (dict, i, hot_brick_count+1, -                                   brick_count, cold_replica_count, -                                   cold_arbiter_count); +                                   brick_count, cold_replica_count);          if (ret)                  goto out;  out: @@ -1010,7 +1018,7 @@ next:                  } else {                          cli_out ("Bricks:");                          ret = print_brick_details (dict, i, j, brick_count, -                                                  replica_count, arbiter_count); +                                                  replica_count);                          if (ret)                                  goto out;                  } diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index 7140f803071..f7ae0578b15 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -2551,6 +2551,8 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict)          int                     dist_count = 0;          int                     stripe_count = 0;          int                     replica_count = 0; +        int                     arbiter_count = 0; +        int                     isArbiter = 0;          int                     disperse_count = 0;          int                     redundancy_count = 0;          int                     transport = 0; @@ -2561,6 +2563,7 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict)          char                    *caps = NULL;          int                     k __attribute__((unused)) = 0;          int                     index = 1; +        int                     start_index = 1;          int                     vol_type               = -1;          int                     tier_vol_type          = 0;          /*hot disperse count, redundancy count and dist count are always @@ -2569,17 +2572,18 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict)          int                     hot_dist_count         = 0;          int                     hot_redundancy_count   = 0;          values                  c                      = 0; -        char                    *keys[30]              = { +        char                    *keys[MAX]              = {                  [COLD_BRICK_COUNT]      = "volume%d.cold_brick_count",                  [COLD_TYPE]             = "volume%d.cold_type",                  [COLD_DIST_COUNT]       = "volume%d.cold_dist_count",                  [COLD_REPLICA_COUNT]    = "volume%d.cold_replica_count", +                [COLD_ARBITER_COUNT]    = "volume%d.cold_arbiter_count",                  [COLD_DISPERSE_COUNT]   = "volume%d.cold_disperse_count",                  [COLD_REDUNDANCY_COUNT] = "volume%d.cold_redundancy_count",                  [HOT_BRICK_COUNT]       = "volume%d.hot_brick_count",                  [HOT_TYPE]              = "volume%d.hot_type",                  [HOT_REPLICA_COUNT]     = "volume%d.hot_replica_count"}; -        int                     value[9]             = {}; +        int                     value[MAX]             = {};          ret = dict_get_int32 (dict, "count", &count); @@ -2668,6 +2672,16 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict)                  XML_RET_CHECK_AND_GOTO (ret, out);                  memset (key, 0, sizeof (key)); +                snprintf (key, sizeof (key), "volume%d.arbiter_count", i); +                ret = dict_get_int32 (dict, key, &arbiter_count); +                if (ret) +                        goto out; +                ret = xmlTextWriterWriteFormatElement (local->writer, +                                                      (xmlChar *)"arbiterCount", +                                                      "%d", arbiter_count); +                XML_RET_CHECK_AND_GOTO (ret, out); + +                memset (key, 0, sizeof (key));                  snprintf (key, sizeof (key), "volume%d.disperse_count", i);                  ret = dict_get_int32 (dict, key, &disperse_count);                  if (ret) @@ -2910,6 +2924,11 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict)                          XML_RET_CHECK_AND_GOTO (ret, out);                          ret = xmlTextWriterWriteFormatElement (local->writer, +                                        (xmlChar *)"coldarbiterCount", +                                        "%d", value[COLD_ARBITER_COUNT]); +                        XML_RET_CHECK_AND_GOTO (ret, out); + +                        ret = xmlTextWriterWriteFormatElement (local->writer,                                                     (xmlChar *)"coldbrickCount",                                                      "%d",                                                      value[COLD_BRICK_COUNT]); @@ -2952,7 +2971,7 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict)                                           value[COLD_BRICK_COUNT]);                          } -                        index = value[HOT_BRICK_COUNT] + 1; +                        start_index = index = value[HOT_BRICK_COUNT] + 1;                          while (index <= brick_count) {                                  snprintf (key, 1024, "volume%d.brick%d", i, @@ -2990,6 +3009,19 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict)                                           "%s", uuid);                                  XML_RET_CHECK_AND_GOTO (ret, out); +                                memset (key, 0, sizeof (key)); +                                snprintf (key, sizeof (key), +                                          "volume%d.brick%d.isArbiter", i, +                                          index); +                                if (dict_get (dict, key)) +                                        isArbiter = 1; +                                else +                                        isArbiter = 0; +                                ret = xmlTextWriterWriteFormatElement +                                        (local->writer, (xmlChar *)"isArbiter", +                                         "%d", isArbiter); +                                XML_RET_CHECK_AND_GOTO (ret, out); +                                  ret = xmlTextWriterEndElement (local->writer);                                  XML_RET_CHECK_AND_GOTO (ret, out); @@ -3035,6 +3067,18 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict)                                           "%s", uuid);                                  XML_RET_CHECK_AND_GOTO (ret, out); +                                memset (key, 0, sizeof (key)); +                                snprintf (key, sizeof (key), +                                          "volume%d.brick%d.isArbiter", i, j); +                                if (dict_get (dict, key)) +                                        isArbiter = 1; +                                else +                                        isArbiter = 0; +                                ret = xmlTextWriterWriteFormatElement +                                        (local->writer, (xmlChar *)"isArbiter", +                                         "%d", isArbiter); +                                XML_RET_CHECK_AND_GOTO (ret, out); +                                  /* </brick> */                                  ret = xmlTextWriterEndElement (local->writer);                                  XML_RET_CHECK_AND_GOTO (ret, out); diff --git a/cli/src/cli.h b/cli/src/cli.h index 68cdb671628..95593e6313f 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -47,6 +47,7 @@ typedef enum {          COLD_TYPE,          COLD_DIST_COUNT,          COLD_REPLICA_COUNT, +        COLD_ARBITER_COUNT,          COLD_DISPERSE_COUNT,          COLD_REDUNDANCY_COUNT,          HOT_BRICK_COUNT, diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 3c4516b76e0..608b6dd5d35 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -405,6 +405,53 @@ out:  }  int +glusterd_add_arbiter_info_to_bricks (glusterd_volinfo_t *volinfo, +                                     dict_t *volumes, int count) +{ +        char                    key[256]    = {0, }; +        int                     i           = 0; +        int                     start_index = 0; +        int                     ret         = 0; + +        if (volinfo->type == GF_CLUSTER_TYPE_TIER) { +                /*TODO: Add info for hot tier once attach tier of arbiter +                 * volumes is supported. */ + +                /* cold tier */ +                if (volinfo->tier_info.cold_replica_count == 1 || +                    volinfo->arbiter_count != 1) +                        return 0; + +                i = start_index = volinfo->tier_info.hot_brick_count + 1; +                for (; i <= volinfo->brick_count; i++) { +                        if ((i - start_index + 1) % +                            volinfo->tier_info.cold_replica_count != 0) +                                continue; +                        memset (key, 0, sizeof (key)); +                        snprintf (key, 256, "volume%d.brick%d.isArbiter", +                                  count, i); +                        ret = dict_set_int32 (volumes, key, 1); +                        if (ret) +                                return ret; +                } +        } else { +                if (volinfo->replica_count == 1 || volinfo->arbiter_count != 1) +                        return 0; +                for (i = 1; i <= volinfo->brick_count; i++) { +                        if (i % volinfo->replica_count != 0) +                                continue; +                        memset (key, 0, sizeof (key)); +                        snprintf (key, 256, "volume%d.brick%d.isArbiter", +                                  count, i); +                        ret = dict_set_int32 (volumes, key, 1); +                        if (ret) +                                return ret; +                } +        } +        return 0; +} + +int  glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,                                      dict_t  *volumes, int count)  { @@ -625,6 +672,9 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,  #endif                  i++;          } +        ret = glusterd_add_arbiter_info_to_bricks (volinfo, volumes, count); +        if (ret) +                goto out;          dict = volinfo->dict;          if (!dict) {  | 
