2 Unix SMB/CIFS implementation.
6 Copyright (C) Andrew Tridgell 2006
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "cluster/cluster.h"
24 #include "cluster/cluster_private.h"
26 static struct cluster_ops *ops;
28 /* set cluster operations */
29 void cluster_set_ops(struct cluster_ops *new_ops)
35 an ugly way of getting at the backend handle (eg. ctdb context) via the cluster API
37 void *cluster_backend_handle(void)
39 return ops->backend_handle(ops);
42 /* by default use the local ops */
43 static void cluster_init(void)
45 if (ops == NULL) cluster_local_init();
49 server a server_id for the local node
51 struct server_id cluster_id(uint32_t id)
54 return ops->cluster_id(ops, id);
59 return a server_id as a string
61 const char *cluster_id_string(TALLOC_CTX *mem_ctx, struct server_id id)
64 return ops->cluster_id_string(ops, mem_ctx, id);
69 open a temporary tdb in a cluster friendly manner
71 struct tdb_wrap *cluster_tdb_tmp_open(TALLOC_CTX *mem_ctx, const char *dbname, int flags)
74 return ops->cluster_tdb_tmp_open(ops, mem_ctx, dbname, flags);
79 register a callback function for a messaging endpoint
81 NTSTATUS cluster_message_init(struct messaging_context *msg, struct server_id server,
82 cluster_message_fn_t handler)
85 return ops->message_init(ops, msg, server, handler);
89 send a message to another node in the cluster
91 NTSTATUS cluster_message_send(struct server_id server, DATA_BLOB *data)
94 return ops->message_send(ops, server, data);