return ctdb->num_nodes;
}
+/*
+ return the number of connected nodes
+*/
+uint32_t ctdb_get_num_connected_nodes(struct ctdb_context *ctdb)
+{
+ int i;
+ uint32_t count=0;
+ for (i=0;i<ctdb->vnn_map->size;i++) {
+ if (ctdb->nodes[i]->flags & NODE_FLAGS_CONNECTED) {
+ count++;
+ }
+ }
+ return count;
+}
+
/*
called by the transport layer when a packet comes in
return -1;
}
+ if (destnode != CTDB_BROADCAST_VNNMAP && destnode != CTDB_BROADCAST_VNNMAP &&
+ (!ctdb_validate_vnn(ctdb, destnode) ||
+ !(ctdb->nodes[destnode]->flags & NODE_FLAGS_CONNECTED))) {
+ if (!(flags & CTDB_CTRL_FLAG_NOREPLY)) {
+ callback(ctdb, -1, tdb_null, "ctdb_control to disconnected node", private_data);
+ }
+ return 0;
+ }
+
/* the state is made a child of private_data if possible. This means any reply
will be discarded if the private_data goes away */
state = talloc(private_data?private_data:ctdb, struct ctdb_control_state);
return -1;
}
+ /* send a message to all clients telling them that the cluster has been reconfigured */
+ ctdb_send_message(ctdb, CTDB_BROADCAST_ALL, CTDB_SRVID_RECONFIGURE, tdb_null);
DEBUG(0, (__location__ " Recovery complete\n"));
return 0;
uint64_t srvid;
srvid = CTDB_SRVTYPE_RECOVERY;
- srvid <<= 32;
emsg.vnn = vnn;
/* register a message port for recovery elections */
srvid = CTDB_SRVTYPE_RECOVERY;
- srvid <<= 32;
ctdb_set_message_handler(ctdb, srvid, election_handler, NULL);
monitor_cluster(ctdb);
if (key.dsize == 0 && data.dsize == 0) {
state->null_count++;
- if (state->null_count != ctdb_get_num_nodes(ctdb)) {
+ if (state->null_count != ctdb_get_num_connected_nodes(ctdb)) {
return 0;
}
}
a message handler ID meaning "give me all messages"
*/
#define CTDB_SRVID_ALL (~(uint64_t)0)
+
/*
srvid type : RECOVERY
*/
-#define CTDB_SRVTYPE_RECOVERY 0x64766372
+#define CTDB_SRVTYPE_RECOVERY 0xF100000000000000LL
+
+/*
+ a message handler ID meaning that the cluster has been reconfigured
+ */
+#define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL
struct event_context;
int ctdb_start_recoverd(struct ctdb_context *ctdb);
+uint32_t ctdb_get_num_connected_nodes(struct ctdb_context *ctdb);
+
#endif