STATISTICS: add total counts for number of delegations and number of revokes
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 8 Feb 2012 02:42:30 +0000 (13:42 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 8 Feb 2012 02:42:30 +0000 (13:42 +1100)
Everytime we give a delegation to another node we count this as one delegation.
If the same record is delegated to several nodes we count one for each node.

Everytime a record has all its delegations revoked we count this as one revoke.

(This used to be ctdb commit b098bcf8007be63889aaed640a951b0eeaa9d191)

ctdb/include/ctdb_protocol.h
ctdb/server/ctdb_call.c
ctdb/server/ctdb_daemon.c
ctdb/tools/ctdb.c

index 0b3245dc882b032546bfe98943b953bf4c329eb5..9cdf91c8d4d1781c447c6be3506393a9df0eabba 100644 (file)
@@ -646,6 +646,8 @@ struct ctdb_statistics {
        uint32_t num_recoveries;
        struct timeval statistics_start_time;
        struct timeval statistics_current_time;
+       uint32_t total_ro_delegations;
+       uint32_t total_ro_revokes;
 };
 
 /*
index 654fff43fab1865bb52ce9551a7314eb78111da6..8856f2ac28cfba1deedfe65d5d15d31440e095a1 100644 (file)
@@ -513,6 +513,7 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 
        if (header.flags & CTDB_REC_RO_REVOKE_COMPLETE) {
                header.flags &= ~(CTDB_REC_RO_HAVE_DELEGATIONS|CTDB_REC_RO_HAVE_READONLY|CTDB_REC_RO_REVOKING_READONLY|CTDB_REC_RO_REVOKE_COMPLETE);
+               CTDB_INCREMENT_STAT(ctdb, total_ro_revokes);
                if (ctdb_ltdb_store(ctdb_db, call->key, &header, data) != 0) {
                        ctdb_fatal(ctdb, "Failed to write header with cleared REVOKE flag");
                }
@@ -619,6 +620,7 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
                }
 
                ctdb_queue_packet(ctdb, &r->hdr);
+               CTDB_INCREMENT_STAT(ctdb, total_ro_delegations);
 
                talloc_free(r);
                return;
index 53f47d67faa6a8f90eb00c67cd4f79bd0628d2ed..bff91c5fa6789157a837ecb9032b8f9fcffd3dc2 100644 (file)
@@ -690,6 +690,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
 
        if (header.flags & CTDB_REC_RO_REVOKE_COMPLETE) {
                header.flags &= ~(CTDB_REC_RO_HAVE_DELEGATIONS|CTDB_REC_RO_HAVE_READONLY|CTDB_REC_RO_REVOKING_READONLY|CTDB_REC_RO_REVOKE_COMPLETE);
+               CTDB_INCREMENT_STAT(ctdb, total_ro_revokes);
                if (ctdb_ltdb_store(ctdb_db, key, &header, data) != 0) {
                        ctdb_fatal(ctdb, "Failed to write header with cleared REVOKE flag");
                }
index e852ca2e0a084fdf0f6326883de867271431d177..ceab2979ffde4ba8f4ba05fc0ce9cddc71fca873 100644 (file)
@@ -343,6 +343,8 @@ static void show_statistics(struct ctdb_statistics *s, int show_header)
                STATISTICS_FIELD(pending_childwrite_calls),
                STATISTICS_FIELD(memory_used),
                STATISTICS_FIELD(max_hop_count),
+               STATISTICS_FIELD(total_ro_delegations),
+               STATISTICS_FIELD(total_ro_revokes),
        };
        tmp = s->statistics_current_time.tv_sec - s->statistics_start_time.tv_sec;
        seconds = tmp%60;