mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Sentinel: propagate down-after-ms changes to slaves and sentinels.
This commit is contained in:
parent
bb6d850160
commit
218cc5fc39
@ -1298,6 +1298,24 @@ sentinelAddr *sentinelGetCurrentMasterAddress(sentinelRedisInstance *master) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function sets the down_after_period field value in 'master' to all
|
||||||
|
* the slaves and sentinel instances connected to this master. */
|
||||||
|
void sentinelPropagateDownAfterPeriod(sentinelRedisInstance *master) {
|
||||||
|
dictIterator *di;
|
||||||
|
dictEntry *de;
|
||||||
|
int j;
|
||||||
|
dict *d[] = {master->slaves, master->sentinels, NULL};
|
||||||
|
|
||||||
|
for (j = 0; d[j]; j++) {
|
||||||
|
di = dictGetIterator(d[j]);
|
||||||
|
while((de = dictNext(di)) != NULL) {
|
||||||
|
sentinelRedisInstance *ri = dictGetVal(de);
|
||||||
|
ri->down_after_period = master->down_after_period;
|
||||||
|
}
|
||||||
|
dictReleaseIterator(di);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ============================ Config handling ============================= */
|
/* ============================ Config handling ============================= */
|
||||||
char *sentinelHandleConfiguration(char **argv, int argc) {
|
char *sentinelHandleConfiguration(char **argv, int argc) {
|
||||||
sentinelRedisInstance *ri;
|
sentinelRedisInstance *ri;
|
||||||
@ -1323,6 +1341,7 @@ char *sentinelHandleConfiguration(char **argv, int argc) {
|
|||||||
ri->down_after_period = atoi(argv[2]);
|
ri->down_after_period = atoi(argv[2]);
|
||||||
if (ri->down_after_period <= 0)
|
if (ri->down_after_period <= 0)
|
||||||
return "negative or zero time parameter.";
|
return "negative or zero time parameter.";
|
||||||
|
sentinelPropagateDownAfterPeriod(ri);
|
||||||
} else if (!strcasecmp(argv[0],"failover-timeout") && argc == 3) {
|
} else if (!strcasecmp(argv[0],"failover-timeout") && argc == 3) {
|
||||||
/* failover-timeout <name> <milliseconds> */
|
/* failover-timeout <name> <milliseconds> */
|
||||||
ri = sentinelGetMasterByName(argv[1]);
|
ri = sentinelGetMasterByName(argv[1]);
|
||||||
@ -2762,6 +2781,7 @@ void sentinelSetCommand(redisClient *c) {
|
|||||||
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll <= 0)
|
if (getLongLongFromObject(o,&ll) == REDIS_ERR || ll <= 0)
|
||||||
goto badfmt;
|
goto badfmt;
|
||||||
ri->down_after_period = ll;
|
ri->down_after_period = ll;
|
||||||
|
sentinelPropagateDownAfterPeriod(ri);
|
||||||
changes++;
|
changes++;
|
||||||
} else if (!strcasecmp(option,"failover-timeout")) {
|
} else if (!strcasecmp(option,"failover-timeout")) {
|
||||||
/* failover-timeout <milliseconds> */
|
/* failover-timeout <milliseconds> */
|
||||||
|
Loading…
Reference in New Issue
Block a user