[SCM] CTDB repository - branch master updated - ctdb-1.0.113-68-g8c89aac
Ronnie Sahlberg
sahlberg at samba.org
Wed Feb 3 15:46:36 MST 2010
The branch, master has been updated
via 8c89aac20260dc7f3746e29fe99f17422a77cb88 (commit)
from eae1d4f9e52e73b4d8769868fffdafa590d03784 (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 8c89aac20260dc7f3746e29fe99f17422a77cb88
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Thu Feb 4 09:45:32 2010 +1100
add two new debug controls to send and receive messages
ctdb msglisten and msgsend
-----------------------------------------------------------------------
Summary of changes:
tools/ctdb.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 65 insertions(+), 0 deletions(-)
Changeset truncated at 500 lines:
diff --git a/tools/ctdb.c b/tools/ctdb.c
index 00bef82..9d6547c 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -4119,6 +4119,69 @@ static int control_rddumpmemory(struct ctdb_context *ctdb, int argc, const char
}
/*
+ send a message to a srvid
+ */
+static int control_msgsend(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+ unsigned long srvid;
+ int ret;
+ TDB_DATA data;
+
+ if (argc < 2) {
+ usage();
+ }
+
+ srvid = strtoul(argv[0], NULL, 0);
+
+ data.dptr = (uint8_t *)discard_const(argv[1]);
+ data.dsize= strlen(argv[1]);
+
+ ret = ctdb_send_message(ctdb, CTDB_BROADCAST_CONNECTED, srvid, data);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,("Failed to send memdump request message to %u\n", options.pnn));
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ handler for msglisten
+*/
+static void msglisten_handler(struct ctdb_context *ctdb, uint64_t srvid,
+ TDB_DATA data, void *private_data)
+{
+ int i;
+
+ printf("Message received: ");
+ for (i=0;i<data.dsize;i++) {
+ printf("%c", data.dptr[i]);
+ }
+ printf("\n");
+}
+
+/*
+ listen for messages on a messageport
+ */
+static int control_msglisten(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+ uint64_t srvid;
+
+ srvid = getpid();
+
+ /* register a message port and listen for messages
+ */
+ ctdb_set_message_handler(ctdb, srvid, msglisten_handler, NULL);
+ printf("Listening for messages on srvid:%d\n", (int)srvid);
+
+ while (1) {
+ event_loop_once(ctdb->ev);
+ }
+
+ return 0;
+}
+
+/*
list all nodes in the cluster
if the daemon is running, we read the data from the daemon.
if the daemon is not running we parse the nodes file directly
@@ -4316,6 +4379,8 @@ static const struct {
{ "setrecmasterrole", control_setrecmasterrole, false, false, "Set RECMASTER role to on/off", "{on|off}"},
{ "setdbprio", control_setdbprio, false, false, "Set DB priority", "<dbid> <prio:1-3>"},
{ "getdbprio", control_getdbprio, false, false, "Get DB priority", "<dbid>"},
+ { "msglisten", control_msglisten, false, false, "Listen on a srvid port for messages", "<msg srvid>"},
+ { "msgsend", control_msgsend, false, false, "Send a message to srvid", "<srvid> <message>"},
};
/*
--
CTDB repository
More information about the samba-cvs
mailing list