Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
dd142b9c
Commit
dd142b9c
authored
Apr 29, 2010
by
antirez
Browse files
New MONITOR output format with timestamp, every command in a single line, string representations
parent
f40b035d
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
dd142b9c
...
@@ -558,6 +558,7 @@ static int rdbSaveBackground(char *filename);
...
@@ -558,6 +558,7 @@ static int rdbSaveBackground(char *filename);
static
robj
*
createStringObject
(
char
*
ptr
,
size_t
len
);
static
robj
*
createStringObject
(
char
*
ptr
,
size_t
len
);
static
robj
*
dupStringObject
(
robj
*
o
);
static
robj
*
dupStringObject
(
robj
*
o
);
static
void
replicationFeedSlaves
(
list
*
slaves
,
int
dictid
,
robj
**
argv
,
int
argc
);
static
void
replicationFeedSlaves
(
list
*
slaves
,
int
dictid
,
robj
**
argv
,
int
argc
);
static
void
replicationFeedMonitors
(
list
*
monitors
,
int
dictid
,
robj
**
argv
,
int
argc
);
static
void
feedAppendOnlyFile
(
struct
redisCommand
*
cmd
,
int
dictid
,
robj
**
argv
,
int
argc
);
static
void
feedAppendOnlyFile
(
struct
redisCommand
*
cmd
,
int
dictid
,
robj
**
argv
,
int
argc
);
static
int
syncWithMaster
(
void
);
static
int
syncWithMaster
(
void
);
static
robj
*
tryObjectEncoding
(
robj
*
o
);
static
robj
*
tryObjectEncoding
(
robj
*
o
);
...
@@ -2212,7 +2213,7 @@ static void call(redisClient *c, struct redisCommand *cmd) {
...
@@ -2212,7 +2213,7 @@ static void call(redisClient *c, struct redisCommand *cmd) {
listLength
(
server
.
slaves
))
listLength
(
server
.
slaves
))
replicationFeedSlaves
(
server
.
slaves
,
c
->
db
->
id
,
c
->
argv
,
c
->
argc
);
replicationFeedSlaves
(
server
.
slaves
,
c
->
db
->
id
,
c
->
argv
,
c
->
argc
);
if
(
listLength
(
server
.
monitors
))
if
(
listLength
(
server
.
monitors
))
replicationFeed
Slave
s
(
server
.
monitors
,
c
->
db
->
id
,
c
->
argv
,
c
->
argc
);
replicationFeed
Monitor
s
(
server
.
monitors
,
c
->
db
->
id
,
c
->
argv
,
c
->
argc
);
server
.
stat_numcommands
++
;
server
.
stat_numcommands
++
;
}
}
...
@@ -2467,6 +2468,64 @@ static void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int arg
...
@@ -2467,6 +2468,64 @@ static void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int arg
if
(
outv
!=
static_outv
)
zfree
(
outv
);
if
(
outv
!=
static_outv
)
zfree
(
outv
);
}
}
static
sds
sdscatrepr
(
sds
s
,
char
*
p
,
size_t
len
)
{
s
=
sdscatlen
(
s
,
"
\"
"
,
1
);
while
(
len
--
)
{
switch
(
*
p
)
{
case
'\\'
:
case
'"'
:
s
=
sdscatprintf
(
s
,
"
\\
%c"
,
*
p
);
break
;
case
'\n'
:
s
=
sdscatlen
(
s
,
"
\\
n"
,
1
);
break
;
case
'\r'
:
s
=
sdscatlen
(
s
,
"
\\
r"
,
1
);
break
;
case
'\t'
:
s
=
sdscatlen
(
s
,
"
\\
t"
,
1
);
break
;
case
'\a'
:
s
=
sdscatlen
(
s
,
"
\\
a"
,
1
);
break
;
case
'\b'
:
s
=
sdscatlen
(
s
,
"
\\
b"
,
1
);
break
;
default:
if
(
isprint
(
*
p
))
s
=
sdscatprintf
(
s
,
"%c"
,
*
p
);
else
s
=
sdscatprintf
(
s
,
"
\\
x%02x"
,(
unsigned
char
)
*
p
);
break
;
}
p
++
;
}
return
sdscatlen
(
s
,
"
\"
"
,
1
);
}
static
void
replicationFeedMonitors
(
list
*
monitors
,
int
dictid
,
robj
**
argv
,
int
argc
)
{
listNode
*
ln
;
listIter
li
;
int
j
;
sds
cmdrepr
=
sdsnew
(
"+"
);
robj
*
cmdobj
;
struct
timeval
tv
;
gettimeofday
(
&
tv
,
NULL
);
cmdrepr
=
sdscatprintf
(
cmdrepr
,
"%ld.%ld "
,(
long
)
tv
.
tv_sec
,(
long
)
tv
.
tv_usec
);
if
(
dictid
!=
0
)
cmdrepr
=
sdscatprintf
(
cmdrepr
,
"(db %d) "
,
dictid
);
for
(
j
=
0
;
j
<
argc
;
j
++
)
{
if
(
argv
[
j
]
->
encoding
==
REDIS_ENCODING_INT
)
{
cmdrepr
=
sdscatprintf
(
cmdrepr
,
"%ld"
,
(
long
)
argv
[
j
]
->
ptr
);
}
else
{
cmdrepr
=
sdscatrepr
(
cmdrepr
,(
char
*
)
argv
[
j
]
->
ptr
,
sdslen
(
argv
[
j
]
->
ptr
));
}
if
(
j
!=
argc
-
1
)
cmdrepr
=
sdscatlen
(
cmdrepr
,
" "
,
1
);
}
cmdrepr
=
sdscatlen
(
cmdrepr
,
"
\r\n
"
,
2
);
cmdobj
=
createObject
(
REDIS_STRING
,
cmdrepr
);
listRewind
(
monitors
,
&
li
);
while
((
ln
=
listNext
(
&
li
)))
{
redisClient
*
monitor
=
ln
->
value
;
addReply
(
monitor
,
cmdobj
);
}
decrRefCount
(
cmdobj
);
}
static
void
processInputBuffer
(
redisClient
*
c
)
{
static
void
processInputBuffer
(
redisClient
*
c
)
{
again:
again:
/* Before to process the input buffer, make sure the client is not
/* Before to process the input buffer, make sure the client is not
...
...
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