mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
ctdb-daemon: New control CTDB_CONTROL_GET_NODES_FILE
This is like CTDB_CONTROL_GET_NODEMAP but it loads from the nodes file instead of the daemon. Also new client function ctdb_ctrl_getnodesfile() Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
8e12e112f8
commit
81e526965c
@ -1540,6 +1540,31 @@ int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
load nodes file on a remote node and return as a node map
|
||||
*/
|
||||
int ctdb_ctrl_getnodesfile(struct ctdb_context *ctdb,
|
||||
struct timeval timeout, uint32_t destnode,
|
||||
TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap)
|
||||
{
|
||||
int ret;
|
||||
TDB_DATA outdata;
|
||||
int32_t res;
|
||||
|
||||
ret = ctdb_control(ctdb, destnode, 0,
|
||||
CTDB_CONTROL_GET_NODES_FILE, 0, tdb_null,
|
||||
mem_ctx, &outdata, &res, &timeout, NULL);
|
||||
if (ret != 0 || res != 0 || outdata.dsize == 0) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getnodes failed ret:%d res:%d\n", ret, res));
|
||||
return -1;
|
||||
}
|
||||
|
||||
*nodemap = (struct ctdb_node_map *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
|
||||
talloc_free(outdata.dptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
old style ipv4-only get a list of nodes (vnn and flags ) from a remote node
|
||||
*/
|
||||
|
@ -225,6 +225,10 @@ int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb,
|
||||
struct timeval timeout, uint32_t destnode,
|
||||
TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
|
||||
|
||||
int ctdb_ctrl_getnodesfile(struct ctdb_context *ctdb,
|
||||
struct timeval timeout, uint32_t destnode,
|
||||
TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
|
||||
|
||||
int ctdb_ctrl_getnodemapv4(struct ctdb_context *ctdb,
|
||||
struct timeval timeout, uint32_t destnode,
|
||||
TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap);
|
||||
|
@ -936,6 +936,7 @@ int ctdb_control_setvnnmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA
|
||||
int ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
|
||||
int ctdb_control_getnodemapv4(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
|
||||
int ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
|
||||
int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
|
||||
int ctdb_control_writerecord(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
|
||||
|
||||
|
||||
|
@ -411,6 +411,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
|
||||
CTDB_CONTROL_IPREALLOCATED = 137,
|
||||
CTDB_CONTROL_GET_RUNSTATE = 138,
|
||||
CTDB_CONTROL_DB_DETACH = 139,
|
||||
CTDB_CONTROL_GET_NODES_FILE = 140,
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -169,6 +169,9 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
case CTDB_CONTROL_GET_NODEMAP:
|
||||
return ctdb_control_getnodemap(ctdb, opcode, indata, outdata);
|
||||
|
||||
case CTDB_CONTROL_GET_NODES_FILE:
|
||||
return ctdb_control_getnodesfile(ctdb, opcode, indata, outdata);
|
||||
|
||||
case CTDB_CONTROL_RELOAD_NODES_FILE:
|
||||
CHECK_CONTROL_DATA_SIZE(0);
|
||||
return ctdb_control_reload_nodes_file(ctdb, opcode);
|
||||
|
@ -1782,6 +1782,24 @@ int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid)
|
||||
return kill(pid, 0);
|
||||
}
|
||||
|
||||
int ctdb_control_getnodesfile(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata)
|
||||
{
|
||||
struct ctdb_node_map *node_map = NULL;
|
||||
|
||||
CHECK_CONTROL_DATA_SIZE(0);
|
||||
|
||||
node_map = ctdb_read_nodes_file(ctdb, ctdb->nodes_file);
|
||||
if (node_map == NULL) {
|
||||
DEBUG(DEBUG_ERR, ("Failed to read nodes file\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
outdata->dptr = (unsigned char *)node_map;
|
||||
outdata->dsize = talloc_get_size(outdata->dptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ctdb_shutdown_sequence(struct ctdb_context *ctdb, int exit_code)
|
||||
{
|
||||
if (ctdb->runstate == CTDB_RUNSTATE_SHUTDOWN) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user