From 3d3767a259b29674882c102fe629cff1eb1a702c Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 16 Mar 2020 16:05:29 +1100 Subject: ctdb-protocol: Add CTDB_SRVID_LEADER CTDB_SRVID_LEADER will be regularly broadcast to all connected nodes by the leader. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/protocol/protocol.h | 5 ++++- ctdb/protocol/protocol_message.c | 12 ++++++++++++ ctdb/tests/UNIT/cunit/protocol_test_101.sh | 1 + ctdb/tests/src/protocol_common_ctdb.c | 2 ++ ctdb/tests/src/protocol_ctdb_compat_test.c | 1 + ctdb/tests/src/protocol_ctdb_test.c | 1 + 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h index 5f788f6f2a8..98d17fa2963 100644 --- a/ctdb/protocol/protocol.h +++ b/ctdb/protocol/protocol.h @@ -128,6 +128,9 @@ struct ctdb_call { /* SRVID to inform of election data */ #define CTDB_SRVID_ELECTION 0xF100000000000000LL +/* SRVID for broadcasting leader */ +#define CTDB_SRVID_LEADER 0xF101000000000000LL + /* SRVID to inform clients that the cluster has been reconfigured */ #define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL @@ -998,7 +1001,7 @@ union ctdb_message_data { uint32_t db_id; /* SRVID_MEM_DUMP, SRVID_TAKEOVER_RUN */ struct ctdb_srvid_message *msg; - /* SRVID_BANNING, SRVID_REBALANCE_NODE */ + /* SRVID_BANNING, SRVID_REBALANCE_NODE, SRVID_LEADER */ uint32_t pnn; /* SRVID_DISABLE_TAKEOVER_RUNS, SRVID_DISABLE_RECOVERIES */ struct ctdb_disable_message *disable; diff --git a/ctdb/protocol/protocol_message.c b/ctdb/protocol/protocol_message.c index 19c1f162d0c..e2202bb78d5 100644 --- a/ctdb/protocol/protocol_message.c +++ b/ctdb/protocol/protocol_message.c @@ -42,6 +42,10 @@ static size_t ctdb_message_data_len(union ctdb_message_data *mdata, len = ctdb_election_message_len(mdata->election); break; + case CTDB_SRVID_LEADER: + len = ctdb_uint32_len(&mdata->pnn); + break; + case CTDB_SRVID_RECONFIGURE: break; @@ -129,6 +133,10 @@ static void ctdb_message_data_push(union ctdb_message_data *mdata, ctdb_election_message_push(mdata->election, buf, &np); break; + case CTDB_SRVID_LEADER: + ctdb_uint32_push(&mdata->pnn, buf, &np); + break; + case CTDB_SRVID_RECONFIGURE: break; @@ -219,6 +227,10 @@ static int ctdb_message_data_pull(uint8_t *buf, size_t buflen, &mdata->election, &np); break; + case CTDB_SRVID_LEADER: + ret = ctdb_uint32_pull(buf, buflen, &mdata->pnn, &np); + break; + case CTDB_SRVID_RECONFIGURE: break; diff --git a/ctdb/tests/UNIT/cunit/protocol_test_101.sh b/ctdb/tests/UNIT/cunit/protocol_test_101.sh index b84f208b109..e62cd071487 100755 --- a/ctdb/tests/UNIT/cunit/protocol_test_101.sh +++ b/ctdb/tests/UNIT/cunit/protocol_test_101.sh @@ -14,6 +14,7 @@ generate_control_output () srvid_list="\ f002000000000000 \ f100000000000000 \ + f101000000000000 \ f200000000000000 \ f300000000000000 \ f301000000000000 \ diff --git a/ctdb/tests/src/protocol_common_ctdb.c b/ctdb/tests/src/protocol_common_ctdb.c index 6bbddbddc1e..61c5c514f9a 100644 --- a/ctdb/tests/src/protocol_common_ctdb.c +++ b/ctdb/tests/src/protocol_common_ctdb.c @@ -1818,6 +1818,7 @@ void fill_ctdb_message_data(TALLOC_CTX *mem_ctx, union ctdb_message_data *md, fill_ctdb_srvid_message(md->msg, md->msg); break; + case CTDB_SRVID_LEADER: case CTDB_SRVID_BANNING: case CTDB_SRVID_REBALANCE_NODE: md->pnn = rand32(); @@ -1881,6 +1882,7 @@ void verify_ctdb_message_data(union ctdb_message_data *md, verify_ctdb_srvid_message(md->msg, md2->msg); break; + case CTDB_SRVID_LEADER: case CTDB_SRVID_BANNING: case CTDB_SRVID_REBALANCE_NODE: assert(md->pnn == md2->pnn); diff --git a/ctdb/tests/src/protocol_ctdb_compat_test.c b/ctdb/tests/src/protocol_ctdb_compat_test.c index 77e10ef6d8f..1c236361128 100644 --- a/ctdb/tests/src/protocol_ctdb_compat_test.c +++ b/ctdb/tests/src/protocol_ctdb_compat_test.c @@ -1218,6 +1218,7 @@ int main(int argc, char *argv[]) uint64_t test_srvid[] = { CTDB_SRVID_BANNING, CTDB_SRVID_ELECTION, + CTDB_SRVID_LEADER, CTDB_SRVID_RECONFIGURE, CTDB_SRVID_RELEASE_IP, CTDB_SRVID_TAKE_IP, diff --git a/ctdb/tests/src/protocol_ctdb_test.c b/ctdb/tests/src/protocol_ctdb_test.c index b359e7a1280..1650c633800 100644 --- a/ctdb/tests/src/protocol_ctdb_test.c +++ b/ctdb/tests/src/protocol_ctdb_test.c @@ -310,6 +310,7 @@ int main(int argc, char *argv[]) uint64_t test_srvid[] = { CTDB_SRVID_BANNING, CTDB_SRVID_ELECTION, + CTDB_SRVID_LEADER, CTDB_SRVID_RECONFIGURE, CTDB_SRVID_RELEASE_IP, CTDB_SRVID_TAKE_IP, -- cgit v1.2.1