summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-01-29 11:39:06 +1100
committerAndrew Tridgell <tridge@samba.org>2008-01-29 11:39:06 +1100
commit377734662901223c24068635c0e9d94b18f4c919 (patch)
tree16d115633269a59f8073bb016f02265dd3d2cc98
parent6b50533c2221eef3e6fc4acab6e41c2cdc42e93f (diff)
downloadsamba-377734662901223c24068635c0e9d94b18f4c919.tar.gz
partial merge from ronnie
(This used to be ctdb commit fd316deb8a9e0545c8efa1bfc8ad83962b310405)
-rw-r--r--ctdb/Makefile.in6
-rw-r--r--ctdb/config/events.d/41.httpd1
-rw-r--r--ctdb/config/events.d/README11
-rw-r--r--ctdb/tests/ctdb_traverse.c114
-rw-r--r--ctdb/tools/ctdb.c9
5 files changed, 134 insertions, 7 deletions
diff --git a/ctdb/Makefile.in b/ctdb/Makefile.in
index 3bff0d798c7..163a1158882 100644
--- a/ctdb/Makefile.in
+++ b/ctdb/Makefile.in
@@ -54,7 +54,7 @@ CTDB_SERVER_OBJ = server/ctdbd.o server/ctdb_daemon.o server/ctdb_lockwait.o \
server/ctdb_keepalive.o server/ctdb_logging.o server/ctdb_uptime.c \
$(CTDB_CLIENT_OBJ) $(CTDB_TCP_OBJ) @INFINIBAND_WRAPPER_OBJ@
-TEST_BINS=bin/ctdb_bench bin/ctdb_fetch bin/ctdb_store bin/ctdb_randrec bin/ctdb_persistent bin/rb_test \
+TEST_BINS=bin/ctdb_bench bin/ctdb_fetch bin/ctdb_store bin/ctdb_randrec bin/ctdb_persistent bin/ctdb_traverse bin/rb_test \
@INFINIBAND_BINS@
BINS = bin/ctdb @CTDB_SCSI_IO@ bin/ctdb_ipmux bin/smnotify
@@ -127,6 +127,10 @@ bin/ctdb_store: $(CTDB_CLIENT_OBJ) tests/ctdb_store.o
@echo Linking $@
@$(CC) $(CFLAGS) -o $@ tests/ctdb_store.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
+bin/ctdb_traverse: $(CTDB_CLIENT_OBJ) tests/ctdb_traverse.o
+ @echo Linking $@
+ @$(CC) $(CFLAGS) -o $@ tests/ctdb_traverse.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
+
bin/ctdb_randrec: $(CTDB_CLIENT_OBJ) tests/ctdb_randrec.o
@echo Linking $@
@$(CC) $(CFLAGS) -o $@ tests/ctdb_randrec.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
diff --git a/ctdb/config/events.d/41.httpd b/ctdb/config/events.d/41.httpd
index d9e82b06662..fac4bad3ef9 100644
--- a/ctdb/config/events.d/41.httpd
+++ b/ctdb/config/events.d/41.httpd
@@ -3,6 +3,7 @@
. $CTDB_BASE/functions
loadconfig ctdb
+loadconfig http
[ "$CTDB_MANAGES_HTTPD" = "yes" ] || exit 0
diff --git a/ctdb/config/events.d/README b/ctdb/config/events.d/README
index be9dbb23c63..bfa43726cde 100644
--- a/ctdb/config/events.d/README
+++ b/ctdb/config/events.d/README
@@ -72,6 +72,8 @@ takeip
This event takes three additional arguments :
'interface' 'ipaddress' and 'netmask'
+ Before this event there will always be a 'startrecovery' event.
+
This event will always be followed by a 'recovered' event onse
all ipaddresses have been reassigned to new nodes and the ctdb database
has been recovered.
@@ -100,9 +102,14 @@ releaseip
Example: 60.nfs
+startrecovery
+ This event is triggered everytime we start a recovery process
+ or before we start changing ip address allocations.
+
recovered
- This event is triggered everytime a full ctdb recovery has completed
- and all public ip addresses have been reassigned among the nodes.
+ This event is triggered every time we have finished a full recovery
+ and also after we have finished reallocating the public ip addresses
+ across the cluster.
Example: 60.nfs which if the ip address configuration has changed
during the recovery (i.e. if addresses have been taken over or
diff --git a/ctdb/tests/ctdb_traverse.c b/ctdb/tests/ctdb_traverse.c
new file mode 100644
index 00000000000..136dfbc2023
--- /dev/null
+++ b/ctdb/tests/ctdb_traverse.c
@@ -0,0 +1,114 @@
+/*
+ simple tool to traverse a ctdb database over and over and over
+
+ Copyright (C) Andrew Tridgell 2006
+ Ronnie sahlberg 2007
+
+ 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 "includes.h"
+#include "lib/events/events.h"
+#include "system/filesys.h"
+#include "popt.h"
+#include "cmdline.h"
+
+#include <sys/time.h>
+#include <time.h>
+
+static char *dbname = "test.tdb";
+
+static int traverse_callback(struct ctdb_context *ctdb, TDB_DATA key, TDB_DATA data, void *private_data)
+{
+ uint32_t *count = private_data;
+
+ (*count)++;
+ return 0;
+}
+
+static void traverse_loop(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db, struct event_context *ev)
+{
+ uint32_t count;
+
+ printf("traversing database\n");
+ count = 0;
+ ctdb_traverse(ctdb_db, traverse_callback, &count);
+ printf("traversed %d records\n", count);
+}
+
+/*
+ main program
+*/
+int main(int argc, const char *argv[])
+{
+ struct ctdb_context *ctdb;
+ struct ctdb_db_context *ctdb_db;
+
+ struct poptOption popt_options[] = {
+ POPT_AUTOHELP
+ POPT_CTDB_CMDLINE
+ { "database", 0, POPT_ARG_STRING, &dbname, 0, "database to traverse", "name" },
+ POPT_TABLEEND
+ };
+ int opt;
+ const char **extra_argv;
+ int extra_argc = 0;
+ poptContext pc;
+ struct event_context *ev;
+
+ pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
+
+ while ((opt = poptGetNextOpt(pc)) != -1) {
+ switch (opt) {
+ default:
+ fprintf(stderr, "Invalid option %s: %s\n",
+ poptBadOption(pc, 0), poptStrerror(opt));
+ exit(1);
+ }
+ }
+
+ /* talloc_enable_leak_report_full(); */
+
+ /* setup the remaining options for the main program to use */
+ extra_argv = poptGetArgs(pc);
+ if (extra_argv) {
+ extra_argv++;
+ while (extra_argv[extra_argc]) extra_argc++;
+ }
+
+ ev = event_context_init(NULL);
+
+ ctdb = ctdb_cmdline_client(ev);
+
+ /* attach to a specific database */
+ ctdb_db = ctdb_attach(ctdb, dbname, false);
+ if (!ctdb_db) {
+ printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb));
+ exit(1);
+ }
+
+ printf("Waiting for cluster\n");
+ while (1) {
+ uint32_t recmode=1;
+ ctdb_ctrl_getrecmode(ctdb, ctdb, timeval_zero(), CTDB_CURRENT_NODE, &recmode);
+ if (recmode == 0) break;
+ event_loop_once(ev);
+ }
+
+ while (1) {
+ traverse_loop(ctdb, ctdb_db, ev);
+ }
+
+ return 0;
+}
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index b192699c1d7..d56a09f2ae6 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -280,13 +280,14 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
}
if(options.machinereadable){
- printf(":Node:IP:Disonnected:Disabled:Permanently Disabled:\n");
+ printf(":Node:IP:Disconnected:Banned:Disabled:Unhealthy:\n");
for(i=0;i<nodemap->num;i++){
- printf(":%d:%s:%d:%d:%d:\n", nodemap->nodes[i].pnn,
+ printf(":%d:%s:%d:%d:%d:%d:\n", nodemap->nodes[i].pnn,
inet_ntoa(nodemap->nodes[i].sin.sin_addr),
!!(nodemap->nodes[i].flags&NODE_FLAGS_DISCONNECTED),
- !!(nodemap->nodes[i].flags&NODE_FLAGS_UNHEALTHY),
- !!(nodemap->nodes[i].flags&NODE_FLAGS_PERMANENTLY_DISABLED));
+ !!(nodemap->nodes[i].flags&NODE_FLAGS_BANNED),
+ !!(nodemap->nodes[i].flags&NODE_FLAGS_PERMANENTLY_DISABLED),
+ !!(nodemap->nodes[i].flags&NODE_FLAGS_UNHEALTHY));
}
return 0;
}