From f6274959ba381b6b5d025cb0cee78665107a72a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 10 Jan 2007 11:16:11 +0000 Subject: r20647: add cluster code (This used to be commit 5870830b99a8d76bda1ff5af3fcf8dda9aba50ec) --- source4/cluster/cluster.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 source4/cluster/cluster.c (limited to 'source4/cluster/cluster.c') diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c new file mode 100644 index 0000000000..fef5bce0d1 --- /dev/null +++ b/source4/cluster/cluster.c @@ -0,0 +1,45 @@ +/* + Unix SMB/CIFS implementation. + + core clustering code + + Copyright (C) Andrew Tridgell 2006 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "cluster/cluster.h" + +/* + server a server_id for the local node +*/ +struct server_id cluster_id(uint32_t id) +{ + struct server_id server_id; + ZERO_STRUCT(server_id); + server_id.id = id; + return server_id; +} + + +/* + return a server_id as a string +*/ +const char *cluster_id_string(TALLOC_CTX *mem_ctx, struct server_id id) +{ + return talloc_asprintf(mem_ctx, "%u.%u", id.node, id.id); +} + -- cgit From 9d8c44af173c5266ea6c5eaf7772a21f8d3fb523 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 19 Jan 2007 03:53:37 +0000 Subject: r20887: allow the registration of multiple cluster backends this is in preparation for ctdb (This used to be commit 489f022175a1022bcca8053116362825daae5e40) --- source4/cluster/cluster.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'source4/cluster/cluster.c') diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c index fef5bce0d1..0bd4649376 100644 --- a/source4/cluster/cluster.c +++ b/source4/cluster/cluster.c @@ -22,16 +22,39 @@ #include "includes.h" #include "cluster/cluster.h" +#include "cluster/cluster_private.h" + +static struct cluster_ops *ops; + +/* set cluster operations */ +void cluster_set_ops(struct cluster_ops *new_ops) +{ + ops = new_ops; +} + +/* + not a nice abstraction :( +*/ +void *cluster_private(void) +{ + return ops->private; +} + +/* by default use the local ops */ +static void cluster_init(void) +{ + if (ops == NULL) cluster_local_init(); +} + + /* server a server_id for the local node */ struct server_id cluster_id(uint32_t id) { - struct server_id server_id; - ZERO_STRUCT(server_id); - server_id.id = id; - return server_id; + cluster_init(); + return ops->cluster_id(ops, id); } @@ -40,6 +63,6 @@ struct server_id cluster_id(uint32_t id) */ const char *cluster_id_string(TALLOC_CTX *mem_ctx, struct server_id id) { - return talloc_asprintf(mem_ctx, "%u.%u", id.node, id.id); + cluster_init(); + return ops->cluster_id_string(ops, mem_ctx, id); } - -- cgit From efc68d8bf6d5acc009285e8f34b30a3a5b252884 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 20 Jan 2007 00:48:31 +0000 Subject: r20919: add a function cluster_tdb_tmp_open() which can be used in a cluster environment for subsystems that have not yet been converted to use ctdb to get a shared temporary tdb (This used to be commit 0ed91384497aed6817b2220c31344bfcd45fd033) --- source4/cluster/cluster.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/cluster/cluster.c') diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c index 0bd4649376..16de01de07 100644 --- a/source4/cluster/cluster.c +++ b/source4/cluster/cluster.c @@ -66,3 +66,13 @@ const char *cluster_id_string(TALLOC_CTX *mem_ctx, struct server_id id) cluster_init(); return ops->cluster_id_string(ops, mem_ctx, id); } + + +/* + open a temporary tdb in a cluster friendly manner +*/ +struct tdb_wrap *cluster_tdb_tmp_open(TALLOC_CTX *mem_ctx, const char *dbname, int flags) +{ + cluster_init(); + return ops->cluster_tdb_tmp_open(ops, mem_ctx, dbname, flags); +} -- cgit From 07478016d7354274cd53ff2b4ec1dda3f0f439d1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 8 Feb 2007 00:58:17 +0000 Subject: r21230: added the hooks needed in the cluster layer and the messaging code for handling messages to remote nodes. Implemented dummy functions in the 'local' cluster backend for the messaging hooks, and modified the messaging layer to check if the destination is remote and redirect messages via the cluster layer (This used to be commit 4474552e8fb73efebef32ad8480d7fe9a1e379ef) --- source4/cluster/cluster.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'source4/cluster/cluster.c') diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c index 16de01de07..ea800d2f62 100644 --- a/source4/cluster/cluster.c +++ b/source4/cluster/cluster.c @@ -33,11 +33,11 @@ void cluster_set_ops(struct cluster_ops *new_ops) } /* - not a nice abstraction :( + an ugly way of getting at the backend handle (eg. ctdb context) via the cluster API */ -void *cluster_private(void) +void *cluster_backend_handle(void) { - return ops->private; + return ops->backend_handle(ops); } /* by default use the local ops */ @@ -46,8 +46,6 @@ static void cluster_init(void) if (ops == NULL) cluster_local_init(); } - - /* server a server_id for the local node */ @@ -76,3 +74,24 @@ struct tdb_wrap *cluster_tdb_tmp_open(TALLOC_CTX *mem_ctx, const char *dbname, i cluster_init(); return ops->cluster_tdb_tmp_open(ops, mem_ctx, dbname, flags); } + + +/* + register a callback function for a messaging endpoint +*/ +NTSTATUS cluster_message_init(struct messaging_context *msg, struct server_id server, + void (*handler)(struct messaging_context *, + struct server_id, uint32_t, DATA_BLOB)) +{ + cluster_init(); + return ops->message_init(ops, msg, server, handler); +} + +/* + send a message to another node in the cluster +*/ +NTSTATUS cluster_message_send(struct server_id server, uint32_t msg_type, DATA_BLOB *data) +{ + cluster_init(); + return ops->message_send(ops, server, msg_type, data); +} -- cgit From a2eff69b4b26ba6b3227b4bbe4557bc9b618d400 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 8 Feb 2007 02:59:58 +0000 Subject: r21233: first version of samba4 messaging using ctdb is working. This means we should now work on a real cluster, and not just a localhost simulator (This used to be commit f05072ad74fb08fd906bc500c5e89930bcc3387f) --- source4/cluster/cluster.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/cluster/cluster.c') diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c index ea800d2f62..4be52b8233 100644 --- a/source4/cluster/cluster.c +++ b/source4/cluster/cluster.c @@ -80,8 +80,7 @@ struct tdb_wrap *cluster_tdb_tmp_open(TALLOC_CTX *mem_ctx, const char *dbname, i register a callback function for a messaging endpoint */ NTSTATUS cluster_message_init(struct messaging_context *msg, struct server_id server, - void (*handler)(struct messaging_context *, - struct server_id, uint32_t, DATA_BLOB)) + cluster_message_fn_t handler) { cluster_init(); return ops->message_init(ops, msg, server, handler); -- cgit From 8de4c33d8f089f2f47817278f8781f194da898d0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 9 Feb 2007 01:52:13 +0000 Subject: r21256: - msg_type is not needed in the cluster messaging API - merge ctdb_get_num_nodes() from bzr tree (This used to be commit 3df7527aedeba7ce2f4a6ca2d3b7167f58c6b68a) --- source4/cluster/cluster.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/cluster/cluster.c') diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c index 4be52b8233..dab39c1fea 100644 --- a/source4/cluster/cluster.c +++ b/source4/cluster/cluster.c @@ -89,8 +89,8 @@ NTSTATUS cluster_message_init(struct messaging_context *msg, struct server_id se /* send a message to another node in the cluster */ -NTSTATUS cluster_message_send(struct server_id server, uint32_t msg_type, DATA_BLOB *data) +NTSTATUS cluster_message_send(struct server_id server, DATA_BLOB *data) { cluster_init(); - return ops->message_send(ops, server, msg_type, data); + return ops->message_send(ops, server, data); } -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/cluster/cluster.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/cluster/cluster.c') diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c index dab39c1fea..606ca9b8b1 100644 --- a/source4/cluster/cluster.c +++ b/source4/cluster/cluster.c @@ -7,7 +7,7 @@ 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 2 of the License, or + 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, @@ -16,8 +16,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 9b009c900987517359485799be8be4167494b376 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Sep 2007 21:35:03 +0000 Subject: r25301: Merge my includes.h cleanups. (This used to be commit 37425495f392a2d0122a93aa2c42758eab7dab5a) --- source4/cluster/cluster.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/cluster/cluster.c') diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c index 606ca9b8b1..673ce2be4e 100644 --- a/source4/cluster/cluster.c +++ b/source4/cluster/cluster.c @@ -22,6 +22,7 @@ #include "includes.h" #include "cluster/cluster.h" #include "cluster/cluster_private.h" +#include "librpc/gen_ndr/misc.h" static struct cluster_ops *ops; -- cgit From 61873ce94c172c801a4831de5550a8e0fe54c5f5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 13 Dec 2007 22:46:23 +0100 Subject: r26431: Require ndr_push creators to specify a iconv_convenience context. (This used to be commit 7352206f4450fdf881b95bda064cedd9d2477e4c) --- source4/cluster/cluster.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/cluster/cluster.c') diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c index 673ce2be4e..6bac1dcbe5 100644 --- a/source4/cluster/cluster.c +++ b/source4/cluster/cluster.c @@ -69,10 +69,10 @@ const char *cluster_id_string(TALLOC_CTX *mem_ctx, struct server_id id) /* open a temporary tdb in a cluster friendly manner */ -struct tdb_wrap *cluster_tdb_tmp_open(TALLOC_CTX *mem_ctx, const char *dbname, int flags) +struct tdb_wrap *cluster_tdb_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *dbname, int flags) { cluster_init(); - return ops->cluster_tdb_tmp_open(ops, mem_ctx, dbname, flags); + return ops->cluster_tdb_tmp_open(ops, mem_ctx, lp_ctx, dbname, flags); } -- cgit From 77f71c1b65358723771354fd9ff1dc418b227ccc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 4 Feb 2008 17:51:38 +1100 Subject: Rework cluster_id() to take an additional argument, as we need .. to be unique in a prefork process environment. Andrew Bartlett and David Disseldorp (This used to be commit 931994a7f185bbc98924823e9e8cef1011dd0957) --- source4/cluster/cluster.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/cluster/cluster.c') diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c index 6bac1dcbe5..cc61974cbd 100644 --- a/source4/cluster/cluster.c +++ b/source4/cluster/cluster.c @@ -47,12 +47,12 @@ static void cluster_init(void) } /* - server a server_id for the local node + create a server_id for the local node */ -struct server_id cluster_id(uint32_t id) +struct server_id cluster_id(uint64_t id, uint32_t id2) { cluster_init(); - return ops->cluster_id(ops, id); + return ops->cluster_id(ops, id, id2); } -- cgit