Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding support for counting deletes on a tube

this makes it easier to track inflow/outflow of a tube
  • Loading branch information...
commit 772033f6705a1eae548eb06132b1e861cfe65f8f 1 parent b5a2049
@drasch drasch authored
View
1  dat.h
@@ -72,6 +72,7 @@ struct stats {
uint buried_ct;
uint reserved_ct;
uint pause_ct;
+ uint64 total_delete_ct;
uint64 total_jobs_ct;
};
View
2  doc/protocol.txt
@@ -485,6 +485,8 @@ to scalars. It contains these keys:
- "pause" is the number of seconds the tube has been paused for.
+ - "cmd-delete" is the cumulative number of delete commands for this tube
+
- "cmd-pause-tube" is the cumulative number of pause-tube commands for this
tube.
View
1  integ-test.c
@@ -35,6 +35,7 @@ static T ts[] = {
{"sh-tests/omit-time-left.commands", "sh-tests/omit-time-left.expected"},
{"sh-tests/pause-tube.commands", "sh-tests/pause-tube.expected"},
{"sh-tests/small_delay.commands", "sh-tests/small_delay.expected"},
+ {"sh-tests/stats_tube.commands", "sh-tests/stats_tube.expected"},
{"sh-tests/too-big.commands", "sh-tests/too-big.expected"},
{"sh-tests/ttr-large.commands", "sh-tests/ttr-large.expected"},
{"sh-tests/zero_delay.commands", "sh-tests/zero_delay.expected"},
View
4 prot.c
@@ -192,6 +192,7 @@ size_t job_data_size_limit = JOB_DATA_SIZE_LIMIT_DEFAULT;
"current-using: %u\n" \
"current-watching: %u\n" \
"current-waiting: %u\n" \
+ "cmd-delete: %" PRIu64 "\n" \
"cmd-pause-tube: %u\n" \
"pause: %" PRIu64 "\n" \
"pause-time-left: %" PRIu64 "\n" \
@@ -1082,6 +1083,7 @@ fmt_stats_tube(char *buf, size_t size, tube t)
t->using_ct,
t->watching_ct,
t->stat.waiting_ct,
+ t->stat.total_delete_ct,
t->stat.pause_ct,
t->pause / 1000000000,
time_left);
@@ -1292,6 +1294,8 @@ dispatch_cmd(conn c)
if (!j) return reply(c, MSG_NOTFOUND, MSG_NOTFOUND_LEN, STATE_SENDWORD);
+ j->tube->stat.total_delete_ct++;
+
j->r.state = Invalid;
r = walwrite(&c->srv->wal, j);
walmaint(&c->srv->wal);
View
9 sh-tests/pause-tube.expected
@@ -1,6 +1,6 @@
INSERTED 1
INSERTED 2
-OK 251
+OK 265
---
name: default
current-jobs-urgent: 0
@@ -12,12 +12,13 @@ total-jobs: 2
current-using: 1
current-watching: 1
current-waiting: 0
+cmd-delete: 0
cmd-pause-tube: 0
pause: 0
pause-time-left: 0
PAUSED
-OK 252
+OK 266
---
name: default
current-jobs-urgent: 0
@@ -29,6 +30,7 @@ total-jobs: 2
current-using: 1
current-watching: 1
current-waiting: 0
+cmd-delete: 0
cmd-pause-tube: 1
pause: 10
pause-time-left: 9
@@ -38,7 +40,7 @@ RESERVED 1 1
1
DELETED
PAUSED
-OK 251
+OK 265
---
name: default
current-jobs-urgent: 1
@@ -50,6 +52,7 @@ total-jobs: 2
current-using: 1
current-watching: 1
current-waiting: 0
+cmd-delete: 1
cmd-pause-tube: 3
pause: 3
pause-time-left: 2
View
7 sh-tests/stats_tube.commands
@@ -0,0 +1,7 @@
+use tubea
+put 0 0 0 0
+
+delete 1
+stats-tube tubea
+stats-tube default
+quit
View
37 sh-tests/stats_tube.expected
@@ -0,0 +1,37 @@
+USING tubea
+INSERTED 1
+DELETED
+OK 263
+---
+name: tubea
+current-jobs-urgent: 0
+current-jobs-ready: 0
+current-jobs-reserved: 0
+current-jobs-delayed: 0
+current-jobs-buried: 0
+total-jobs: 1
+current-using: 1
+current-watching: 0
+current-waiting: 0
+cmd-delete: 1
+cmd-pause-tube: 0
+pause: 0
+pause-time-left: 0
+
+OK 265
+---
+name: default
+current-jobs-urgent: 0
+current-jobs-ready: 0
+current-jobs-reserved: 0
+current-jobs-delayed: 0
+current-jobs-buried: 0
+total-jobs: 0
+current-using: 0
+current-watching: 1
+current-waiting: 0
+cmd-delete: 0
+cmd-pause-tube: 0
+pause: 0
+pause-time-left: 0
+
Please sign in to comment.
Something went wrong with that request. Please try again.