From 7c23a94516c5dd21536c259f323a3cc113fdfa0d Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Tue, 6 Nov 2012 12:18:24 +0530 Subject: mgmt/glusterd: Implementation of server-side quorum Feature-page: http://www.gluster.org/community/documentation/index.php/Features/Server-quorum Change-Id: I747b222519e71022462343d2c1bcd3626e1f9c86 BUG: 839595 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/3811 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- cli/src/cli-rpc-ops.c | 84 ++++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 41 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 442020371..10ff6e7a9 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -83,6 +83,42 @@ rpc_clnt_prog_t cli_pmap_prog = { .progver = GLUSTER_PMAP_VERSION, }; +void +gf_cli_probe_strerror (gf1_cli_probe_rsp *rsp, char *msg, size_t len) +{ + switch (rsp->op_errno) { + case GF_PROBE_ANOTHER_CLUSTER: + snprintf (msg, len, "%s is already part of another cluster", + rsp->hostname); + break; + case GF_PROBE_VOLUME_CONFLICT: + snprintf (msg, len, "Atleast one volume on %s conflicts with " + "existing volumes in the cluster", rsp->hostname); + break; + case GF_PROBE_UNKNOWN_PEER: + snprintf (msg, len, "%s responded with 'unknown peer' error, " + "this could happen if %s doesn't have localhost in " + "its peer database", rsp->hostname, rsp->hostname); + break; + case GF_PROBE_ADD_FAILED: + snprintf (msg, len, "Failed to add peer information on %s" , + rsp->hostname); + break; + case GF_PROBE_SAME_UUID: + snprintf (msg, len, "Peer uuid (host %s) is same as local uuid", + rsp->hostname); + break; + case GF_PROBE_QUORUM_NOT_MET: + snprintf (msg, len, "Cluster quorum is not met. Changing " + "peers is not allowed in this state"); + break; + default: + snprintf (msg, len, "Probe returned with unknown " + "errno %d", rsp->op_errno); + break; + } +} + int gf_cli_probe_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) @@ -133,47 +169,7 @@ gf_cli_probe_cbk (struct rpc_req *req, struct iovec *iov, if (rsp.op_errstr && (strlen (rsp.op_errstr) > 0)) { snprintf (msg, sizeof (msg), "%s", rsp.op_errstr); } else { - switch (rsp.op_errno) { - case GF_PROBE_ANOTHER_CLUSTER: - snprintf (msg, sizeof (msg), - "%s is already part of " - "another cluster", - rsp.hostname); - break; - case GF_PROBE_VOLUME_CONFLICT: - snprintf (msg, sizeof (msg), - "Atleast one volume on %s " - "conflicts with existing " - "volumes in the cluster", - rsp.hostname); - break; - case GF_PROBE_UNKNOWN_PEER: - snprintf (msg, sizeof (msg), - "%s responded with 'unknown " - "peer' error, this could " - "happen if %s doesn't have " - "localhost in its peer " - "database", rsp.hostname, - rsp.hostname); - break; - case GF_PROBE_ADD_FAILED: - snprintf (msg, sizeof (msg), - "Failed to add peer " - "information on %s" , - rsp.hostname); - break; - case GF_PROBE_SAME_UUID: - snprintf (msg, sizeof (msg), - "Peer uuid (host %s) is" - "same as local uuid", - rsp.hostname); - break; - default: - snprintf (msg, sizeof (msg), - "Probe returned with unknown " - "errno %d", rsp.op_errno); - break; - } + gf_cli_probe_strerror (&rsp, msg, sizeof (msg)); } gf_log ("cli", GF_LOG_ERROR, "%s", msg); } @@ -248,6 +244,12 @@ gf_cli_deprobe_cbk (struct rpc_req *req, struct iovec *iov, " down. Check with 'peer " "status'."); break; + case GF_DEPROBE_QUORUM_NOT_MET: + snprintf (msg, sizeof (msg), "Cluster " + "quorum is not met. Changing " + "peers is not allowed in this" + " state"); + break; default: snprintf (msg, sizeof (msg), "Detach returned with unknown" -- cgit