[SCM] CTDB repository - branch master updated - ctdb-1.12-154-g15d8ae8

Ronnie Sahlberg sahlberg at samba.org
Mon Jan 2 18:41:19 MST 2012


The branch, master has been updated
       via  15d8ae8b0f80f95d7839528b8ac60aa0e2485c77 (commit)
       via  adcb076612c56f92cfb6f3ba90721981a067a494 (commit)
       via  726b598076132a5a73f9259d6b65ee2a4012099f (commit)
       via  5b11f990404c26c279c9ae389483e560f1c01a81 (commit)
       via  54377ef8b992f92d3a4ece42ee72e37d22cd2de6 (commit)
       via  2c1baf5ddd3c2cdd2a3f98b8e208d3a48530d1d1 (commit)
       via  355685a14be17bf4648788f8a72c54790fe03502 (commit)
       via  fade71539482e8276f57ba3c003fe004d8666ce7 (commit)
       via  920e3a732eb9e09004edde6cfb3c7db8a004016f (commit)
      from  809d1f3b8a9232fce0376cb47e4f633b49237529 (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 15d8ae8b0f80f95d7839528b8ac60aa0e2485c77
Merge: adcb076612c56f92cfb6f3ba90721981a067a494 809d1f3b8a9232fce0376cb47e4f633b49237529
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Jan 3 12:40:15 2012 +1100

    Merge branch 'master' of ssh://git.samba.org/data/git/ctdb

commit adcb076612c56f92cfb6f3ba90721981a067a494
Merge: 00373958a5d5fb8c9b99548d5b9f327e78669162 726b598076132a5a73f9259d6b65ee2a4012099f
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Jan 3 12:31:37 2012 +1100

    Merge remote branch 'martins/nodestatus'

commit 726b598076132a5a73f9259d6b65ee2a4012099f
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Dec 7 18:40:55 2011 +1100

    Tests - make a comment more accurate
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 5b11f990404c26c279c9ae389483e560f1c01a81
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Dec 7 14:04:54 2011 +1100

    Tests - test code for parse_nodestring() function
    
    This function is fairly complex so here is some test code.
    
    This reworks Makefile a bit and also provides test stubs for some
    libctdb functions.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 54377ef8b992f92d3a4ece42ee72e37d22cd2de6
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Dec 7 13:40:24 2011 +1100

    Rename struct traverse_state to allow tools C files to be #included.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 2c1baf5ddd3c2cdd2a3f98b8e208d3a48530d1d1
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Dec 7 13:35:49 2011 +1100

    ctdb tool - remove verify_node() function
    
    parse_nodestring() checks what this used to check.  parse_nodestring()
    already has the nodemap.
    
    It was a 50-50 decision to decide whether to update verify_node() to
    check against a nodemap that is passed in or to delete it.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    Conflicts:
    
    	tools/ctdb.c
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 355685a14be17bf4648788f8a72c54790fe03502
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Dec 6 20:17:02 2011 +1100

    ctdb tool - new command "ctdb nodestatus [nodestring]"
    
    This is very much like "ctdb status" but actually returns the status
    for use in scripts.
    
    This can be used in 2 modes:
    
    * An optional nodestring is passed directly to the command without
      using -n.  In this mode the current node is asked for the status of
      all listed nodes.
    
    * The nodestring is passed via -n.  In this mode the designated nodes
      will be asked for their status.  This is like "ctdb status".
    
    These modes can be mixed.  For example:
    
      ctdb nodestatus 1,2,3 -n 0
    
    asks node 0 for the status of nodes 1, 2 and 3, returning the bitwise
    OR of their statuses.
    
    This version uses the auto_all functionality, so the output isn't
    necessarily pretty.  An improved version that does its own -n
    processing may appear soon.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit fade71539482e8276f57ba3c003fe004d8666ce7
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Dec 6 20:10:34 2011 +1100

    ctdb tool - factor out status printing functions
    
    Create 2 new functions: control_status_1_machine() and
    control_status_1_human() that contain chunks of code from
    control_status().  We're about to find another purpose for these
    functions.
    
    This should be a no-op.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 920e3a732eb9e09004edde6cfb3c7db8a004016f
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Dec 6 19:50:40 2011 +1100

    ctdb tool - generalise nodestring parsing for -n
    
    Centralise -n nodestring parsing and add the ability to pass a
    comma-separated list of node numbers.  Listing a node that is
    disconnected or deleted results in failure, similar to the way passing
    a single node currently works.  All of the auto_all commands inherit
    this functionality.  For now, the non-auto_all commands do not inherit
    this - they need to be individually tweaked.  Therefore, we haven't
    updated the documentation to advertise this feature.
    
    Implemented via a new function parse_nodestring() that parses an
    optional (pass NULL when not available to indicate "current node")
    comma-separated list of node numbers or "all".  parse_nodestring() can
    be told to be non-fatal for disconnected/deleted nodes so it can also
    be used in other contexts (yes, coming soon).  main() is changed to
    call this function.
    
    A new magic PNN value CTDB_MULTICAST is added and along with a
    corresponding option.nodes structure member (a talloc-ed array of
    PNNs).  This is also populated for "all" as well.
    
    control_status() has new function pretty_print_flags() factored out so
    pretty-printed flags can be used in error/debug messages.  New
    function is_partially_online() is also factored out - this simplifies
    some of the logic.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

-----------------------------------------------------------------------

Summary of changes:
 Makefile.in                       |   17 ++-
 include/ctdb_protocol.h           |    2 +
 tests/src/ctdb_parse_nodestring.c |  126 ++++++++++++
 tests/src/ctdb_takeover_tests.c   |    3 +-
 tests/src/ctdb_test.c             |   60 ++++++
 tests/src/libctdb_test.c          |  231 ++++++++++++++++++++++
 tools/ctdb.c                      |  381 ++++++++++++++++++++++++-------------
 tools/ctdb_vacuum.c               |    6 +-
 8 files changed, 680 insertions(+), 146 deletions(-)
 create mode 100644 tests/src/ctdb_parse_nodestring.c
 create mode 100644 tests/src/ctdb_test.c
 create mode 100644 tests/src/libctdb_test.c


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index 3b9648d..2dd2bb7 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -84,6 +84,7 @@ TEST_BINS=tests/bin/ctdb_bench tests/bin/ctdb_fetch tests/bin/ctdb_fetch_one \
 	tests/bin/ctdb_randrec tests/bin/ctdb_persistent \
 	tests/bin/ctdb_traverse tests/bin/rb_test tests/bin/ctdb_transaction \
 	tests/bin/ctdb_takeover_tests tests/bin/ctdb_update_record \
+	tests/bin/ctdb_parse_nodestring \
 	@INFINIBAND_BINS@
 
 BINS = bin/ctdb @CTDB_SCSI_IO@ bin/smnotify bin/ping_pong bin/ltdbtool @CTDB_PMDA@
@@ -234,19 +235,25 @@ tests/bin/ctdb_transaction: $(CTDB_CLIENT_OBJ) tests/src/ctdb_transaction.o
 	@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_transaction.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
 
 CTDB_SERVER_MOST_OBJ = $(CTDB_SERVER_OBJ:server/ctdbd.o=)
-CTDB_TEST_C = $(CTDB_SERVER_MOST_OBJ:.o=.c) tests/src/ctdbd_test.c
+CTDBD_TEST_C = $(CTDB_SERVER_MOST_OBJ:.o=.c) tests/src/ctdbd_test.c
+
+CTDB_TEST_C = $(CTDB_CLIENT_OBJ:.o=.c) tools/ctdb.c tools/ctdb_vacuum.c  tests/src/ctdb_test.c
+
 CTDB_TEST_OBJ =  @TALLOC_OBJ@ @TDB_OBJ@ \
 	@LIBREPLACEOBJ@ $(EXTRA_OBJ) @TEVENT_OBJ@ $(SOCKET_WRAPPER_OBJ)
 
-CTDB_TEST_DEPENDS = $(CTDB_TEST_OBJ) $(CTDB_SERVER_MOST_C) \
-	tests/src/ctdbd_test.c
-
-tests/src/ctdb_takeover_tests.o: tests/src/ctdb_takeover_tests.c $(CTDB_TEST_C)
+tests/src/ctdb_takeover_tests.o: tests/src/ctdb_takeover_tests.c $(CTDBD_TEST_C)
 
 tests/bin/ctdb_takeover_tests: $(CTDB_TEST_OBJ) tests/src/ctdb_takeover_tests.o
 	@echo Linking $@
 	@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_takeover_tests.o $(CTDB_TEST_OBJ) $(LIB_FLAGS)
 
+tests/src/ctdb_parse_nodestring.o: tests/src/ctdb_parse_nodestring.c tests/src/libctdb_test.c $(CTDB_TEST_C)
+
+tests/bin/ctdb_parse_nodestring: $(CTDB_TEST_OBJ) tests/src/ctdb_parse_nodestring.o
+	@echo Linking $@
+	@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_parse_nodestring.o $(CTDB_TEST_OBJ) @POPT_OBJ@ $(LIB_FLAGS)
+
 tests/bin/ibwrapper_test: $(CTDB_CLIENT_OBJ) ib/ibwrapper_test.o
 	@echo Linking $@
 	@$(CC) $(CFLAGS) -o $@ ib/ibwrapper_test.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
diff --git a/include/ctdb_protocol.h b/include/ctdb_protocol.h
index d96f565..70197d9 100644
--- a/include/ctdb_protocol.h
+++ b/include/ctdb_protocol.h
@@ -182,6 +182,8 @@ struct ctdb_call_info {
 #define CTDB_BROADCAST_VNNMAP 0xF0000003
 /* send a broadcast to all connected nodes */
 #define CTDB_BROADCAST_CONNECTED 0xF0000004
+/* send a broadcast to selected connected nodes */
+#define CTDB_MULTICAST 0xF0000005
 
 /* the key used for transaction locking on persistent databases */
 #define CTDB_TRANSACTION_LOCK_KEY "__transaction_lock__"
diff --git a/tests/src/ctdb_parse_nodestring.c b/tests/src/ctdb_parse_nodestring.c
new file mode 100644
index 0000000..e467c36
--- /dev/null
+++ b/tests/src/ctdb_parse_nodestring.c
@@ -0,0 +1,126 @@
+/* 
+   Tests for tools/ctdb.c:parse_nodestring()
+
+   Copyright (C) Martin Schwenke 2011
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "ctdb_test.c"
+#include "libctdb_test.c"
+
+static void test_read_nodemap(void)
+{
+	struct ctdb_connection *ctdb = ctdb_connect("foo", NULL, NULL);
+
+	libctdb_test_read_nodemap(ctdb);
+	libctdb_test_print_nodemap(ctdb);
+
+	ctdb_disconnect(ctdb);
+}
+
+static const char * decode_pnn_mode(uint32_t pnn_mode)
+{
+	int i;
+	static const struct {
+		uint32_t mode;
+		const char *name;
+	} pnn_modes[] = {
+		{ CTDB_CURRENT_NODE,        "CURRENT_NODE" },
+		{ CTDB_BROADCAST_ALL,       "BROADCAST_ALL" },
+		{ CTDB_BROADCAST_VNNMAP,    "BROADCAST_VNNMAP" },
+		{ CTDB_BROADCAST_CONNECTED, "BROADCAST_CONNECTED" },
+		{ CTDB_MULTICAST,           "MULTICAST" },
+	};
+
+	for (i = 0; i < ARRAY_SIZE(pnn_modes); i++) {
+		if (pnn_mode == pnn_modes[i].mode) {
+			return pnn_modes[i].name;
+		}
+	}
+
+	return "PNN";
+}
+
+static void print_nodes(uint32_t *nodes, uint32_t pnn_mode)
+{
+	int i;
+
+	printf("NODES:");
+	for (i = 0; i < talloc_array_length(nodes); i++) {
+		printf(" %lu", (unsigned long) nodes[i]);
+	}
+	printf("\n");
+
+	printf("PNN MODE: %s (%lu)\n",
+	       decode_pnn_mode(pnn_mode), (unsigned long) pnn_mode);
+}
+
+static void test_parse_nodestring(const char *nodestring_s,
+				  const char *dd_ok_s)
+{
+	const char *nodestring;
+	bool dd_ok;
+	struct ctdb_connection *ctdb;
+	uint32_t *nodes;
+	uint32_t pnn_mode;
+
+	nodestring = strcmp("", nodestring_s) == 0 ? NULL : nodestring_s;
+
+	if (strcasecmp(dd_ok_s, "yes") == 0 ||
+	    strcmp(dd_ok_s, "true") == 0) {
+		dd_ok = true;
+	} else {
+		dd_ok = false;
+	}
+
+	ctdb  = ctdb_connect("foo", NULL, NULL);
+	ctdb_connection = ctdb;
+
+	libctdb_test_read_nodemap(ctdb);
+
+	if (parse_nodestring(NULL, nodestring, dd_ok, &nodes, &pnn_mode)) {
+		print_nodes(nodes, pnn_mode);
+	}
+
+	ctdb_disconnect(ctdb);
+}
+
+static void usage(void)
+{
+	fprintf(stderr, "usage: ctdb_parse_nodelist <op>\n");
+	exit(1);
+}
+
+int main(int argc, const char *argv[])
+{
+	LogLevel = DEBUG_DEBUG;
+	if (getenv("CTDB_TEST_LOGLEVEL")) {
+		LogLevel = atoi(getenv("CTDB_TEST_LOGLEVEL"));
+	}
+
+	if (argc < 2) {
+		usage();
+	}
+
+	if (argc == 2 && strcmp(argv[1], "read_nodemap") == 0) {
+		test_read_nodemap();
+	} else if (argc == 4 && strcmp(argv[1], "parse_nodestring") == 0) {
+		test_parse_nodestring(argv[2], argv[3]);
+	} else {
+		usage();
+	}
+
+	return 0;
+}
diff --git a/tests/src/ctdb_takeover_tests.c b/tests/src/ctdb_takeover_tests.c
index 19cb5a6..96cb9e5 100644
--- a/tests/src/ctdb_takeover_tests.c
+++ b/tests/src/ctdb_takeover_tests.c
@@ -97,8 +97,7 @@ void ctdb_test_read_ctdb_public_ip_list(void)
 	talloc_free(tmp_ctx);
 }
 
-/* Format of each line is "IP pnn" - the separator has to be at least
- * 1 space (not a tab or whatever - a space!).
+/* Format of each line is "IP CURRENT_PNN ALLOWED_PNN,...".
  */
 static bool
 read_ctdb_public_ip_info(TALLOC_CTX *ctx,
diff --git a/tests/src/ctdb_test.c b/tests/src/ctdb_test.c
new file mode 100644
index 0000000..533f3f4
--- /dev/null
+++ b/tests/src/ctdb_test.c
@@ -0,0 +1,60 @@
+/*
+   ctdb test include file
+
+   Copyright (C) Martin Schwenke  2011
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _CTDBD_TEST_C
+#define _CTDBD_TEST_C
+
+#define main(argc, argv) main_foobar(argc, argv)
+#define usage usage_foobar
+#include "tools/ctdb.c"
+#undef main
+#undef usage
+
+#undef TIMELIMIT
+#include "tools/ctdb_vacuum.c"
+
+/* UTIL_OBJ */
+#include "lib/util/idtree.c"
+#include "lib/util/db_wrap.c"
+#include "lib/util/strlist.c"
+#include "lib/util/util.c"
+#include "lib/util/util_time.c"
+#include "lib/util/util_file.c"
+#include "lib/util/fault.c"
+#include "lib/util/substitute.c"
+#include "lib/util/signal.c"
+
+/* CTDB_COMMON_OBJ */
+#include "common/ctdb_io.c"
+#include "common/ctdb_util.c"
+#include "common/ctdb_ltdb.c"
+#include "common/ctdb_message.c"
+#include "common/cmdline.c"
+#include "lib/util/debug.c"
+#include "common/rb_tree.c"
+#ifdef _LINUX_ERRNO_H
+#include "common/system_linux.c"
+#endif
+#include "common/system_common.c"
+#include "common/ctdb_logging.c"
+
+/* CTDB_CLIENT_OBJ */
+#include "client/ctdb_client.c"
+
+#endif /* _CTDBD_TEST_C */
diff --git a/tests/src/libctdb_test.c b/tests/src/libctdb_test.c
new file mode 100644
index 0000000..9e9c31e
--- /dev/null
+++ b/tests/src/libctdb_test.c
@@ -0,0 +1,231 @@
+/*
+   Test stubs and support functions for some libctdb functions
+
+   Copyright (C) Martin Schwenke  2011
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <syslog.h>
+#include "ctdb.h"
+
+/* Can't use the real definition, since including libctdb_private.h
+ * causes macro conflicts */
+struct ctdb_connection {
+	struct ctdb_node_map *nodemap;
+	uint32_t current_node;
+	uint32_t recmaster;
+	struct ctdb_ifaces_list *ifaces;
+};
+
+
+/* Read a nodemap from stdin.  Each line looks like:
+ *  <PNN> <FLAGS> [RECMASTER] [CURRENT]
+ * EOF or a blank line terminates input.
+ */
+void libctdb_test_read_nodemap(struct ctdb_connection *ctdb)
+{
+	char line[1024];
+
+	ctdb->nodemap = (struct ctdb_node_map *) malloc(sizeof(uint32_t));
+	if (ctdb->nodemap == NULL) {
+		DEBUG(DEBUG_ERR, ("OOM allocating nodemap\n"));
+		exit (1);
+	}
+	ctdb->nodemap->num = 0;
+
+	while ((fgets(line, sizeof(line), stdin) != NULL) &&
+	       (line[0] != '\n')) {
+		uint32_t pnn, flags;
+		char *tok, *t;
+
+		/* Get rid of pesky newline */
+		if ((t = strchr(line, '\n')) != NULL) {
+			*t = '\0';
+		}
+
+		/* Get PNN */
+		tok = strtok(line, " \t");
+		if (tok == NULL) {
+			DEBUG(DEBUG_ERR, (__location__ " WARNING, bad line ignoed :%s\n", line));
+			continue;
+		}
+		pnn = (uint32_t)strtoul(tok, NULL, 0);
+
+		/* Get flags */
+		tok = strtok(NULL, " \t");
+		if (tok == NULL) {
+			DEBUG(DEBUG_ERR, (__location__ " WARNING, bad line ignored :%s\n", line));
+			continue;
+		}
+		flags = (uint32_t)strtoul(tok, NULL, 0);
+
+		tok = strtok(NULL, " \t");
+		while (tok != NULL) {
+			if (strcmp(tok, "CURRENT") == 0) {
+				ctdb->current_node = pnn;
+			} else if (strcmp(tok, "RECMASTER") == 0) {
+				ctdb->recmaster = pnn;
+			}
+			tok = strtok(NULL, " \t");
+		}
+
+		ctdb->nodemap = (struct ctdb_node_map *) realloc(ctdb->nodemap, sizeof(uint32_t) + (ctdb->nodemap->num + 1) * sizeof(struct ctdb_node_and_flags));
+		if (ctdb->nodemap == NULL) {
+			DEBUG(DEBUG_ERR, ("OOM allocating nodemap\n"));
+			exit (1);
+		}
+
+		ctdb->nodemap->nodes[ctdb->nodemap->num].pnn = pnn;
+		ctdb->nodemap->nodes[ctdb->nodemap->num].flags = flags;
+		ctdb->nodemap->num++;
+	}
+}
+
+void libctdb_test_print_nodemap(struct ctdb_connection *ctdb)
+{
+	int i;
+
+	for (i = 0; i < ctdb->nodemap->num; i++) {
+		printf("%ld\t0x%lx%s%s\n",
+		       (unsigned long) ctdb->nodemap->nodes[i].pnn,
+		       (unsigned long) ctdb->nodemap->nodes[i].flags,
+		       ctdb->nodemap->nodes[i].pnn == ctdb->current_node ? "\tCURRENT" : "",
+		       ctdb->nodemap->nodes[i].pnn == ctdb->recmaster ? "\tRECMASTER" : "");
+	}
+}
+
+/* Stubs... */
+
+bool ctdb_getnodemap(struct ctdb_connection *ctdb,
+		     uint32_t destnode, struct ctdb_node_map **nodemap)
+{
+	*nodemap = ctdb->nodemap;
+	return true;
+}
+
+void ctdb_free_nodemap(struct ctdb_node_map *nodemap)
+{
+	return;
+}
+
+bool ctdb_getifaces(struct ctdb_connection *ctdb,
+		    uint32_t destnode, struct ctdb_ifaces_list **ifaces)
+{
+	*ifaces = ctdb->ifaces;
+	return false; /* Not implemented */
+}
+
+void ctdb_free_ifaces(struct ctdb_ifaces_list *ifaces)
+{
+	return;
+}
+
+bool ctdb_getpnn(struct ctdb_connection *ctdb,
+		 uint32_t destnode,
+		 uint32_t *pnn)
+{
+	if (destnode == CTDB_CURRENT_NODE) {
+		*pnn = ctdb->current_node;
+	} else {
+		*pnn = destnode;
+	}
+	return true;
+}
+
+bool ctdb_getrecmode(struct ctdb_connection *ctdb,
+		     uint32_t destnode,
+		     uint32_t *recmode)
+{
+	*recmode = 0;
+	return true;
+}
+
+bool ctdb_getrecmaster(struct ctdb_connection *ctdb,
+		       uint32_t destnode,
+		       uint32_t *recmaster)
+{
+	*recmaster = ctdb->recmaster;
+	return true;
+}
+
+bool
+ctdb_getdbseqnum(struct ctdb_connection *ctdb,
+		 uint32_t destnode,
+		 uint32_t dbid,
+		 uint64_t *seqnum)
+{
+	*seqnum = 0;
+	return false; /* Not implemented */
+}
+
+bool
+ctdb_check_message_handlers(struct ctdb_connection *ctdb,
+			   uint32_t destnode,
+			   uint32_t num,
+			   uint64_t *mhs,
+			   uint8_t *result)
+{
+	*result = 0;
+	return false; /* Not implemented */
+}
+
+/* Not a stub, a copy */
+void ctdb_log_file(FILE *outf, int priority, const char *format, va_list ap)
+{
+	fprintf(outf, "%s:",
+		priority == LOG_EMERG ? "EMERG" :
+		priority == LOG_ALERT ? "ALERT" :
+		priority == LOG_CRIT ? "CRIT" :
+		priority == LOG_ERR ? "ERR" :
+		priority == LOG_WARNING ? "WARNING" :
+		priority == LOG_NOTICE ? "NOTICE" :
+		priority == LOG_INFO ? "INFO" :
+		priority == LOG_DEBUG ? "DEBUG" :
+		"Unknown Error Level");
+
+	vfprintf(outf, format, ap);
+	if (priority == LOG_ERR) {
+		fprintf(outf, " (%s)", strerror(errno));
+	}
+	fprintf(outf, "\n");
+}
+
+/* Remove type-safety macro. */
+#undef ctdb_connect
+struct ctdb_connection *ctdb_connect(const char *addr,
+				     ctdb_log_fn_t log_func, void *log_priv)
+{
+	struct ctdb_connection *ctdb;
+
+	ctdb = malloc(sizeof(struct ctdb_connection));
+	if (ctdb == NULL) {
+		DEBUG(DEBUG_ERR, ("OOM allocating ctdb_connection\n"));
+		exit (1);
+	}
+
+	ctdb->nodemap = NULL;
+	ctdb->current_node = 0;
+	ctdb->recmaster = 0;
+
+	return ctdb;
+}
+
+void ctdb_disconnect(struct ctdb_connection *ctdb)
+{


-- 
CTDB repository


More information about the samba-cvs mailing list