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
ab4b2ec8
Commit
ab4b2ec8
authored
Nov 12, 2013
by
antirez
Browse files
Sentinel: allow to vote for myself.
parent
b6b65b29
Changes
1
Show whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
ab4b2ec8
...
...
@@ -1043,24 +1043,6 @@ sentinelRedisInstance *sentinelGetMasterByName(char *name) {
return
ri
;
}
/* Senitnel lookup by runid */
sentinelRedisInstance *sentinelGetSentinelByRunid(sentinelRedisInstance *master, char *runid) {
sentinelRedisInstance *retval = NULL;
dictIterator *di;
dictEntry *de;
di = dictGetIterator(master->sentinels);
while((de = dictNext(di)) != NULL) {
sentinelRedisInstance *ri = dictGetVal(de);
if (!strcmp(ri->runid,runid)) {
retval = ri;
break;
}
}
dictReleaseIterator(di);
return retval;
}
/* Add the specified flags to all the instances in the specified dictionary. */
void
sentinelAddFlagsToDictOfRedisInstances
(
dict
*
instances
,
int
flags
)
{
dictIterator
*
di
;
...
...
@@ -2417,17 +2399,15 @@ int compareRunID(const void *a, const void *b) {
* If a vote is not available returns NULL, otherwise return the Sentinel
* runid and populate the leader_epoch with the epoch of the last vote. */
char
*
sentinelVoteLeader
(
sentinelRedisInstance
*
master
,
uint64_t
req_epoch
,
char
*
req_runid
,
uint64_t
*
leader_epoch
)
{
sentinelRedisInstance *si = sentinelGetSentinelByRunid(master,req_runid);
if
(
req_epoch
>
sentinel
.
current_epoch
)
sentinel
.
current_epoch
=
req_epoch
;
if (si && master->leader_epoch < req_epoch &&
sentinel.current_epoch <= req_epoch)
{
if
(
master
->
leader_epoch
<
req_epoch
&&
sentinel
.
current_epoch
<=
req_epoch
)
{
sdsfree
(
master
->
leader
);
master
->
leader
=
sdsnew
(
req_runid
);
master
->
leader_epoch
=
sentinel
.
current_epoch
;
printf
(
"Selected leader %s for epoch %llu
\n
"
,
master
->
leader
,
(
unsigned
long
long
)
master
->
leader_epoch
);
}
*
leader_epoch
=
master
->
leader_epoch
;
...
...
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