Skip to content

Commit

Permalink
Split job stats into its own command: stats-job.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Rarick committed Feb 26, 2008
1 parent e897546 commit 4ab2962
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 70 deletions.
144 changes: 78 additions & 66 deletions doc/protocol.txt
Expand Up @@ -346,121 +346,133 @@ KICKED <count>\r\n

- <count> is an integer indicating the number of jobs actually kicked.

The stats command gives statistical information. If a job id is given, the
response will contain information about that job if it exists. Otherwise stats
will return information about the system as a whole. Its form is:
The stats-job command gives statistical information about the specified job if
it exists. Its form is:

stats[ <id>]\r\n
stats-job <id>\r\n

If a job id is given, the response may be:
- <id> is a job id.

- "NOT_FOUND\r\n" if the job does not exist.
The response is one of:

Otherwise the server will respond:
- "NOT_FOUND\r\n" if the job does not exist.

OK <bytes>\r\n
<data>\r\n
- "OK <bytes>\r\n<data>\r\n"

- <bytes> is the size of the following data section in bytes.
- <bytes> is the size of the following data section in bytes.

- <data> is a sequence of bytes of length <bytes> from the previous line. It
is a YAML file with statistical information represented a dictionary.
- <data> is a sequence of bytes of length <bytes> from the previous line. It
is a YAML file with statistical information represented a dictionary.

The stats-job data is a YAML file representing a single dictionary of strings
to scalars. It contains these keys:

- "id" is the job id

- "tube" is the name of the tube that contains this job

Stats format
- "state" is "ready" or "delayed" or "reserved" or "buried"

The stats data is a YAML file representing a single dictionary of strings to
scalars.
- "pri" is the priority value set by the put, release, or bury commands.

- The stats dict for a job contains these keys:
- "age" is the time in seconds since the put command that created this job.

- "id" is the job id
- "time-left" is the number of seconds left until the server puts this job
into the ready queue. This number is only meaningful if the job is
reserved or delayed. If the job is reserved and this amount of time
elapses before its state changes, it is considered to have timed out.

- "tube" is the name of the tube that contains this job
- "timeouts" is the number of times this job has timed out during a
reservation.

- "state" is "ready" or "delayed" or "reserved" or "buried"
- "releases" is the number of times a client has released this job from a
reservation.

- "pri" is the priority value set by the put, release, or bury commands.
- "buries" is the number of times this job has been buried.

- "age" is the time in seconds since the put command that created this job.
- "kicks" is the number of times this job has been kicked.

- "time-left" is the number of seconds left until the server puts this job
into the ready queue. This number is only meaningful if the job is
reserved or delayed. If the job is reserved and this amount of time
elapses before its state changes, it is considered to have timed out.
The stats command gives statistical information about the system as a whole.
Its form is:

- "timeouts" is the number of times this job has timed out during a
reservation.
stats\r\n

- "releases" is the number of times a client has released this job from a
reservation.
The server will respond:

- "buries" is the number of times this job has been buried.
OK <bytes>\r\n
<data>\r\n

- <bytes> is the size of the following data section in bytes.

- <data> is a sequence of bytes of length <bytes> from the previous line. It
is a YAML file with statistical information represented a dictionary.

- "kicks" is the number of times this job has been kicked.
The stats data for the system is a YAML file representing a single dictionary
of strings to scalars. It contains these keys:

- The stats dict for the system contains these keys:
- "current-jobs-urgent" is the number of ready jobs with priority < 1024.

- "current-jobs-urgent" is the number of ready jobs with priority < 1024.
- "current-jobs-ready" is the number of jobs in the ready queue.

- "current-jobs-ready" is the number of jobs in the ready queue.
- "current-jobs-reserved" is the number of jobs reserved by all clients.

- "current-jobs-reserved" is the number of jobs reserved by all clients.
- "current-jobs-delayed" is the number of delayed jobs.

- "current-jobs-delayed" is the number of delayed jobs.
- "current-jobs-buried" is the number of buried jobs.

- "current-jobs-buried" is the number of buried jobs.
- "cmd-put" is the cumulative number of put commands.

- "cmd-put" is the cumulative number of put commands.
- "cmd-peek" is the cumulative number of peek commands.

- "cmd-peek" is the cumulative number of peek commands.
- "cmd-reserve" is the cumulative number of reserve commands.

- "cmd-reserve" is the cumulative number of reserve commands.
- "cmd-delete" is the cumulative number of delete commands.

- "cmd-delete" is the cumulative number of delete commands.
- "cmd-release" is the cumulative number of release commands.

- "cmd-release" is the cumulative number of release commands.
- "cmd-bury" is the cumulative number of bury commands.

