diff options
| author | hari gowtham <hgowtham@redhat.com> | 2017-08-21 15:41:42 +0530 | 
|---|---|---|
| committer | Atin Mukherjee <amukherj@redhat.com> | 2017-09-06 11:52:40 +0000 | 
| commit | ecef90aa414a4dcb0a0d520be2334f03d06a4451 (patch) | |
| tree | 5559c8f7671dd487af8c4205626024a688a1d078 /xlators/mgmt/glusterd/src | |
| parent | b1b49997574eeb7c6a42e6e8257c81ac8d2d7578 (diff) | |
Command to identify client process
command: gluster volume status <volname/all> client-list
output:
Client connections for volume v1
Name                                                       count
-----                                                     ------
fuse                                                           2
tierd                                                          1
total clients for volume v1 : 3
-----------------------------------------------------------------
Client connections for volume v2
Name                                                       count
-----                                                     ------
tierd                                                          1
fuse.gsync                                                     1
total clients for volume v2 : 2
-----------------------------------------------------------------
Updates: #178
Change-Id: I0ff2579d6adf57cc0d3bd0161a2ec6ac6c4747c0
Signed-off-by: hari gowtham <hgowtham@redhat.com>
Reviewed-on: https://review.gluster.org/18095
Smoke: Gluster Build System <jenkins@build.gluster.org>
Tested-by: hari gowtham <hari.gowtham005@gmail.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src')
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 10 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 1 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-syncop.c | 12 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 210 | 
4 files changed, 229 insertions, 4 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index c0929fa8192..a3ff49de173 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -4303,6 +4303,16 @@ __glusterd_handle_status_volume (rpcsvc_request_t *req)                          "Received status volume req for volume %s", volname);          } +        if ((cmd & GF_CLI_STATUS_CLIENT_LIST) && +            (conf->op_version < GD_OP_VERSION_4_0_0)) { +                snprintf (err_str, sizeof (err_str), "The cluster is operating " +                          "at version less than %d. Getting the client-list " +                          "is not allowed in this state.", +                          GD_OP_VERSION_4_0_0); +                ret = -1; +                goto out; +        } +          if ((cmd & GF_CLI_STATUS_QUOTAD) &&              (conf->op_version == GD_OP_VERSION_MIN)) {                  snprintf (err_str, sizeof (err_str), "The cluster is operating " diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index b461edba106..28f36d7c268 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -7281,6 +7281,7 @@ glusterd_bricks_select_status_volume (dict_t *dict, char **op_errstr,          case GF_CLI_STATUS_TIERD:          case GF_CLI_STATUS_BITD:          case GF_CLI_STATUS_SCRUB: +        case GF_CLI_STATUS_CLIENT_LIST:                  break;          default:                  goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c index e327c168d20..aa47517c356 100644 --- a/xlators/mgmt/glusterd/src/glusterd-syncop.c +++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c @@ -987,7 +987,6 @@ gd_syncop_mgmt_brick_op (struct rpc_clnt *rpc, glusterd_pending_node_t *pnode,                  else                          GF_FREE (args.errstr);          } -          if (op == GD_OP_STOP_VOLUME || op == GD_OP_REMOVE_BRICK) {                  if (args.op_ret == 0) {                          brickinfo = pnode->node; @@ -1758,7 +1757,16 @@ gd_brick_op_phase (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,                  }                  ret = gd_syncop_mgmt_brick_op (rpc, pending_node, op, req_dict,                                                 op_ctx, op_errstr); -                if (cmd == GF_OP_CMD_DETACH_START) { +                if (op == GD_OP_STATUS_VOLUME) { +                        /* for client-list its enough to quit the loop +                         * once we get the value from one brick +                         * */ +                        ret = dict_get_int32 (req_dict, "cmd", &cmd); +                        if (!ret && (cmd & GF_CLI_STATUS_CLIENT_LIST)) { +                                if (dict_get (op_ctx, "client-count")) +                                        break; +                        } +                } else if (cmd == GF_OP_CMD_DETACH_START) {                          op = GD_OP_REMOVE_BRICK;                          dict_del (req_dict, "rebalance-command");                  } else if (cmd == GF_DEFRAG_CMD_DETACH_START) { diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index fbf192ebdb7..b861edf4a20 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -11378,6 +11378,206 @@ out:  }  int +glusterd_status_volume_client_list (dict_t *rsp_dict, dict_t *op_ctx, +                                  char **op_errstr) +{ +        int                             ret             = 0; +        char                            *process        = 0; +        int32_t                         count           = 0; +        int32_t                         fuse_count      = 0; +        int32_t                         gfapi_count     = 0; +        int32_t                         tierd_count     = 0; +        int32_t                         rebalance_count = 0; +        int32_t                         glustershd_count = 0; +        int32_t                         quotad_count    = 0; +        int32_t                         snapd_count     = 0; +        int32_t                         client_count    = 0; +        int                             i               = 0; +        char                            key[256]        = {0,}; + +        GF_ASSERT (rsp_dict); +        GF_ASSERT (op_ctx); +        GF_ASSERT (op_errstr); + +        ret = dict_get_int32 (rsp_dict, "clientcount", &client_count); +        if (ret) { +                gf_msg (THIS->name, GF_LOG_INFO, 0, +                                GD_MSG_DICT_GET_FAILED, +                        "Couldn't get node index"); +        } +        ret = dict_set_int32 (op_ctx, "client-count", client_count); +        if (ret) { +                gf_msg (THIS->name, GF_LOG_ERROR, 0, +                                GD_MSG_DICT_GET_FAILED, +                                "Couldn't get node index"); +                goto out; +        } +        for (i = 0; i < client_count; i++) { +                count = 0; +                snprintf (key, sizeof (key), "client%d.name", i); +                ret = dict_get_str (rsp_dict, key, &process); +                if (ret) { +                        gf_msg (THIS->name, GF_LOG_INFO, 0, +                                GD_MSG_DICT_GET_FAILED, +                                "Couldn't get client name"); +                        goto out; +                } +                ret = dict_add_dynstr_with_alloc (op_ctx, key, process); +                if (ret) { +                        gf_msg (THIS->name, GF_LOG_INFO, 0, +                                        GD_MSG_DICT_SET_FAILED, +                                        "Couldn't set client name"); +                } +                if (!strncmp(process, "fuse", 4)) { +                        ret = dict_get_int32 (op_ctx, "fuse-count", +                                              &count); +                        if (ret) { +                                gf_msg (THIS->name, GF_LOG_INFO, 0, +                                        GD_MSG_DICT_GET_FAILED, +                                        "Couldn't get fuse-count"); +                        } +                        fuse_count++; +                        continue; +                } else if (!strncmp(process, "gfapi", 5)) { +                        ret = dict_get_int32 (op_ctx, "gfapi-count", +                                              &count); +                        if (ret) { +                                gf_msg (THIS->name, GF_LOG_INFO, 0, +                                        GD_MSG_DICT_GET_FAILED, +                                        "Couldn't get gfapi-count"); +                        } +                        gfapi_count++; +                        continue; + +                } else if (!strcmp(process, "tierd")) { +                        ret = dict_get_int32 (op_ctx, "tierd-count", +                                              &count); +                        if (ret) { +                                gf_msg (THIS->name, GF_LOG_INFO, 0, +                                        GD_MSG_DICT_GET_FAILED, +                                        "Couldn't get tierd-count"); +                        } +                        tierd_count++; +                        continue; +                } else if (!strcmp(process, "rebalance")) { +                        ret = dict_get_int32 (op_ctx, "rebalance-count", +                                              &count); +                        if (ret) { +                                gf_msg (THIS->name, GF_LOG_INFO, 0, +                                        GD_MSG_DICT_GET_FAILED, +                                        "Couldn't get rebalance-count"); +                        } +                        rebalance_count++; +                        continue; +                } else if (!strcmp(process, "glustershd")) { +                        ret = dict_get_int32 (op_ctx, +                                              "glustershd-count", &count); +                        if (ret) { +                                gf_msg (THIS->name, GF_LOG_INFO, 0, +                                        GD_MSG_DICT_GET_FAILED, +                                        "Couldn't get glustershd-count"); +                        } +                        glustershd_count++; +                        continue; +                } else if (!strcmp(process, "quotad")) { +                        ret = dict_get_int32 (op_ctx, "quotad-count", +                                              &count); +                        if (ret) { +                                gf_msg (THIS->name, GF_LOG_INFO, 0, +                                        GD_MSG_DICT_GET_FAILED, +                                        "Couldn't get quotad-count"); +                        } +                        quotad_count++; +                        continue; +                } else if (!strcmp(process, "snapd")) { +                        ret = dict_get_int32 (op_ctx, "snapd-count", +                                              &count); +                        if (ret) { +                                gf_msg (THIS->name, GF_LOG_INFO, 0, +                                        GD_MSG_DICT_GET_FAILED, +                                        "Couldn't get snapd-count"); +                        } +                        snapd_count++; + +                } +        } + +        if (fuse_count) { +                ret = dict_set_int32 (op_ctx, "fuse-count", +                                      fuse_count); +                if (ret) { +                        gf_msg (THIS->name, GF_LOG_ERROR, 0, +                                GD_MSG_DICT_SET_FAILED, +                                "Couldn't set fuse-count"); +                        goto out; +                } +        } +        if (gfapi_count) { +                ret = dict_set_int32 (op_ctx, "gfapi-count", +                                      gfapi_count); +                if (ret) { +                        gf_msg (THIS->name, GF_LOG_ERROR, 0, +                                GD_MSG_DICT_SET_FAILED, +                                "Couldn't set gfapi-count"); +                        goto out; +                } +        } +        if (tierd_count) { +                ret = dict_set_int32 (op_ctx, "tierd-count", +                                      tierd_count); +                if (ret) { +                        gf_msg (THIS->name, GF_LOG_ERROR, 0, +                                GD_MSG_DICT_SET_FAILED, +                                "Couldn't set tierd-count"); +                        goto out; +                } +        } +        if (rebalance_count) { +                ret = dict_set_int32 (op_ctx, "rebalance-count", +                                      rebalance_count); +                if (ret) { +                        gf_msg (THIS->name, GF_LOG_ERROR, 0, +                                GD_MSG_DICT_SET_FAILED, +                                "Couldn't set rebalance-count"); +                        goto out; +                } +        } +        if (glustershd_count) { +                ret = dict_set_int32 (op_ctx, "glustershd-count", +                                      glustershd_count); +                if (ret) { +                        gf_msg (THIS->name, GF_LOG_ERROR, 0, +                                GD_MSG_DICT_SET_FAILED, +                                "Couldn't set glustershd-count"); +                        goto out; +                } +        } +        if (quotad_count) { +                ret = dict_set_int32 (op_ctx, "quotad-count", +                                      quotad_count); +                if (ret) { +                        gf_msg (THIS->name, GF_LOG_ERROR, 0, +                                GD_MSG_DICT_SET_FAILED, +                                "Couldn't set quotad-count"); +                        goto out; +                } +        } +        if (snapd_count) { +                ret = dict_set_int32 (op_ctx, "snapd-count", +                                      snapd_count); +                if (ret) { +                        gf_msg (THIS->name, GF_LOG_ERROR, 0, +                                GD_MSG_DICT_SET_FAILED, +                                "Couldn't set snapd-count"); +                        goto out; +                } +        } + +out: +        return ret; +} + +int  glusterd_tier_or_rebalance_rsp (dict_t *op_ctx, glusterd_rebalance_t *index, int32_t i)  {          int                             ret = 0; @@ -11542,6 +11742,7 @@ glusterd_handle_node_rsp (dict_t *req_dict, void *pending_entry,                            char **op_errstr, gd_node_type type)  {          int                     ret = 0; +        int32_t                 cmd = GF_OP_CMD_NONE;          GF_ASSERT (op_errstr); @@ -11552,8 +11753,13 @@ glusterd_handle_node_rsp (dict_t *req_dict, void *pending_entry,                                                           op_errstr, type);                  break;          case GD_OP_STATUS_VOLUME: -                ret = glusterd_status_volume_brick_rsp (rsp_dict, op_ctx, -                                                        op_errstr); +                ret = dict_get_int32 (req_dict, "cmd", &cmd); +                if (!ret && (cmd & GF_CLI_STATUS_CLIENT_LIST)) { +                        ret = glusterd_status_volume_client_list (rsp_dict, +                                        op_ctx, op_errstr); +                } else +                        ret = glusterd_status_volume_brick_rsp (rsp_dict, +                                        op_ctx, op_errstr);                  break;          case GD_OP_TIER_STATUS:          case GD_OP_DETACH_TIER_STATUS:  | 
