move the definition of server/message id port values to the public ctdb.h header
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 18 May 2010 02:46:00 +0000 (12:46 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 18 May 2010 02:46:00 +0000 (12:46 +1000)
change tst.c example to use message id ports from the range reserved for test purposes

include/ctdb.h
include/ctdb_protocol.h
libctdb/tst.c

index 6e07a105129a76c44ba2917188c158eee456c438..c9ca36ac1a1066ebbc66966319f8fb32dd91f7eb 100644 (file)
@@ -144,6 +144,99 @@ int ctdb_writerecord(ctdb_handle *handle,
 
 
 
+/*
+   Messaging serverid ports
+*/
+/* 
+   a message handler ID meaning "give me all messages"
+ */
+#define CTDB_SRVID_ALL (~(uint64_t)0)
+
+/*
+   The top 32 bits of the server id represents the owner of
+   this part of the srvid space
+*/
+#define CTDB_SRVID_MASK        0xFFFFFFFF00000000LL
+
+
+/*
+   Samba owns all message handler IDs where the top 32 bits are all zero
+*/
+#define CTDB_SRVID_SAMBA       0x0000000000000000
+#define CTDB_IS_SAMBA_SRVID    ((srvid & CTDB_SRVID_MASK) == CTDB_SRVID_SAMBA)
+
+/*
+   Server ids reserved for testing 
+*/
+#define CTDB_SRVID_TEST                0x0000000100000000
+#define CTDB_IS_TEST_SRVID     ((srvid & CTDB_SRVID_MASK) == CTDB_SRVID_TEST)
+
+/*
+  srvid type : RECOVERY
+*/
+#define CTDB_SRVID_RECOVERY    0xF100000000000000LL
+
+/* 
+   a message handler ID meaning that the cluster has been reconfigured
+ */
+#define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
+
+/* 
+   a message handler ID meaning that an IP address has been released
+ */
+#define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
+
+/* 
+   a message ID to set the node flags in the recovery daemon
+ */
+#define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
+
+/* 
+   a message ID to ask the recovery daemon to update the expected node
+   assignment for a public ip
+ */
+#define CTDB_SRVID_RECD_UPDATE_IP 0xF500000000000000LL
+
+/*
+  a message to tell the recovery daemon to fetch a set of records
+ */
+#define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
+
+/*
+  a message to tell the recovery daemon to write a talloc memdump
+  to the log
+ */
+#define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
+
+/* 
+   a message ID to get the recovery daemon to push the node flags out
+ */
+#define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
+
+/* 
+   a message ID to get the recovery daemon to reload the nodes file
+ */
+#define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
+
+/* 
+   a message ID to get the recovery daemon to perform a takeover run
+ */
+#define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
+
+/* A message id to ask the recovery daemon to temporarily disable the
+   public ip checks
+*/
+#define CTDB_SRVID_DISABLE_IP_CHECK  0xFC00000000000000LL
+
+/* A dummy port used for sending back ipreallocate resposnes to the main
+   daemon
+*/
+#define CTDB_SRVID_TAKEOVER_RUN_RESPONSE  0xFD00000000000000LL
+
+/* A port reserved for samba (top 32 bits)
+ */
+#define CTDB_SRVID_SAMBA_NOTIFY  0xFE00000000000000LL
+
 /*
  * messaging functions
  * these functions provide a messaging layer for applications to communicate
index 58be9e78cebdb8aeddfdd3d76f7395c10e75b1de..bb725773f01d78a61abbac5c193644313470a326 100644 (file)
@@ -50,95 +50,6 @@ struct ctdb_call_info {
 */
 #define CTDB_FLAG_TORTURE      (1<<1)
 
-/*
-   The top 32 bits of the server id represents the owner of
-   this part of the srvid space
-*/
-#define CTDB_SRVID_MASK        0xFFFFFFFF00000000LL
-
-
-/*
-   Samba owns all message handler IDs where the top 32 bits are all zero
-*/
-#define CTDB_SRVID_SAMBA       0x0000000000000000
-#define CTDB_IS_SAMBA_SRVID    ((srvid & CTDB_SRVID_MASK) == CTDB_SRVID_SAMBA)
-
-/*
-   Server ids reserved for testing 
-*/
-#define CTDB_SRVID_TEST                0x0000000100000000
-#define CTDB_IS_TEST_SRVID     ((srvid & CTDB_SRVID_MASK) == CTDB_SRVID_TEST)
-
-/* 
-   a message handler ID meaning "give me all messages"
- */
-#define CTDB_SRVID_ALL (~(uint64_t)0)
-
-/*
-  srvid type : RECOVERY
-*/
-#define CTDB_SRVID_RECOVERY    0xF100000000000000LL
-
-/* 
-   a message handler ID meaning that the cluster has been reconfigured
- */
-#define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
-
-/* 
-   a message handler ID meaning that an IP address has been released
- */
-#define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
-
-/* 
-   a message ID to set the node flags in the recovery daemon
- */
-#define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
-
-/* 
-   a message ID to ask the recovery daemon to update the expected node
-   assignment for a public ip
- */
-#define CTDB_SRVID_RECD_UPDATE_IP 0xF500000000000000LL
-
-/*
-  a message to tell the recovery daemon to fetch a set of records
- */
-#define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
-
-/*
-  a message to tell the recovery daemon to write a talloc memdump
-  to the log
- */
-#define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
-
-/* 
-   a message ID to get the recovery daemon to push the node flags out
- */
-#define CTDB_SRVID_PUSH_NODE_FLAGS 0xF900000000000000LL
-
-/* 
-   a message ID to get the recovery daemon to reload the nodes file
- */
-#define CTDB_SRVID_RELOAD_NODES 0xFA00000000000000LL
-
-/* 
-   a message ID to get the recovery daemon to perform a takeover run
- */
-#define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
-
-/* A message id to ask the recovery daemon to temporarily disable the
-   public ip checks
-*/
-#define CTDB_SRVID_DISABLE_IP_CHECK  0xFC00000000000000LL
-
-/* A dummy port used for sending back ipreallocate resposnes to the main
-   daemon
-*/
-#define CTDB_SRVID_TAKEOVER_RUN_RESPONSE  0xFD00000000000000LL
-
-/* A port reserved for samba (top 32 bits)
- */
-#define CTDB_SRVID_SAMBA_NOTIFY  0xFE00000000000000LL
 
 
 /* the key used for transaction locking on persistent databases */
index ca968a4f1bec73780e61bd0957e0cce50f902e0d..abedd20470d5810057f0c9294296f33ee525fbd9 100644 (file)
@@ -11,7 +11,7 @@ TDB_DATA key;
 
 void msg_h(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA data, void *private_data)
 {
-       printf("Message received on port %d : %s\n", (int)srvid, data.dptr);
+       printf("Message received on port 0x%016llx : %s\n", srvid, data.dptr);
 }
 
 
@@ -109,7 +109,7 @@ int main(int argc, char *argv[])
 
        ctdb = ctdb_connect("/tmp/ctdb.socket");
 
-       handle = ctdb_set_message_handler_send(ctdb, 55, NULL, msg_h, NULL);
+       handle = ctdb_set_message_handler_send(ctdb, CTDB_SRVID_TEST|55, NULL, msg_h, NULL);
        if (handle == NULL) {
                printf("Failed to register message port\n");
                exit(10);
@@ -123,7 +123,7 @@ int main(int argc, char *argv[])
        msg.dptr="HelloWorld";
        msg.dsize = strlen(msg.dptr);
 
-       ret = ctdb_send_message(ctdb, 0, 55, msg);
+       ret = ctdb_send_message(ctdb, 0, CTDB_SRVID_TEST|55, msg);
        if (ret != 0) {
                printf("Failed to send message. Aborting\n");
                exit(10);