- "cmd-bury" is the cumulative number of bury commands.
- "cmd-kick" is the cumulative number of kick commands.

- "cmd-kick" is the cumulative number of kick commands.
- "cmd-stats" is the cumulative number of stats commands.

- "cmd-stats" is the cumulative number of stats commands.
- "cmd-stats-job" is the cumulative number of stats-job commands.

- "cmd-list-tubes" is the cumulative number of list-tubes commands.
- "cmd-list-tubes" is the cumulative number of list-tubes commands.

- "cmd-list-watched-tubes" is the cumulative number of list-watched-tubes
commands.
- "cmd-list-watched-tubes" is the cumulative number of list-watched-tubes
commands.

- "job-timeouts" is the cumulative count of times a job has timed out.
- "job-timeouts" is the cumulative count of times a job has timed out.

- "total-jobs" is the cumulative count of jobs created.
- "total-jobs" is the cumulative count of jobs created.

- "current-tubes" is the number of currently-existing tubes.
- "current-tubes" is the number of currently-existing tubes.

- "current-connections" is the number of currently open connections.
- "current-connections" is the number of currently open connections.

- "current-producers" is the number of open connections that have each
issued at least one put command.
- "current-producers" is the number of open connections that have each
issued at least one put command.

- "current-workers" is the number of open connections that have each issued
at least one reserve command.
- "current-workers" is the number of open connections that have each issued
at least one reserve command.

- "current-waiting" is the number of open connections that have issued a
reserve command but not yet received a response.
- "current-waiting" is the number of open connections that have issued a
reserve command but not yet received a response.

- "total-connections" is the cumulative count of connections.
- "total-connections" is the cumulative count of connections.

- "pid" is the process id of the server.
- "pid" is the process id of the server.

- "version" is the version string of the server.
- "version" is the version string of the server.

- "rusage-utime" is the accumulated user CPU time of this process in seconds
and microseconds.
- "rusage-utime" is the accumulated user CPU time of this process in seconds
and microseconds.

- "rusage-stime" is the accumulated system CPU time of this process in
seconds and microseconds.
- "rusage-stime" is the accumulated system CPU time of this process in
seconds and microseconds.

- "uptime" is the number of seconds since this server started running.
- "uptime" is the number of seconds since this server started running.

The list-tubes command returns a list of all existing tubes. Its form is:

Expand Down
10 changes: 6 additions & 4 deletions prot.c
Expand Up @@ -52,7 +52,7 @@
#define CMD_BURY "bury "
#define CMD_KICK "kick "
#define CMD_STATS "stats"
#define CMD_JOBSTATS "stats "
#define CMD_JOBSTATS "stats-job "
#define CMD_USE "use "
#define CMD_WATCH "watch "
#define CMD_IGNORE "ignore "
Expand Down Expand Up @@ -114,6 +114,7 @@
"cmd-bury: %llu\n" \
"cmd-kick: %llu\n" \
"cmd-stats: %llu\n" \
"cmd-stats-job: %llu\n" \
"cmd-list-tubes: %llu\n" \
"cmd-list-watched-tubes: %llu\n" \
"job-timeouts: %llu\n" \
Expand Down Expand Up @@ -160,8 +161,8 @@ static int drain_mode = 0;
static time_t start_time;
static unsigned long long int put_ct = 0, peek_ct = 0, reserve_ct = 0,
delete_ct = 0, release_ct = 0, bury_ct = 0, kick_ct = 0,
stats_ct = 0, timeout_ct = 0, list_tubes_ct = 0,
list_watched_tubes_ct = 0;
stats_job_ct = 0, stats_ct = 0, timeout_ct = 0,
list_tubes_ct = 0, list_watched_tubes_ct = 0;

static unsigned int cur_reserved_ct = 0;

Expand Down Expand Up @@ -689,6 +690,7 @@ fmt_stats(char *buf, size_t size, void *x)
bury_ct,
kick_ct,
stats_ct,
stats_job_ct,
list_tubes_ct,
list_watched_tubes_ct,
timeout_ct,
Expand Down Expand Up @@ -1099,7 +1101,7 @@ dispatch_cmd(conn c)
j = peek_job(id);
if (!j) return reply(c, MSG_NOTFOUND, MSG_NOTFOUND_LEN, STATE_SENDWORD);

stats_ct++; /* stats */
stats_job_ct++; /* stats */

if (!j->tube) return reply_serr(c, MSG_INTERNAL_ERROR);
do_stats(c, fmt_job_stats, j);
Expand Down

0 comments on commit 4ab2962

Please sign in to comment.