summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-sm.c
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2013-12-11 16:26:25 -0500
committerJeff Darcy <jdarcy@redhat.com>2013-12-11 16:26:25 -0500
commitef171ff2bfd114e46442441fbdeb692a416cc951 (patch)
tree27ac663045954c8efb145fbbae3df87d7bbfe5b3 /xlators/mgmt/glusterd/src/glusterd-sm.c
parent4bbbda2017be3cfae57c122d70d11c9470364f63 (diff)
Roll-up patch for NSR so far.
Previous history: https://forge.gluster.org/~jdarcy/glusterfs-core/glusterfs-nsr Change-Id: I2b56328788753c6a74d9589815f2dd705ac9ce6a Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-sm.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.c16
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 c671edf68..2490ba665 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;
@@ -596,6 +597,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);
@@ -642,6 +646,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;
@@ -692,6 +701,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);