Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
83beaa88
Commit
83beaa88
authored
Jul 01, 2014
by
antirez
Browse files
LATENCY LATEST implemented.
parent
753b707d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/latency.c
View file @
83beaa88
...
@@ -107,6 +107,27 @@ void latencyCommandReplyWithSamples(redisClient *c, struct latencyTimeSeries *ts
...
@@ -107,6 +107,27 @@ void latencyCommandReplyWithSamples(redisClient *c, struct latencyTimeSeries *ts
setDeferredMultiBulkLength
(
c
,
replylen
,
samples
);
setDeferredMultiBulkLength
(
c
,
replylen
,
samples
);
}
}
/* latencyCommand() helper to produce the reply for the LATEST subcommand,
* listing the last latency sample for every event type registered so far. */
void
latencyCommandReplyWithLatestEvents
(
redisClient
*
c
)
{
dictIterator
*
di
;
dictEntry
*
de
;
addReplyMultiBulkLen
(
c
,
dictSize
(
server
.
latency_events
));
di
=
dictGetIterator
(
server
.
latency_events
);
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
char
*
event
=
dictGetKey
(
de
);
struct
latencyTimeSeries
*
ts
=
dictGetVal
(
de
);
int
last
=
(
ts
->
idx
+
LATENCY_TS_LEN
-
1
)
%
LATENCY_TS_LEN
;
addReplyMultiBulkLen
(
c
,
3
);
addReplyBulkCString
(
c
,
event
);
addReplyLongLong
(
c
,
ts
->
samples
[
last
].
time
);
addReplyLongLong
(
c
,
ts
->
samples
[
last
].
latency
);
}
dictReleaseIterator
(
di
);
}
/* LATENCY command implementations.
/* LATENCY command implementations.
*
*
* LATENCY SAMPLES: return time-latency samples for the specified event.
* LATENCY SAMPLES: return time-latency samples for the specified event.
...
@@ -122,6 +143,9 @@ void latencyCommand(redisClient *c) {
...
@@ -122,6 +143,9 @@ void latencyCommand(redisClient *c) {
ts
=
dictFetchValue
(
server
.
latency_events
,
c
->
argv
[
2
]
->
ptr
);
ts
=
dictFetchValue
(
server
.
latency_events
,
c
->
argv
[
2
]
->
ptr
);
if
(
ts
==
NULL
)
goto
nodataerr
;
if
(
ts
==
NULL
)
goto
nodataerr
;
latencyCommandReplyWithSamples
(
c
,
ts
);
latencyCommandReplyWithSamples
(
c
,
ts
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"latest"
)
&&
c
->
argc
==
2
)
{
/* LATENCY LATEST */
latencyCommandReplyWithLatestEvents
(
c
);
}
else
{
}
else
{
addReply
(
c
,
shared
.
syntaxerr
);
addReply
(
c
,
shared
.
syntaxerr
);
return
;
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment