mirror of
https://github.com/samba-team/samba.git
synced 2025-01-24 02:04:21 +03:00
- renamed ctdb_control utility to ctdb
- use -n to specify node number in ctdb utility - change 'ctdb status' to 'ctdb statistics' - added 'ctdb status' which shows status - added netmask to public IPs, so you don't try a takeover on a foreign network - cleaned up tools/ctdb_control.c a lot - generate usage message at runtime (This used to be ctdb commit 28de71c03ace7d32a9fd9882fabbd5d668b97656)
This commit is contained in:
parent
9838027ff8
commit
ccf4d78e04
@ -41,7 +41,7 @@ CTDB_OBJ = $(CTDB_COMMON_OBJ) $(CTDB_TAKEOVER_OBJ) $(CTDB_TCP_OBJ) $(POPT_OBJ)
|
||||
|
||||
OBJS = @TDB_OBJ@ @TALLOC_OBJ@ @LIBREPLACEOBJ@ @INFINIBAND_WRAPPER_OBJ@ $(EXTRA_OBJ) @EVENTS_OBJ@ $(CTDB_OBJ) $(UTIL_OBJ)
|
||||
|
||||
BINS = bin/ctdbd bin/ctdbd_test bin/ctdb_test bin/ctdb_bench bin/ctdb_messaging bin/ctdb_fetch bin/ctdb_fetch1 bin/lockwait bin/ctdb_control @INFINIBAND_BINS@
|
||||
BINS = bin/ctdbd bin/ctdbd_test bin/ctdb_test bin/ctdb_bench bin/ctdb_messaging bin/ctdb_fetch bin/ctdb_fetch1 bin/lockwait bin/ctdb @INFINIBAND_BINS@
|
||||
|
||||
DIRS = lib bin
|
||||
|
||||
|
@ -279,52 +279,52 @@ void ctdb_input_pkt(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
|
||||
|
||||
switch (hdr->operation) {
|
||||
case CTDB_REQ_CALL:
|
||||
ctdb->status.node.req_call++;
|
||||
ctdb->statistics.node.req_call++;
|
||||
ctdb_request_call(ctdb, hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REPLY_CALL:
|
||||
ctdb->status.node.reply_call++;
|
||||
ctdb->statistics.node.reply_call++;
|
||||
ctdb_reply_call(ctdb, hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REPLY_ERROR:
|
||||
ctdb->status.node.reply_error++;
|
||||
ctdb->statistics.node.reply_error++;
|
||||
ctdb_reply_error(ctdb, hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REQ_DMASTER:
|
||||
ctdb->status.node.req_dmaster++;
|
||||
ctdb->statistics.node.req_dmaster++;
|
||||
ctdb_request_dmaster(ctdb, hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REPLY_DMASTER:
|
||||
ctdb->status.node.reply_dmaster++;
|
||||
ctdb->statistics.node.reply_dmaster++;
|
||||
ctdb_reply_dmaster(ctdb, hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REQ_MESSAGE:
|
||||
ctdb->status.node.req_message++;
|
||||
ctdb->statistics.node.req_message++;
|
||||
ctdb_request_message(ctdb, hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REQ_FINISHED:
|
||||
ctdb->status.node.req_finished++;
|
||||
ctdb->statistics.node.req_finished++;
|
||||
ctdb_request_finished(ctdb, hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REQ_CONTROL:
|
||||
ctdb->status.node.req_control++;
|
||||
ctdb->statistics.node.req_control++;
|
||||
ctdb_request_control(ctdb, hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REPLY_CONTROL:
|
||||
ctdb->status.node.reply_control++;
|
||||
ctdb->statistics.node.reply_control++;
|
||||
ctdb_reply_control(ctdb, hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REQ_KEEPALIVE:
|
||||
ctdb->status.keepalive_packets_recv++;
|
||||
ctdb->statistics.keepalive_packets_recv++;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -345,7 +345,7 @@ static void ctdb_recv_pkt(struct ctdb_context *ctdb, uint8_t *data, uint32_t len
|
||||
{
|
||||
struct ctdb_req_header *hdr = (struct ctdb_req_header *)data;
|
||||
|
||||
ctdb->status.node_packets_recv++;
|
||||
ctdb->statistics.node_packets_recv++;
|
||||
|
||||
/* up the counter for this source node, so we know its alive */
|
||||
if (ctdb_validate_vnn(ctdb, hdr->srcnode)) {
|
||||
@ -487,7 +487,7 @@ void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
|
||||
return;
|
||||
}
|
||||
|
||||
ctdb->status.node_packets_sent++;
|
||||
ctdb->statistics.node_packets_sent++;
|
||||
|
||||
if (!ctdb_validate_vnn(ctdb, hdr->destnode)) {
|
||||
DEBUG(0,(__location__ " cant send to node %u that does not exist\n",
|
||||
|
@ -465,8 +465,8 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->hopcount > ctdb->status.max_hop_count) {
|
||||
ctdb->status.max_hop_count = c->hopcount;
|
||||
if (c->hopcount > ctdb->statistics.max_hop_count) {
|
||||
ctdb->statistics.max_hop_count = c->hopcount;
|
||||
}
|
||||
|
||||
/* if this nodes has done enough consecutive calls on the same record
|
||||
@ -801,7 +801,7 @@ void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode)
|
||||
r->hdr.destnode = destnode;
|
||||
r->hdr.reqid = 0;
|
||||
|
||||
ctdb->status.keepalive_packets_sent++;
|
||||
ctdb->statistics.keepalive_packets_sent++;
|
||||
|
||||
ctdb_queue_packet(ctdb, &r->hdr);
|
||||
|
||||
|
@ -805,29 +805,29 @@ int ctdb_ctrl_process_exists(struct ctdb_context *ctdb, uint32_t destnode, pid_t
|
||||
}
|
||||
|
||||
/*
|
||||
get remote status
|
||||
get remote statistics
|
||||
*/
|
||||
int ctdb_ctrl_status(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_status *status)
|
||||
int ctdb_ctrl_statistics(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_statistics *status)
|
||||
{
|
||||
int ret;
|
||||
TDB_DATA data;
|
||||
int32_t res;
|
||||
|
||||
ret = ctdb_control(ctdb, destnode, 0,
|
||||
CTDB_CONTROL_STATUS, 0, tdb_null,
|
||||
CTDB_CONTROL_STATISTICS, 0, tdb_null,
|
||||
ctdb, &data, &res, NULL, NULL);
|
||||
if (ret != 0 || res != 0) {
|
||||
DEBUG(0,(__location__ " ctdb_control for status failed\n"));
|
||||
DEBUG(0,(__location__ " ctdb_control for statistics failed\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (data.dsize != sizeof(struct ctdb_status)) {
|
||||
DEBUG(0,(__location__ " Wrong status size %u - expected %u\n",
|
||||
data.dsize, sizeof(struct ctdb_status)));
|
||||
if (data.dsize != sizeof(struct ctdb_statistics)) {
|
||||
DEBUG(0,(__location__ " Wrong statistics size %u - expected %u\n",
|
||||
data.dsize, sizeof(struct ctdb_statistics)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
*status = *(struct ctdb_status *)data.dptr;
|
||||
*status = *(struct ctdb_statistics *)data.dptr;
|
||||
talloc_free(data.dptr);
|
||||
|
||||
return 0;
|
||||
@ -1397,16 +1397,16 @@ uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb,
|
||||
/*
|
||||
reset remote status
|
||||
*/
|
||||
int ctdb_status_reset(struct ctdb_context *ctdb, uint32_t destnode)
|
||||
int ctdb_statistics_reset(struct ctdb_context *ctdb, uint32_t destnode)
|
||||
{
|
||||
int ret;
|
||||
int32_t res;
|
||||
|
||||
ret = ctdb_control(ctdb, destnode, 0,
|
||||
CTDB_CONTROL_STATUS_RESET, 0, tdb_null,
|
||||
CTDB_CONTROL_STATISTICS_RESET, 0, tdb_null,
|
||||
NULL, NULL, &res, NULL, NULL);
|
||||
if (ret != 0 || res != 0) {
|
||||
DEBUG(0,(__location__ " ctdb_control for reset status failed\n"));
|
||||
DEBUG(0,(__location__ " ctdb_control for reset statistics failed\n"));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -52,7 +52,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
switch (opcode) {
|
||||
case CTDB_CONTROL_PROCESS_EXISTS: {
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(pid_t));
|
||||
ctdb->status.controls.process_exists++;
|
||||
ctdb->statistics.controls.process_exists++;
|
||||
return kill(*(pid_t *)indata.dptr, 0);
|
||||
}
|
||||
|
||||
@ -69,14 +69,14 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
case CTDB_CONTROL_STATUS: {
|
||||
case CTDB_CONTROL_STATISTICS: {
|
||||
CHECK_CONTROL_DATA_SIZE(0);
|
||||
ctdb->status.controls.status++;
|
||||
ctdb->status.memory_used = talloc_total_size(ctdb);
|
||||
ctdb->status.frozen = (ctdb->freeze_mode == CTDB_FREEZE_FROZEN);
|
||||
ctdb->status.recovering = (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE);
|
||||
outdata->dptr = (uint8_t *)&ctdb->status;
|
||||
outdata->dsize = sizeof(ctdb->status);
|
||||
ctdb->statistics.controls.statistics++;
|
||||
ctdb->statistics.memory_used = talloc_total_size(ctdb);
|
||||
ctdb->statistics.frozen = (ctdb->freeze_mode == CTDB_FREEZE_FROZEN);
|
||||
ctdb->statistics.recovering = (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE);
|
||||
outdata->dptr = (uint8_t *)&ctdb->statistics;
|
||||
outdata->dsize = sizeof(ctdb->statistics);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -86,9 +86,9 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
case CTDB_CONTROL_STATUS_RESET: {
|
||||
case CTDB_CONTROL_STATISTICS_RESET: {
|
||||
CHECK_CONTROL_DATA_SIZE(0);
|
||||
ZERO_STRUCT(ctdb->status);
|
||||
ZERO_STRUCT(ctdb->statistics);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
|
||||
case CTDB_CONTROL_CONFIG: {
|
||||
CHECK_CONTROL_DATA_SIZE(0);
|
||||
ctdb->status.controls.get_config++;
|
||||
ctdb->statistics.controls.get_config++;
|
||||
outdata->dptr = (uint8_t *)ctdb;
|
||||
outdata->dsize = sizeof(*ctdb);
|
||||
return 0;
|
||||
@ -152,8 +152,8 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
|
||||
case CTDB_CONTROL_PING:
|
||||
CHECK_CONTROL_DATA_SIZE(0);
|
||||
ctdb->status.controls.ping++;
|
||||
return ctdb->status.num_clients;
|
||||
ctdb->statistics.controls.ping++;
|
||||
return ctdb->statistics.num_clients;
|
||||
|
||||
case CTDB_CONTROL_GET_DBNAME: {
|
||||
uint32_t db_id;
|
||||
@ -182,50 +182,50 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
}
|
||||
|
||||
case CTDB_CONTROL_DB_ATTACH:
|
||||
ctdb->status.controls.attach++;
|
||||
ctdb->statistics.controls.attach++;
|
||||
return ctdb_control_db_attach(ctdb, indata, outdata);
|
||||
|
||||
case CTDB_CONTROL_SET_CALL: {
|
||||
struct ctdb_control_set_call *sc =
|
||||
(struct ctdb_control_set_call *)indata.dptr;
|
||||
ctdb->status.controls.set_call++;
|
||||
ctdb->statistics.controls.set_call++;
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_control_set_call));
|
||||
return ctdb_daemon_set_call(ctdb, sc->db_id, sc->fn, sc->id);
|
||||
}
|
||||
|
||||
case CTDB_CONTROL_TRAVERSE_START:
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_traverse_start));
|
||||
ctdb->status.controls.traverse_start++;
|
||||
ctdb->statistics.controls.traverse_start++;
|
||||
return ctdb_control_traverse_start(ctdb, indata, outdata, srcnode);
|
||||
|
||||
case CTDB_CONTROL_TRAVERSE_ALL:
|
||||
ctdb->status.controls.traverse_all++;
|
||||
ctdb->statistics.controls.traverse_all++;
|
||||
return ctdb_control_traverse_all(ctdb, indata, outdata);
|
||||
|
||||
case CTDB_CONTROL_TRAVERSE_DATA:
|
||||
ctdb->status.controls.traverse_data++;
|
||||
ctdb->statistics.controls.traverse_data++;
|
||||
return ctdb_control_traverse_data(ctdb, indata, outdata);
|
||||
|
||||
case CTDB_CONTROL_REGISTER_SRVID:
|
||||
ctdb->status.controls.register_srvid++;
|
||||
ctdb->statistics.controls.register_srvid++;
|
||||
return daemon_register_message_handler(ctdb, client_id, srvid);
|
||||
|
||||
case CTDB_CONTROL_DEREGISTER_SRVID:
|
||||
ctdb->status.controls.deregister_srvid++;
|
||||
ctdb->statistics.controls.deregister_srvid++;
|
||||
return daemon_deregister_message_handler(ctdb, client_id, srvid);
|
||||
|
||||
case CTDB_CONTROL_ENABLE_SEQNUM:
|
||||
ctdb->status.controls.enable_seqnum++;
|
||||
ctdb->statistics.controls.enable_seqnum++;
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
|
||||
return ctdb_ltdb_enable_seqnum(ctdb, *(uint32_t *)indata.dptr);
|
||||
|
||||
case CTDB_CONTROL_UPDATE_SEQNUM:
|
||||
ctdb->status.controls.update_seqnum++;
|
||||
ctdb->statistics.controls.update_seqnum++;
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
|
||||
return ctdb_ltdb_update_seqnum(ctdb, *(uint32_t *)indata.dptr, srcnode);
|
||||
|
||||
case CTDB_CONTROL_SET_SEQNUM_FREQUENCY:
|
||||
ctdb->status.controls.set_seqnum_frequency++;
|
||||
ctdb->statistics.controls.set_seqnum_frequency++;
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
|
||||
return ctdb_ltdb_set_seqnum_frequency(ctdb, *(uint32_t *)indata.dptr);
|
||||
|
||||
@ -409,7 +409,7 @@ static void ctdb_control_timeout(struct event_context *ev, struct timed_event *t
|
||||
struct ctdb_control_state *state = talloc_get_type(private_data, struct ctdb_control_state);
|
||||
TALLOC_CTX *tmp_ctx = talloc_new(ev);
|
||||
|
||||
state->ctdb->status.timeouts.control++;
|
||||
state->ctdb->statistics.timeouts.control++;
|
||||
|
||||
talloc_steal(tmp_ctx, state);
|
||||
|
||||
|
@ -95,7 +95,7 @@ static void block_signal(int signum)
|
||||
*/
|
||||
static int daemon_queue_send(struct ctdb_client *client, struct ctdb_req_header *hdr)
|
||||
{
|
||||
client->ctdb->status.client_packets_sent++;
|
||||
client->ctdb->statistics.client_packets_sent++;
|
||||
return ctdb_queue_send(client->queue, (uint8_t *)hdr, hdr->length);
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ static int ctdb_client_destructor(struct ctdb_client *client)
|
||||
{
|
||||
ctdb_takeover_client_destructor_hook(client);
|
||||
ctdb_reqid_remove(client->ctdb, client->client_id);
|
||||
client->ctdb->status.num_clients--;
|
||||
client->ctdb->statistics.num_clients--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -305,8 +305,8 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
|
||||
res = ctdb_daemon_call_recv(state, dstate->call);
|
||||
if (res != 0) {
|
||||
DEBUG(0, (__location__ " ctdbd_call_recv() returned error\n"));
|
||||
client->ctdb->status.pending_calls--;
|
||||
ctdb_latency(&client->ctdb->status.max_call_latency, dstate->start_time);
|
||||
client->ctdb->statistics.pending_calls--;
|
||||
ctdb_latency(&client->ctdb->statistics.max_call_latency, dstate->start_time);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -315,8 +315,8 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
|
||||
length, struct ctdb_reply_call);
|
||||
if (r == NULL) {
|
||||
DEBUG(0, (__location__ " Failed to allocate reply_call in ctdb daemon\n"));
|
||||
client->ctdb->status.pending_calls--;
|
||||
ctdb_latency(&client->ctdb->status.max_call_latency, dstate->start_time);
|
||||
client->ctdb->statistics.pending_calls--;
|
||||
ctdb_latency(&client->ctdb->statistics.max_call_latency, dstate->start_time);
|
||||
return;
|
||||
}
|
||||
r->hdr.reqid = dstate->reqid;
|
||||
@ -327,9 +327,9 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
|
||||
if (res != 0) {
|
||||
DEBUG(0, (__location__ " Failed to queue packet from daemon to client\n"));
|
||||
}
|
||||
ctdb_latency(&client->ctdb->status.max_call_latency, dstate->start_time);
|
||||
ctdb_latency(&client->ctdb->statistics.max_call_latency, dstate->start_time);
|
||||
talloc_free(dstate);
|
||||
client->ctdb->status.pending_calls--;
|
||||
client->ctdb->statistics.pending_calls--;
|
||||
}
|
||||
|
||||
|
||||
@ -352,14 +352,14 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
|
||||
int ret;
|
||||
struct ctdb_context *ctdb = client->ctdb;
|
||||
|
||||
ctdb->status.total_calls++;
|
||||
ctdb->status.pending_calls++;
|
||||
ctdb->statistics.total_calls++;
|
||||
ctdb->statistics.pending_calls++;
|
||||
|
||||
ctdb_db = find_ctdb_db(client->ctdb, c->db_id);
|
||||
if (!ctdb_db) {
|
||||
DEBUG(0, (__location__ " Unknown database in request. db_id==0x%08x",
|
||||
c->db_id));
|
||||
ctdb->status.pending_calls--;
|
||||
ctdb->statistics.pending_calls--;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -371,13 +371,13 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
|
||||
daemon_incoming_packet, client, True);
|
||||
if (ret == -2) {
|
||||
/* will retry later */
|
||||
ctdb->status.pending_calls--;
|
||||
ctdb->statistics.pending_calls--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
DEBUG(0,(__location__ " Unable to fetch record\n"));
|
||||
ctdb->status.pending_calls--;
|
||||
ctdb->statistics.pending_calls--;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -385,7 +385,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
|
||||
if (dstate == NULL) {
|
||||
ctdb_ltdb_unlock(ctdb_db, key);
|
||||
DEBUG(0,(__location__ " Unable to allocate dstate\n"));
|
||||
ctdb->status.pending_calls--;
|
||||
ctdb->statistics.pending_calls--;
|
||||
return;
|
||||
}
|
||||
dstate->start_time = timeval_current();
|
||||
@ -397,8 +397,8 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
|
||||
if (call == NULL) {
|
||||
ctdb_ltdb_unlock(ctdb_db, key);
|
||||
DEBUG(0,(__location__ " Unable to allocate call\n"));
|
||||
ctdb->status.pending_calls--;
|
||||
ctdb_latency(&ctdb->status.max_call_latency, dstate->start_time);
|
||||
ctdb->statistics.pending_calls--;
|
||||
ctdb_latency(&ctdb->statistics.max_call_latency, dstate->start_time);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -418,8 +418,8 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
|
||||
|
||||
if (state == NULL) {
|
||||
DEBUG(0,(__location__ " Unable to setup call send\n"));
|
||||
ctdb->status.pending_calls--;
|
||||
ctdb_latency(&ctdb->status.max_call_latency, dstate->start_time);
|
||||
ctdb->statistics.pending_calls--;
|
||||
ctdb_latency(&ctdb->statistics.max_call_latency, dstate->start_time);
|
||||
return;
|
||||
}
|
||||
talloc_steal(state, dstate);
|
||||
@ -459,27 +459,27 @@ static void daemon_incoming_packet(void *p, struct ctdb_req_header *hdr)
|
||||
|
||||
switch (hdr->operation) {
|
||||
case CTDB_REQ_CALL:
|
||||
ctdb->status.client.req_call++;
|
||||
ctdb->statistics.client.req_call++;
|
||||
daemon_request_call_from_client(client, (struct ctdb_req_call *)hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REQ_MESSAGE:
|
||||
ctdb->status.client.req_message++;
|
||||
ctdb->statistics.client.req_message++;
|
||||
daemon_request_message_from_client(client, (struct ctdb_req_message *)hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REQ_CONNECT_WAIT:
|
||||
ctdb->status.client.req_connect_wait++;
|
||||
ctdb->statistics.client.req_connect_wait++;
|
||||
daemon_request_connect_wait(client, (struct ctdb_req_connect_wait *)hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REQ_SHUTDOWN:
|
||||
ctdb->status.client.req_shutdown++;
|
||||
ctdb->statistics.client.req_shutdown++;
|
||||
daemon_request_shutdown(client, (struct ctdb_req_shutdown *)hdr);
|
||||
break;
|
||||
|
||||
case CTDB_REQ_CONTROL:
|
||||
ctdb->status.client.req_control++;
|
||||
ctdb->statistics.client.req_control++;
|
||||
daemon_request_control_from_client(client, (struct ctdb_req_control *)hdr);
|
||||
break;
|
||||
|
||||
@ -505,7 +505,7 @@ static void ctdb_daemon_read_cb(uint8_t *data, size_t cnt, void *args)
|
||||
return;
|
||||
}
|
||||
|
||||
client->ctdb->status.client_packets_recv++;
|
||||
client->ctdb->statistics.client_packets_recv++;
|
||||
|
||||
if (cnt < sizeof(*hdr)) {
|
||||
ctdb_set_error(client->ctdb, "Bad packet length %u in daemon\n",
|
||||
@ -558,7 +558,7 @@ static void ctdb_accept_client(struct event_context *ev, struct fd_event *fde,
|
||||
client->ctdb = ctdb;
|
||||
client->fd = fd;
|
||||
client->client_id = ctdb_reqid_new(ctdb, client);
|
||||
ctdb->status.num_clients++;
|
||||
ctdb->statistics.num_clients++;
|
||||
|
||||
client->queue = ctdb_queue_setup(ctdb, client, fd, CTDB_DS_ALIGNMENT,
|
||||
ctdb_daemon_read_cb, client);
|
||||
|
@ -54,8 +54,8 @@ static void lockwait_handler(struct event_context *ev, struct fd_event *fde,
|
||||
key.dptr = talloc_memdup(tmp_ctx, key.dptr, key.dsize);
|
||||
|
||||
talloc_set_destructor(h, NULL);
|
||||
ctdb_latency(&h->ctdb->status.max_lockwait_latency, h->start_time);
|
||||
h->ctdb->status.pending_lockwait_calls--;
|
||||
ctdb_latency(&h->ctdb->statistics.max_lockwait_latency, h->start_time);
|
||||
h->ctdb->statistics.pending_lockwait_calls--;
|
||||
|
||||
/* the handle needs to go away when the context is gone - when
|
||||
the handle goes away this implicitly closes the pipe, which
|
||||
@ -79,7 +79,7 @@ static void lockwait_handler(struct event_context *ev, struct fd_event *fde,
|
||||
|
||||
static int lockwait_destructor(struct lockwait_handle *h)
|
||||
{
|
||||
h->ctdb->status.pending_lockwait_calls--;
|
||||
h->ctdb->statistics.pending_lockwait_calls--;
|
||||
kill(h->child, SIGKILL);
|
||||
waitpid(h->child, NULL, 0);
|
||||
return 0;
|
||||
@ -104,11 +104,11 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
|
||||
int ret;
|
||||
pid_t parent = getpid();
|
||||
|
||||
ctdb_db->ctdb->status.lockwait_calls++;
|
||||
ctdb_db->ctdb->status.pending_lockwait_calls++;
|
||||
ctdb_db->ctdb->statistics.lockwait_calls++;
|
||||
ctdb_db->ctdb->statistics.pending_lockwait_calls++;
|
||||
|
||||
if (!(result = talloc_zero(private_data, struct lockwait_handle))) {
|
||||
ctdb_db->ctdb->status.pending_lockwait_calls--;
|
||||
ctdb_db->ctdb->statistics.pending_lockwait_calls--;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
|
||||
|
||||
if (ret != 0) {
|
||||
talloc_free(result);
|
||||
ctdb_db->ctdb->status.pending_lockwait_calls--;
|
||||
ctdb_db->ctdb->statistics.pending_lockwait_calls--;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
|
||||
close(result->fd[0]);
|
||||
close(result->fd[1]);
|
||||
talloc_free(result);
|
||||
ctdb_db->ctdb->status.pending_lockwait_calls--;
|
||||
ctdb_db->ctdb->statistics.pending_lockwait_calls--;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
|
||||
(void *)result);
|
||||
if (result->fde == NULL) {
|
||||
talloc_free(result);
|
||||
ctdb_db->ctdb->status.pending_lockwait_calls--;
|
||||
ctdb_db->ctdb->statistics.pending_lockwait_calls--;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ static void ctdb_traverse_all_timeout(struct event_context *ev, struct timed_eve
|
||||
{
|
||||
struct ctdb_traverse_all_handle *state = talloc_get_type(private_data, struct ctdb_traverse_all_handle);
|
||||
|
||||
state->ctdb->status.timeouts.traverse++;
|
||||
state->ctdb->statistics.timeouts.traverse++;
|
||||
|
||||
state->callback(state->private_data, tdb_null, tdb_null);
|
||||
talloc_free(state);
|
||||
|
@ -211,8 +211,8 @@ struct ctdb_db_context *find_ctdb_db(struct ctdb_context *ctdb, uint32_t id);
|
||||
|
||||
struct ctdb_context *ctdb_cmdline_client(struct event_context *ev);
|
||||
|
||||
struct ctdb_status;
|
||||
int ctdb_ctrl_status(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_status *status);
|
||||
struct ctdb_statistics;
|
||||
int ctdb_ctrl_statistics(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_statistics *status);
|
||||
|
||||
int ctdb_ctrl_shutdown(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
|
||||
|
||||
@ -327,7 +327,7 @@ uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
uint32_t *num_nodes);
|
||||
|
||||
int ctdb_status_reset(struct ctdb_context *ctdb, uint32_t destnode);
|
||||
int ctdb_statistics_reset(struct ctdb_context *ctdb, uint32_t destnode);
|
||||
|
||||
int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile);
|
||||
|
||||
|
@ -115,6 +115,7 @@ struct ctdb_node {
|
||||
|
||||
/* the public address of this node, if known */
|
||||
const char *public_address;
|
||||
uint8_t public_netmask_bits;
|
||||
|
||||
/* the node number that has taken over this nodes public address, if any.
|
||||
If not taken over, then set to -1 */
|
||||
@ -165,7 +166,7 @@ struct ctdb_daemon_data {
|
||||
/*
|
||||
ctdb status information
|
||||
*/
|
||||
struct ctdb_status {
|
||||
struct ctdb_statistics {
|
||||
uint32_t num_clients;
|
||||
uint32_t frozen;
|
||||
uint32_t recovering;
|
||||
@ -195,7 +196,7 @@ struct ctdb_status {
|
||||
uint32_t req_control;
|
||||
} client;
|
||||
struct {
|
||||
uint32_t status;
|
||||
uint32_t statistics;
|
||||
uint32_t get_config;
|
||||
uint32_t ping;
|
||||
uint32_t attach;
|
||||
@ -220,7 +221,7 @@ struct ctdb_status {
|
||||
uint32_t lockwait_calls;
|
||||
uint32_t pending_lockwait_calls;
|
||||
uint32_t memory_used;
|
||||
uint32_t __last_counter; /* hack for control_status_all */
|
||||
uint32_t __last_counter; /* hack for control_statistics_all */
|
||||
uint32_t max_hop_count;
|
||||
double max_call_latency;
|
||||
double max_lockwait_latency;
|
||||
@ -296,7 +297,7 @@ struct ctdb_context {
|
||||
struct ctdb_db_context *db_list;
|
||||
struct ctdb_message_list *message_list;
|
||||
struct ctdb_daemon_data daemon;
|
||||
struct ctdb_status status;
|
||||
struct ctdb_statistics statistics;
|
||||
struct ctdb_vnn_map *vnn_map;
|
||||
uint32_t num_clients;
|
||||
uint32_t seqnum_frequency;
|
||||
@ -368,7 +369,7 @@ struct ctdb_ltdb_header {
|
||||
};
|
||||
|
||||
enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS,
|
||||
CTDB_CONTROL_STATUS,
|
||||
CTDB_CONTROL_STATISTICS,
|
||||
CTDB_CONTROL_CONFIG,
|
||||
CTDB_CONTROL_PING,
|
||||
CTDB_CONTROL_GETDBPATH,
|
||||
@ -384,7 +385,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS,
|
||||
CTDB_CONTROL_PUSH_DB,
|
||||
CTDB_CONTROL_GET_RECMODE,
|
||||
CTDB_CONTROL_SET_RECMODE,
|
||||
CTDB_CONTROL_STATUS_RESET,
|
||||
CTDB_CONTROL_STATISTICS_RESET,
|
||||
CTDB_CONTROL_DB_ATTACH,
|
||||
CTDB_CONTROL_SET_CALL,
|
||||
CTDB_CONTROL_TRAVERSE_START,
|
||||
|
@ -225,15 +225,57 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist)
|
||||
}
|
||||
|
||||
for (i=0;i<nlines;i++) {
|
||||
char *p;
|
||||
struct in_addr in;
|
||||
|
||||
ctdb->nodes[i]->public_address = talloc_strdup(ctdb->nodes[i], lines[i]);
|
||||
CTDB_NO_MEMORY(ctdb, ctdb->nodes[i]->public_address);
|
||||
ctdb->nodes[i]->takeover_vnn = -1;
|
||||
|
||||
/* see if they supplied a netmask length */
|
||||
p = strchr(ctdb->nodes[i]->public_address, '/');
|
||||
if (!p) {
|
||||
DEBUG(0,("You must supply a netmask for public address %s\n",
|
||||
ctdb->nodes[i]->public_address));
|
||||
return -1;
|
||||
}
|
||||
*p = 0;
|
||||
ctdb->nodes[i]->public_netmask_bits = atoi(p+1);
|
||||
|
||||
if (ctdb->nodes[i]->public_netmask_bits > 32) {
|
||||
DEBUG(0, ("Illegal netmask for IP %s\n", ctdb->nodes[i]->public_address));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (inet_aton(ctdb->nodes[i]->public_address, &in) != 0) {
|
||||
DEBUG(0,("Badly formed IP '%s' in public address list\n", ctdb->nodes[i]->public_address));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
talloc_free(lines);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
see if two IPs are on the same subnet
|
||||
*/
|
||||
static bool ctdb_same_subnet(const char *ip1, const char *ip2, uint8_t netmask_bits)
|
||||
{
|
||||
struct in_addr in1, in2;
|
||||
uint32_t mask;
|
||||
|
||||
inet_aton(ip1, &in1);
|
||||
inet_aton(ip2, &in2);
|
||||
|
||||
mask = ~((1LL<<(32-netmask_bits))-1);
|
||||
|
||||
if ((ntohl(in1.s_addr) & mask) != (ntohl(in2.s_addr) & mask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
make any IP alias changes for public addresses that are necessary
|
||||
@ -252,16 +294,16 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
|
||||
for (j=(i+1)%nodemap->num;
|
||||
j != i;
|
||||
j=(j+1)%nodemap->num) {
|
||||
if ((nodemap->nodes[j].flags & NODE_FLAGS_CONNECTED) &&
|
||||
same_subnet(nodemap->nodes[j]->public_address, nodemap->nodes[i]->public_address,
|
||||
nodemap->nodes[i]->public_netmask)) {
|
||||
if ((nodemap->nodes[j].flags & NODE_FLAGS_CONNECTED) &&
|
||||
ctdb_same_subnet(ctdb->nodes[j]->public_address, ctdb->nodes[i]->public_address,
|
||||
ctdb->nodes[i]->public_netmask_bits)) {
|
||||
ctdb->nodes[i]->takeover_vnn = nodemap->nodes[j].vnn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == i) {
|
||||
DEBUG(0,(__location__ " No node available on same network to take %s\n",
|
||||
nodemap->nodes[i]->public_address));
|
||||
ctdb->nodes[i]->public_address));
|
||||
ctdb->nodes[i]->takeover_vnn = -1;
|
||||
}
|
||||
}
|
||||
|
@ -7,29 +7,29 @@ $VALGRIND bin/ctdbd --nlist direct/nodes.txt
|
||||
$VALGRIND bin/ctdbd --nlist direct/nodes.txt
|
||||
|
||||
echo "Testing ping"
|
||||
$VALGRIND bin/ctdb_control ping || exit 1
|
||||
$VALGRIND bin/ctdb ping || exit 1
|
||||
|
||||
echo "Testing status"
|
||||
$VALGRIND bin/ctdb_control status all || exit 1
|
||||
$VALGRIND bin/ctdb status || exit 1
|
||||
|
||||
echo "Testing statusreset"
|
||||
$VALGRIND bin/ctdb_control statusreset all || exit 1
|
||||
echo "Testing statistics"
|
||||
$VALGRIND bin/ctdb -n all statistics || exit 1
|
||||
|
||||
echo "Testing statisticsreset"
|
||||
$VALGRIND bin/ctdb -n all statisticsreset || exit 1
|
||||
|
||||
echo "Testing debug"
|
||||
$VALGRIND bin/ctdb_control debug all 5 || exit 1
|
||||
$VALGRIND bin/ctdb_control debuglevel || exit 1
|
||||
$VALGRIND bin/ctdb_control debug all 0 || exit 1
|
||||
$VALGRIND bin/ctdb_control debuglevel || exit 1
|
||||
|
||||
echo "Testing map calls"
|
||||
$VALGRIND bin/ctdb_control getvnnmap 0 || exit 1
|
||||
$VALGRIND bin/ctdb -n all setdebug 5 || exit 1
|
||||
$VALGRIND bin/ctdb -n all getdebug || exit 1
|
||||
$VALGRIND bin/ctdb -n all setdebug 0 || exit 1
|
||||
$VALGRIND bin/ctdb -n all getdebug || exit 1
|
||||
|
||||
echo "Attaching to some databases"
|
||||
$VALGRIND bin/ctdb_control attach test1.tdb || exit 1
|
||||
$VALGRIND bin/ctdb_control attach test2.tdb || exit 1
|
||||
$VALGRIND bin/ctdb attach test1.tdb || exit 1
|
||||
$VALGRIND bin/ctdb attach test2.tdb || exit 1
|
||||
|
||||
echo "Testing getdbmap"
|
||||
$VALGRIND bin/ctdb_control getdbmap 0 || exit 1
|
||||
$VALGRIND bin/ctdb getdbmap || exit 1
|
||||
|
||||
echo "All done"
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
CTDB_CONTROL="./bin/ctdb_control"
|
||||
export CTDB_CONTROL
|
||||
|
||||
$CTDB_CONTROL getnodemap 0 | egrep "^vnn:" | sed -e "s/^vnn://" -e "s/ .*$//" | while read NODE; do
|
||||
xterm -geometry 30x25 -e "watch -n1 \"$CTDB_CONTROL getnodemap $NODE; $CTDB_CONTROL getvnnmap $NODE; $CTDB_CONTROL getrecmode $NODE; $CTDB_CONTROL getrecmaster $NODE\"" &
|
||||
CTDB="./bin/ctdb"
|
||||
export CTDB
|
||||
|
||||
$CTDB status | egrep "^vnn:" | sed -e "s/^vnn://" -e "s/ .*$//" | while read NODE; do
|
||||
xterm -geometry 30x25 -e "watch -n1 \"$CTDB -n $NODE status\"" &
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user