From: Martin Schwenke Date: Tue, 19 Feb 2013 03:29:06 +0000 (+1100) Subject: client: New generic node listing function list_of_nodes() X-Git-Tag: ctdb-1.2.39-8~2 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=61ac25e266d101c1ac979a4f3c765d4536cd7ccb;hp=12c9737e00f548599ea88b644b625be72466bb8b;p=ctdb.git client: New generic node listing function list_of_nodes() Signed-off-by: Martin Schwenke Pair-programmed-with: Amitay Isaacs Cherry-pick-from: a73bb56991b8c07ed0e9517ffcf0dc264be30487 --- diff --git a/client/ctdb_client.c b/client/ctdb_client.c index 5e066045..7e2dd4a2 100644 --- a/client/ctdb_client.c +++ b/client/ctdb_client.c @@ -3176,6 +3176,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;inum;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;inum;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, diff --git a/include/ctdb_client.h b/include/ctdb_client.h index 3dc115f0..94987911 100644 --- a/include/ctdb_client.h +++ b/include/ctdb_client.h @@ -486,6 +486,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,