Merge branch 'newsentinel' into unstable

This commit is contained in:
antirez 2013-11-21 15:01:25 +01:00
commit 1ca56ea796
4 changed files with 788 additions and 567 deletions

View File

@ -1154,6 +1154,8 @@ void configGetCommand(redisClient *c) {
* *
*/ */
#define REDIS_CONFIG_REWRITE_SIGNATURE "# Generated by CONFIG REWRITE"
/* We use the following dictionary type to store where a configuration /* We use the following dictionary type to store where a configuration
* option is mentioned in the old configuration file, so it's * option is mentioned in the old configuration file, so it's
* like "maxmemory" -> list of line numbers (first line is zero). */ * like "maxmemory" -> list of line numbers (first line is zero). */
@ -1162,6 +1164,10 @@ int dictSdsKeyCompare(void *privdata, const void *key1, const void *key2);
void dictSdsDestructor(void *privdata, void *val); void dictSdsDestructor(void *privdata, void *val);
void dictListDestructor(void *privdata, void *val); void dictListDestructor(void *privdata, void *val);
/* Sentinel config rewriting is implemented inside sentinel.c by
* rewriteConfigSentinelOption(). */
void rewriteConfigSentinelOption(struct rewriteConfigState *state);
dictType optionToLineDictType = { dictType optionToLineDictType = {
dictSdsHash, /* hash function */ dictSdsHash, /* hash function */
NULL, /* key dup */ NULL, /* key dup */
@ -1226,6 +1232,8 @@ struct rewriteConfigState *rewriteConfigReadOldFile(char *path) {
/* Handle comments and empty lines. */ /* Handle comments and empty lines. */
if (line[0] == '#' || line[0] == '\0') { if (line[0] == '#' || line[0] == '\0') {
if (!state->has_tail && !strcmp(line,REDIS_CONFIG_REWRITE_SIGNATURE))
state->has_tail = 1;
rewriteConfigAppendLine(state,line); rewriteConfigAppendLine(state,line);
continue; continue;
} }
@ -1297,7 +1305,7 @@ void rewriteConfigRewriteLine(struct rewriteConfigState *state, char *option, sd
/* Append a new line. */ /* Append a new line. */
if (!state->has_tail) { if (!state->has_tail) {
rewriteConfigAppendLine(state, rewriteConfigAppendLine(state,
sdsnew("# Generated by CONFIG REWRITE")); sdsnew(REDIS_CONFIG_REWRITE_SIGNATURE));
state->has_tail = 1; state->has_tail = 1;
} }
rewriteConfigAppendLine(state,line); rewriteConfigAppendLine(state,line);
@ -1735,6 +1743,7 @@ int rewriteConfig(char *path) {
rewriteConfigClientoutputbufferlimitOption(state); rewriteConfigClientoutputbufferlimitOption(state);
rewriteConfigNumericalOption(state,"hz",server.hz,REDIS_DEFAULT_HZ); rewriteConfigNumericalOption(state,"hz",server.hz,REDIS_DEFAULT_HZ);
rewriteConfigYesNoOption(state,"aof-rewrite-incremental-fsync",server.aof_rewrite_incremental_fsync,REDIS_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC); rewriteConfigYesNoOption(state,"aof-rewrite-incremental-fsync",server.aof_rewrite_incremental_fsync,REDIS_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC);
if (server.sentinel_mode) rewriteConfigSentinelOption(state);
/* Step 3: remove all the orphaned lines in the old file, that is, lines /* Step 3: remove all the orphaned lines in the old file, that is, lines
* that were used by a config option and are no longer used, like in case * that were used by a config option and are no longer used, like in case

View File

@ -3108,6 +3108,8 @@ int main(int argc, char **argv) {
redisLog(REDIS_NOTICE,"The server is now ready to accept connections on port %d", server.port); redisLog(REDIS_NOTICE,"The server is now ready to accept connections on port %d", server.port);
if (server.sofd > 0) if (server.sofd > 0)
redisLog(REDIS_NOTICE,"The server is now ready to accept connections at %s", server.unixsocket); redisLog(REDIS_NOTICE,"The server is now ready to accept connections at %s", server.unixsocket);
} else {
sentinelIsRunning();
} }
/* Warning the user about suspicious maxmemory setting. */ /* Warning the user about suspicious maxmemory setting. */

View File

@ -1169,6 +1169,9 @@ sds keyspaceEventsFlagsToString(int flags);
void loadServerConfig(char *filename, char *options); void loadServerConfig(char *filename, char *options);
void appendServerSaveParams(time_t seconds, int changes); void appendServerSaveParams(time_t seconds, int changes);
void resetServerSaveParams(); void resetServerSaveParams();
struct rewriteConfigState; /* Forward declaration to export API. */
void rewriteConfigRewriteLine(struct rewriteConfigState *state, char *option, sds line, int force);
int rewriteConfig(char *path);
/* db.c -- Keyspace access API */ /* db.c -- Keyspace access API */
int removeExpire(redisDb *db, robj *key); int removeExpire(redisDb *db, robj *key);
@ -1220,6 +1223,7 @@ void initSentinelConfig(void);
void initSentinel(void); void initSentinel(void);
void sentinelTimer(void); void sentinelTimer(void);
char *sentinelHandleConfiguration(char **argv, int argc); char *sentinelHandleConfiguration(char **argv, int argc);
void sentinelIsRunning(void);
/* Scripting */ /* Scripting */
void scriptingInit(void); void scriptingInit(void);

File diff suppressed because it is too large Load Diff