1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

client: New generic node listing function list_of_nodes()

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

(This used to be ctdb commit a73bb56991b8c07ed0e9517ffcf0dc264be30487)
This commit is contained in:
Martin Schwenke 2013-02-19 14:29:06 +11:00 committed by Amitay Isaacs
parent a2abdc1353
commit dab2f6817d
2 changed files with 43 additions and 0 deletions

View File

@ -3451,6 +3451,44 @@ uint32_t *list_of_vnnmap_nodes(struct ctdb_context *ctdb,
return nodes;
}
/* Get list of nodes not including those with flags specified by mask.
* If exclude_pnn is not -1 then exclude that pnn from the list.
*/
uint32_t *list_of_nodes(struct ctdb_context *ctdb,
struct ctdb_node_map *node_map,
TALLOC_CTX *mem_ctx,
uint32_t mask,
int exclude_pnn)
{
int i, j, num_nodes;
uint32_t *nodes;
for (i=num_nodes=0;i<node_map->num;i++) {
if (node_map->nodes[i].flags & mask) {
continue;
}
if (node_map->nodes[i].pnn == exclude_pnn) {
continue;
}
num_nodes++;
}
nodes = talloc_array(mem_ctx, uint32_t, num_nodes);
CTDB_NO_MEMORY_FATAL(ctdb, nodes);
for (i=j=0;i<node_map->num;i++) {
if (node_map->nodes[i].flags & mask) {
continue;
}
if (node_map->nodes[i].pnn == exclude_pnn) {
continue;
}
nodes[j++] = node_map->nodes[i].pnn;
}
return nodes;
}
uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
struct ctdb_node_map *node_map,
TALLOC_CTX *mem_ctx,

View File

@ -507,6 +507,11 @@ int ctdb_ctrl_setreclock(struct ctdb_context *ctdb,
const char *reclock);
uint32_t *list_of_nodes(struct ctdb_context *ctdb,
struct ctdb_node_map *node_map,
TALLOC_CTX *mem_ctx,
uint32_t mask,
int exclude_pnn);
uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
struct ctdb_node_map *node_map,
TALLOC_CTX *mem_ctx,