diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-sm.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-sm.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c index fd56e5abf..3aaf359ac 100644 --- a/xlators/mgmt/glusterd/src/glusterd-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-sm.c @@ -34,6 +34,7 @@ #include "glusterd-op-sm.h" #include "glusterd-utils.h" #include "glusterd-store.h" +#include "glusterd-etcd.h" static struct list_head gd_friend_sm_queue; @@ -605,6 +606,9 @@ glusterd_ac_handle_friend_remove_req (glusterd_friend_sm_event_t *event, "Peer detach cleanup was not successful"); ret = 0; } + gf_log (THIS->name, GF_LOG_INFO, "detached, stopping etcd"); + stop_etcd(priv->etcd_pid); + nuke_etcd_dir(); out: gf_log (THIS->name, GF_LOG_DEBUG, "Returning with %d", ret); @@ -651,6 +655,11 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx) int status = 0; int32_t op_ret = -1; int32_t op_errno = 0; + xlator_t *this = NULL; + glusterd_conf_t *priv = NULL; + + this = THIS; + priv = this->private; GF_ASSERT (ctx); ev_ctx = ctx; @@ -701,6 +710,13 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx) peerinfo->hostname, ev_ctx->port, op_ret, op_errno); + // apply a deterministic function to decide via whom we should join the cluster + if (strcmp(peerinfo->hostname, ev_ctx->hostname) > 0) { + stop_etcd(priv->etcd_pid); + nuke_etcd_dir(); + priv->etcd_pid = start_etcd (uuid_utoa(MY_UUID), peerinfo->hostname); + } + out: gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); |