[sheepdog] [PATCH] sheep: exchange name of sd_{join, accept}_handler

Liu Yuan namei.unix at gmail.com
Sun Jul 14 11:54:01 CEST 2013


- update some comments too

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/cluster.h                        |   20 ++++++++++----------
 sheep/cluster/corosync.c               |   10 +++++-----
 sheep/cluster/local.c                  |    4 ++--
 sheep/cluster/shepherd.c               |    8 ++++----
 sheep/cluster/zookeeper.c              |    4 ++--
 sheep/group.c                          |   12 ++++++------
 tests/unit/sheep/mock_group.c          |    2 +-
 tests/unit/sheep/test_cluster_driver.c |    4 ++--
 8 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/sheep/cluster.h b/sheep/cluster.h
index dedab1a..2ec0a14 100644
--- a/sheep/cluster.h
+++ b/sheep/cluster.h
@@ -51,12 +51,12 @@ struct cluster_driver {
 	 *
 	 * This function is used to join the cluster, and notifies a join
 	 * event to all the nodes.  The copy of 'opaque' is passed to
-	 * sd_accept_handler() and sd_join_handler().
+	 * sd_join_handler() and sd_accept_handler().
 	 *
-	 * sd_check_join_cb() is called on one of the nodes which already
+	 * sd_join_handler() is called on all of the nodes which already
 	 * paticipate in the cluster.  If the content of 'opaque' is
-	 * changed in sd_check_join_cb(), the updated 'opaque' must be
-	 * passed to sd_join_handler().
+	 * changed in sd_join_handler(), the updated 'opaque' must be
+	 * passed to sd_accept_handler().
 	 *
 	 * Returns zero on success, -1 on error
 	 */
@@ -162,18 +162,18 @@ static inline const char *get_cdrv_option(const struct cluster_driver *cdrv,
 }
 
 /* callbacks back into sheepdog from the cluster drivers */
-void sd_join_handler(const struct sd_node *joined,
-		     const struct sd_node *members, size_t nr_members,
-		     const void *opaque);
+void sd_accept_handler(const struct sd_node *joined,
+		       const struct sd_node *members, size_t nr_members,
+		       const void *opaque);
 void sd_leave_handler(const struct sd_node *left, const struct sd_node *members,
 		      size_t nr_members);
 void sd_notify_handler(const struct sd_node *sender, void *msg, size_t msg_len);
 bool sd_block_handler(const struct sd_node *sender);
 int sd_reconnect_handler(void);
 void sd_update_node_handler(struct sd_node *);
-void sd_accept_handler(const struct sd_node *joining,
-		       const struct sd_node *nodes, size_t nr_nodes,
-		       void *opaque);
+void sd_join_handler(const struct sd_node *joining,
+		     const struct sd_node *nodes, size_t nr_nodes,
+		     void *opaque);
 void recalculate_vnodes(struct sd_node *nodes, int nr_nodes);
 
 #endif
diff --git a/sheep/cluster/corosync.c b/sheep/cluster/corosync.c
index 7d308f7..577d0cb 100644
--- a/sheep/cluster/corosync.c
+++ b/sheep/cluster/corosync.c
@@ -290,12 +290,12 @@ static bool __corosync_dispatch_one(struct corosync_event *cevent)
 			return false;
 
 		if (cevent->callbacked)
-			/* sd_accept_handler() must be called only once */
+			/* sd_join_handler() must be called only once */
 			return false;
 
 		build_node_list(cpg_nodes, nr_cpg_nodes, entries);
-		sd_accept_handler(&cevent->sender.node, entries, nr_cpg_nodes,
-				  cevent->msg);
+		sd_join_handler(&cevent->sender.node, entries, nr_cpg_nodes,
+				cevent->msg);
 		send_message(COROSYNC_MSG_TYPE_ACCEPT, &cevent->sender,
 			     cpg_nodes, nr_cpg_nodes, cevent->msg,
 			     cevent->msg_len);
@@ -307,8 +307,8 @@ static bool __corosync_dispatch_one(struct corosync_event *cevent)
 		nr_cpg_nodes++;
 
 		build_node_list(cpg_nodes, nr_cpg_nodes, entries);
-		sd_join_handler(&cevent->sender.node, entries, nr_cpg_nodes,
-				cevent->msg);
+		sd_accept_handler(&cevent->sender.node, entries, nr_cpg_nodes,
+				  cevent->msg);
 		break;
 	case COROSYNC_EVENT_TYPE_LEAVE:
 		n = xlfind(&cevent->sender, cpg_nodes, nr_cpg_nodes,
diff --git a/sheep/cluster/local.c b/sheep/cluster/local.c
index 8757996..9d109ca 100644
--- a/sheep/cluster/local.c
+++ b/sheep/cluster/local.c
@@ -433,7 +433,7 @@ static bool local_process_event(void)
 	case EVENT_JOIN:
 		/* nodes[nr_nodes - 1] is a sender, so don't include it */
 		assert(node_eq(&ev->sender.node, &nodes[nr_nodes - 1]));
-		sd_accept_handler(&ev->sender.node, nodes, nr_nodes - 1,
+		sd_join_handler(&ev->sender.node, nodes, nr_nodes - 1,
 				  ev->buf);
 		ev->type = EVENT_ACCEPT;
 		msync(ev, sizeof(*ev), MS_SYNC);
@@ -442,7 +442,7 @@ static bool local_process_event(void)
 
 		return false;
 	case EVENT_ACCEPT:
-		sd_join_handler(&ev->sender.node, nodes, nr_nodes, ev->buf);
+		sd_accept_handler(&ev->sender.node, nodes, nr_nodes, ev->buf);
 		break;
 	case EVENT_LEAVE:
 		if (ev->sender.gateway) {
diff --git a/sheep/cluster/shepherd.c b/sheep/cluster/shepherd.c
index ed79452..49fcf8d 100644
--- a/sheep/cluster/shepherd.c
+++ b/sheep/cluster/shepherd.c
@@ -114,7 +114,7 @@ retry:
 		 * FIXME: member change events must be ordered with nonblocked
 		 *        events
 		 */
-		sd_accept_handler(&join->new_node, NULL, 0, join->opaque);
+		sd_join_handler(&join->new_node, NULL, 0, join->opaque);
 
 		/* FIXME: join->master_elected is needed? */
 		assert(join->master_elected);
@@ -160,7 +160,7 @@ retry:
 	nr_nodes = join_reply->nr_nodes;
 
 	/* FIXME: member change events must be ordered with nonblocked events */
-	sd_join_handler(&this_node, nodes, nr_nodes, join_reply->opaque);
+	sd_accept_handler(&this_node, nodes, nr_nodes, join_reply->opaque);
 
 	free(join_reply);
 
@@ -325,7 +325,7 @@ static void msg_new_node(struct sph_msg *rcv)
 	}
 
 	/* FIXME: member change events must be ordered with nonblocked events */
-	sd_accept_handler(&join->new_node, nodes, nr_nodes, join->opaque);
+	sd_join_handler(&join->new_node, nodes, nr_nodes, join->opaque);
 
 	memset(&snd, 0, sizeof(snd));
 	snd.type = SPH_CLI_MSG_ACCEPT;
@@ -361,7 +361,7 @@ static void msg_new_node_finish(struct sph_msg *rcv)
 		   node_to_str(&join_node_finish->new_node));
 
 	/* FIXME: member change events must be ordered with nonblocked events */
-	sd_join_handler(&join_node_finish->new_node, nodes, nr_nodes, jm);
+	sd_accept_handler(&join_node_finish->new_node, nodes, nr_nodes, jm);
 
 	free(join_node_finish);
 }
diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index f450790..99cb261 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -845,7 +845,7 @@ static void zk_handle_join(struct zk_event *ev)
 		return;
 	}
 
