Commit 7673d88d authored by antirez's avatar antirez
Browse files

Slave removal: replace very few things in Sentinel.

SENTINEL REPLICAS was added as an alias, in the configuration rewriting
now it uses known-replica, however all the rest is basically at API
level of logged events and messages having to do with the protocol, so
there is very little to do here compared to the Redis core itself, to
preserve compatibility.
parent f1de29b3
...@@ -1687,16 +1687,18 @@ char *sentinelHandleConfiguration(char **argv, int argc) { ...@@ -1687,16 +1687,18 @@ char *sentinelHandleConfiguration(char **argv, int argc) {
ri = sentinelGetMasterByName(argv[1]); ri = sentinelGetMasterByName(argv[1]);
if (!ri) return "No such master with specified name."; if (!ri) return "No such master with specified name.";
ri->leader_epoch = strtoull(argv[2],NULL,10); ri->leader_epoch = strtoull(argv[2],NULL,10);
} else if (!strcasecmp(argv[0],"known-slave") && argc == 4) { } else if ((!strcasecmp(argv[0],"known-slave") ||
!strcasecmp(argv[0],"known-replica")) && argc == 4)
{
sentinelRedisInstance *slave; sentinelRedisInstance *slave;
/* known-slave <name> <ip> <port> */ /* known-replica <name> <ip> <port> */
ri = sentinelGetMasterByName(argv[1]); ri = sentinelGetMasterByName(argv[1]);
if (!ri) return "No such master with specified name."; if (!ri) return "No such master with specified name.";
if ((slave = createSentinelRedisInstance(NULL,SRI_SLAVE,argv[2], if ((slave = createSentinelRedisInstance(NULL,SRI_SLAVE,argv[2],
atoi(argv[3]), ri->quorum, ri)) == NULL) atoi(argv[3]), ri->quorum, ri)) == NULL)
{ {
return "Wrong hostname or port for slave."; return "Wrong hostname or port for replica.";
} }
} else if (!strcasecmp(argv[0],"known-sentinel") && } else if (!strcasecmp(argv[0],"known-sentinel") &&
(argc == 4 || argc == 5)) { (argc == 4 || argc == 5)) {
...@@ -1854,7 +1856,7 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) { ...@@ -1854,7 +1856,7 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) {
if (sentinelAddrIsEqual(slave_addr,master_addr)) if (sentinelAddrIsEqual(slave_addr,master_addr))
slave_addr = master->addr; slave_addr = master->addr;
line = sdscatprintf(sdsempty(), line = sdscatprintf(sdsempty(),
"sentinel known-slave %s %s %d", "sentinel known-replica %s %s %d",
master->name, slave_addr->ip, slave_addr->port); master->name, slave_addr->ip, slave_addr->port);
rewriteConfigRewriteLine(state,"sentinel",line,1); rewriteConfigRewriteLine(state,"sentinel",line,1);
} }
...@@ -2978,8 +2980,10 @@ void sentinelCommand(client *c) { ...@@ -2978,8 +2980,10 @@ void sentinelCommand(client *c) {
if ((ri = sentinelGetMasterByNameOrReplyError(c,c->argv[2])) if ((ri = sentinelGetMasterByNameOrReplyError(c,c->argv[2]))
== NULL) return; == NULL) return;
addReplySentinelRedisInstance(c,ri); addReplySentinelRedisInstance(c,ri);
} else if (!strcasecmp(c->argv[1]->ptr,"slaves")) { } else if (!strcasecmp(c->argv[1]->ptr,"slaves") ||
/* SENTINEL SLAVES <master-name> */ !strcasecmp(c->argv[1]->ptr,"replicas"))
{
/* SENTINEL REPLICAS <master-name> */
sentinelRedisInstance *ri; sentinelRedisInstance *ri;
if (c->argc != 3) goto numargserr; if (c->argc != 3) goto numargserr;
...@@ -3079,7 +3083,7 @@ void sentinelCommand(client *c) { ...@@ -3079,7 +3083,7 @@ void sentinelCommand(client *c) {
return; return;
} }
if (sentinelSelectSlave(ri) == NULL) { if (sentinelSelectSlave(ri) == NULL) {
addReplySds(c,sdsnew("-NOGOODSLAVE No suitable slave to promote\r\n")); addReplySds(c,sdsnew("-NOGOODSLAVE No suitable replica to promote\r\n"));
return; return;
} }
serverLog(LL_WARNING,"Executing user requested FAILOVER of '%s'", serverLog(LL_WARNING,"Executing user requested FAILOVER of '%s'",
...@@ -3261,7 +3265,7 @@ void sentinelCommand(client *c) { ...@@ -3261,7 +3265,7 @@ void sentinelCommand(client *c) {
sentinel.simfailure_flags |= sentinel.simfailure_flags |=
SENTINEL_SIMFAILURE_CRASH_AFTER_PROMOTION; SENTINEL_SIMFAILURE_CRASH_AFTER_PROMOTION;
serverLog(LL_WARNING,"Failure simulation: this Sentinel " serverLog(LL_WARNING,"Failure simulation: this Sentinel "
"will crash after promoting the selected slave to master"); "will crash after promoting the selected replica to master");
} else if (!strcasecmp(c->argv[j]->ptr,"help")) { } else if (!strcasecmp(c->argv[j]->ptr,"help")) {
addReplyMultiBulkLen(c,2); addReplyMultiBulkLen(c,2);
addReplyBulkCString(c,"crash-after-election"); addReplyBulkCString(c,"crash-after-election");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment