diff options
author | antirez <antirez@gmail.com> | 2013-11-18 16:02:58 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-11-21 15:21:55 +0100 |
commit | 0b9853ecdc6898bab2fae0764e8aa90e0ca49e83 (patch) | |
tree | c9e3226f8888d5bc841884d16fd843c1a50fc2bb | |
parent | 737062745de934549823c945df97a4dfef034f0d (diff) | |
download | redis-0b9853ecdc6898bab2fae0764e8aa90e0ca49e83.tar.gz |
Sentinel: added config options useful to take state on config rewrite.
We'll use CONFIG REWRITE (internally) in order to store the new
configuration of a Sentinel after the internal state changes. In order
to do so, we need configuration options (that usually the user will not
touch at all) about config epoch of the master, Sentinels and Slaves
known for this master, and so forth.
-rw-r--r-- | src/sentinel.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/sentinel.c b/src/sentinel.c index 4198afb95..366f7bcae 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -1314,6 +1314,35 @@ char *sentinelHandleConfiguration(char **argv, int argc) { ri = sentinelGetMasterByName(argv[1]); if (!ri) return "No such master with specified name."; ri->auth_pass = sdsnew(argv[2]); + } else if (!strcasecmp(argv[0],"config-epoch") && argc == 3) { + /* config-epoch <name> <epoch> */ + ri = sentinelGetMasterByName(argv[1]); + if (!ri) return "No such master with specified name."; + ri->config_epoch = strtoull(argv[2],NULL,10); + if (ri->config_epoch > sentinel.current_epoch) + sentinel.current_epoch = ri->config_epoch; + } else if (!strcasecmp(argv[0],"slave") && argc == 3) { + sentinelRedisInstance *slave; + + /* slave <name> <ip> <port> */ + ri = sentinelGetMasterByName(argv[1]); + if (!ri) return "No such master with specified name."; + if ((slave = createSentinelRedisInstance(NULL,SRI_SLAVE,argv[2], + atoi(argv[3]), ri->quorum, ri)) == NULL) + { + return "Wrong hostname or port for slave."; + } + } else if (!strcasecmp(argv[0],"sentinel") && argc == 3) { + sentinelRedisInstance *si; + + /* sentinel <name> <ip> <port> */ + ri = sentinelGetMasterByName(argv[1]); + if (!ri) return "No such master with specified name."; + if ((si = createSentinelRedisInstance(NULL,SRI_SENTINEL,argv[2], + atoi(argv[3]), ri->quorum, ri)) == NULL) + { + return "Wrong hostname or port for sentinel."; + } } else { return "Unrecognized sentinel configuration statement."; } |