-	sd_accept_handler(&ev->sender.node, sd_nodes, nr_sd_nodes, ev->buf);
+	sd_join_handler(&ev->sender.node, sd_nodes, nr_sd_nodes, ev->buf);
 	push_join_response(ev);
 
 	sd_dprintf("I'm the master now");
@@ -909,7 +909,7 @@ static void zk_handle_accept(struct zk_event *ev)
 	zk_tree_add(&ev->sender);
 
 	build_node_list();
-	sd_join_handler(&ev->sender.node, sd_nodes, nr_sd_nodes, ev->buf);
+	sd_accept_handler(&ev->sender.node, sd_nodes, nr_sd_nodes, ev->buf);
 }
 
 static void kick_block_event(void)
diff --git a/sheep/group.c b/sheep/group.c
index 8b52198..4a2a83b 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -780,9 +780,9 @@ void sd_notify_handler(const struct sd_node *sender, void *data,
  *
  * Note that 'nodes' doesn't contain 'joining'.
  */
-void sd_accept_handler(const struct sd_node *joining,
-		       const struct sd_node *nodes, size_t nr_nodes,
-		       void *opaque)
+void sd_join_handler(const struct sd_node *joining,
+		     const struct sd_node *nodes, size_t nr_nodes,
+		     void *opaque)
 {
 	struct join_message *jm = opaque;
 	char str[MAX_NODE_STR_LEN];
@@ -918,9 +918,9 @@ static bool cluster_join_check(const struct join_message *jm)
 	return true;
 }
 
-void sd_join_handler(const struct sd_node *joined,
-		     const struct sd_node *members, size_t nr_members,
-		     const void *opaque)
+void sd_accept_handler(const struct sd_node *joined,
+		       const struct sd_node *members, size_t nr_members,
+		       const void *opaque)
 {
 	int i;
 	const struct join_message *jm = opaque;
diff --git a/tests/unit/sheep/mock_group.c b/tests/unit/sheep/mock_group.c
index b2556a1..7df96fd 100644
--- a/tests/unit/sheep/mock_group.c
+++ b/tests/unit/sheep/mock_group.c
@@ -15,7 +15,7 @@
 
 #include "cluster.h"
 
-MOCK_VOID_METHOD(sd_join_handler, const struct sd_node *joined,
+MOCK_VOID_METHOD(sd_accept_handler, const struct sd_node *joined,
 		 const struct sd_node *members, size_t nr_members,
 		 const void *opaque)
 MOCK_VOID_METHOD(sd_leave_handler, const struct sd_node *left,
diff --git a/tests/unit/sheep/test_cluster_driver.c b/tests/unit/sheep/test_cluster_driver.c
index 3ea6538..02b6224 100644
--- a/tests/unit/sheep/test_cluster_driver.c
+++ b/tests/unit/sheep/test_cluster_driver.c
@@ -55,8 +55,8 @@ static void do_test(const char *arg)
 	assert_ret(driver->join(&node, msg, len), 0);
 
 	LOOP_WHEN(method_nr_call(sd_check_join_cb) == 0);
-	LOOP_WHEN(method_nr_call(sd_join_handler) == 0);
-	ck_assert_int_eq(method_nr_call(sd_join_handler), 1);
+	LOOP_WHEN(method_nr_call(sd_accept_handler) == 0);
+	ck_assert_int_eq(method_nr_call(sd_accept_handler), 1);
 
 	assert_ret(driver->block(), 0);
 	assert_ret(driver->block(), 0);
-- 
1.7.9.5




More information about the sheepdog mailing list