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
a6ebd910
Commit
a6ebd910
authored
Nov 20, 2013
by
antirez
Browse files
Sentinel: take the replication offset in slaves state.
parent
b1f5a0b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
a6ebd910
...
@@ -165,10 +165,11 @@ typedef struct sentinelRedisInstance {
...
@@ -165,10 +165,11 @@ typedef struct sentinelRedisInstance {
mstime_t
master_link_down_time
;
/* Slave replication link down time. */
mstime_t
master_link_down_time
;
/* Slave replication link down time. */
int
slave_priority
;
/* Slave priority according to its INFO output. */
int
slave_priority
;
/* Slave priority according to its INFO output. */
mstime_t
slave_reconf_sent_time
;
/* Time at which we sent SLAVE OF <new> */
mstime_t
slave_reconf_sent_time
;
/* Time at which we sent SLAVE OF <new> */
struct
sentinelRedisInstance
*
master
;
/* Master instance if
SRI_SLAVE is set
. */
struct
sentinelRedisInstance
*
master
;
/* Master instance if
it's slave
. */
char
*
slave_master_host
;
/* Master host as reported by INFO */
char
*
slave_master_host
;
/* Master host as reported by INFO */
int
slave_master_port
;
/* Master port as reported by INFO */
int
slave_master_port
;
/* Master port as reported by INFO */
int
slave_master_link_status
;
/* Master link status as reported by INFO */
int
slave_master_link_status
;
/* Master link status as reported by INFO */
unsigned
long
long
slave_repl_offset
;
/* Slave replication offset. */
/* Failover */
/* Failover */
char
*
leader
;
/* If this is a master instance, this is the runid of
char
*
leader
;
/* If this is a master instance, this is the runid of
the Sentinel that should perform the failover. If
the Sentinel that should perform the failover. If
...
@@ -900,6 +901,7 @@ sentinelRedisInstance *createSentinelRedisInstance(char *name, int flags, char *
...
@@ -900,6 +901,7 @@ sentinelRedisInstance *createSentinelRedisInstance(char *name, int flags, char *
ri
->
slave_master_host
=
NULL
;
ri
->
slave_master_host
=
NULL
;
ri
->
slave_master_port
=
0
;
ri
->
slave_master_port
=
0
;
ri
->
slave_master_link_status
=
SENTINEL_MASTER_LINK_STATUS_DOWN
;
ri
->
slave_master_link_status
=
SENTINEL_MASTER_LINK_STATUS_DOWN
;
ri
->
slave_repl_offset
=
0
;
ri
->
sentinels
=
dictCreate
(
&
instancesDictType
,
NULL
);
ri
->
sentinels
=
dictCreate
(
&
instancesDictType
,
NULL
);
ri
->
quorum
=
quorum
;
ri
->
quorum
=
quorum
;
ri
->
parallel_syncs
=
SENTINEL_DEFAULT_PARALLEL_SYNCS
;
ri
->
parallel_syncs
=
SENTINEL_DEFAULT_PARALLEL_SYNCS
;
...
@@ -1738,6 +1740,10 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
...
@@ -1738,6 +1740,10 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
/* slave_priority:<priority> */
/* slave_priority:<priority> */
if
(
sdslen
(
l
)
>=
15
&&
!
memcmp
(
l
,
"slave_priority:"
,
15
))
if
(
sdslen
(
l
)
>=
15
&&
!
memcmp
(
l
,
"slave_priority:"
,
15
))
ri
->
slave_priority
=
atoi
(
l
+
15
);
ri
->
slave_priority
=
atoi
(
l
+
15
);
/* slave_repl_offset:<offset> */
if
(
sdslen
(
l
)
>=
18
&&
!
memcmp
(
l
,
"slave_repl_offset:"
,
18
))
ri
->
slave_repl_offset
=
strtoull
(
l
+
18
,
NULL
,
10
);
}
}
}
}
ri
->
info_refresh
=
mstime
();
ri
->
info_refresh
=
mstime
();
...
@@ -2262,6 +2268,10 @@ void addReplySentinelRedisInstance(redisClient *c, sentinelRedisInstance *ri) {
...
@@ -2262,6 +2268,10 @@ void addReplySentinelRedisInstance(redisClient *c, sentinelRedisInstance *ri) {
addReplyBulkCString
(
c
,
"slave-priority"
);
addReplyBulkCString
(
c
,
"slave-priority"
);
addReplyBulkLongLong
(
c
,
ri
->
slave_priority
);
addReplyBulkLongLong
(
c
,
ri
->
slave_priority
);
fields
++
;
fields
++
;
addReplyBulkCString
(
c
,
"slave-repl-offset"
);
addReplyBulkLongLong
(
c
,
ri
->
slave_repl_offset
);
fields
++
;
}
}
/* Only sentinels */
/* Only sentinels */
...
...
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