diff options
| author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2010-09-29 10:38:41 +1000 |
|---|---|---|
| committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2010-09-29 12:14:24 +1000 |
| commit | 39c367a68ff47efc7b61bf8247ad60fd4cfbfbc8 (patch) | |
| tree | 4171609f9f24ba4680540e296538bd73b91452e7 /ctdb/include | |
| parent | 869242a7cdef1169fc310efea1624ec6e134ad19 (diff) | |
Create macros to update the statistics counters and use these macros
everywhere instead of manipulating the coutenrs directly.
(This used to be ctdb commit 2e648df890e5713bc575965d87937827b068d0d7)
Diffstat (limited to 'ctdb/include')
| -rw-r--r-- | ctdb/include/ctdb_private.h | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index cd6aeec1c4..1f2477054f 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -276,8 +276,58 @@ struct ctdb_daemon_data { struct ctdb_queue *queue; }; + +#define CTDB_UPDATE_STAT(ctdb, counter, value) \ + { \ + if (value > ctdb->statistics.counter) { \ + ctdb->statistics.counter = c->hopcount; \ + } \ + } + +#define CTDB_INCREMENT_STAT(ctdb, counter) \ + { \ + ctdb->statistics.counter++; \ + } + +#define CTDB_DECREMENT_STAT(ctdb, counter) \ + { \ + if (ctdb->statistics.counter > 0) \ + ctdb->statistics.counter--; \ + } + +#define CTDB_UPDATE_RECLOCK_LATENCY(ctdb, name, counter, value) \ + { \ + if (value > ctdb->statistics.counter) { \ + ctdb->statistics.counter = value; \ + } \ + \ + if (ctdb->tunable.reclock_latency_ms != 0) { \ + if (value*1000 > ctdb->tunable.reclock_latency_ms) { \ + DEBUG(DEBUG_ERR, ("High RECLOCK latency %fs for operation %s\n", value, name)); \ + } \ + } \ + } + + +#define CTDB_UPDATE_LATENCY(ctdb, db, operation, counter, t) \ + { \ + double l = timeval_elapsed(&t); \ + if (l > ctdb->statistics.counter) { \ + ctdb->statistics.counter = l; \ + } \ + \ + if (ctdb->tunable.log_latency_ms !=0) { \ + if (l*1000 > ctdb->tunable.log_latency_ms) { \ + DEBUG(DEBUG_WARNING, ("High latency %.6fs for operation %s on database %s\n", l, operation, db->db_name));\ + } \ + } \ + } + + + + /* - ctdb status information + ctdb statistics information */ struct ctdb_statistics { uint32_t num_clients; @@ -748,9 +798,6 @@ void ctdb_recv_raw_pkt(void *p, uint8_t *data, uint32_t length); int ctdb_socket_connect(struct ctdb_context *ctdb); -void ctdb_latency(struct ctdb_db_context *ctdb_db, const char *name, double *latency, struct timeval t); -void ctdb_reclock_latency(struct ctdb_context *ctdb, const char *name, double *latency, double l); - #define CTDB_BAD_REQID ((uint32_t)-1) uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state); void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location); @@ -1339,4 +1386,6 @@ int update_ip_assignment_tree(struct ctdb_context *ctdb, int ctdb_init_tevent_logging(struct ctdb_context *ctdb); +int ctdb_update_stat_counter(struct ctdb_context *ctdb, uint32_t *counter, uint32_t value); + #endif |
