4 Copyright (C) Amitay Isaacs 2015
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "system/network.h"
22 #include "system/filesys.h"
28 #include "common/logging.h"
30 #include "lib/util/debug.h"
32 #include "protocol/protocol.h"
33 #include "protocol/protocol_api.h"
34 #include "client/client_private.h"
35 #include "client/client.h"
36 #include "client/client_sync.h"
38 int list_of_nodes(struct ctdb_node_map
*nodemap
,
39 uint32_t flags_mask
, uint32_t exclude_pnn
,
40 TALLOC_CTX
*mem_ctx
, uint32_t **pnn_list
)
46 /* Allocate the list of same number of nodes */
47 list
= talloc_array(mem_ctx
, uint32_t, nodemap
->num
);
52 for (i
=0; i
<nodemap
->num
; i
++) {
53 if (nodemap
->node
[i
].flags
& flags_mask
) {
56 if (nodemap
->node
[i
].pnn
== exclude_pnn
) {
59 list
[num_nodes
] = nodemap
->node
[i
].pnn
;
67 int list_of_active_nodes(struct ctdb_node_map
*nodemap
, uint32_t exclude_pnn
,
68 TALLOC_CTX
*mem_ctx
, uint32_t **pnn_list
)
70 return list_of_nodes(nodemap
, NODE_FLAGS_INACTIVE
, exclude_pnn
,
74 int list_of_connected_nodes(struct ctdb_node_map
*nodemap
,
76 TALLOC_CTX
*mem_ctx
, uint32_t **pnn_list
)
78 return list_of_nodes(nodemap
, NODE_FLAGS_DISCONNECTED
, exclude_pnn
,
82 struct ctdb_server_id
ctdb_client_get_server_id(
83 struct ctdb_client_context
*client
,
86 struct ctdb_server_id sid
;
89 sid
.task_id
= task_id
;
90 sid
.vnn
= ctdb_client_pnn(client
);
91 sid
.unique_id
= task_id
;
92 sid
.unique_id
= (sid
.unique_id
<< 32) | sid
.pid
;
97 bool ctdb_server_id_equal(struct ctdb_server_id
*sid1
,
98 struct ctdb_server_id
*sid2
)
100 if (sid1
->pid
!= sid2
->pid
) {
103 if (sid1
->task_id
!= sid2
->task_id
) {
106 if (sid1
->vnn
!= sid2
->vnn
) {
109 if (sid1
->unique_id
!= sid2
->unique_id
) {
116 int ctdb_server_id_exists(TALLOC_CTX
*mem_ctx
, struct tevent_context
*ev
,
117 struct ctdb_client_context
*client
,
118 struct ctdb_server_id
*sid
, bool *exists
)
123 ret
= ctdb_ctrl_process_exists(mem_ctx
, ev
, client
, sid
->vnn
,
124 tevent_timeval_zero(),