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
6b373edb
Commit
6b373edb
authored
Feb 24, 2014
by
antirez
Browse files
Sentinel: generate +monitor events at startup.
parent
3b7a7574
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
6b373edb
...
@@ -327,6 +327,7 @@ void sentinelDiscardReplyCallback(redisAsyncContext *c, void *reply, void *privd
...
@@ -327,6 +327,7 @@ void sentinelDiscardReplyCallback(redisAsyncContext *c, void *reply, void *privd
int sentinelSendSlaveOf(sentinelRedisInstance *ri, char *host, int port);
int sentinelSendSlaveOf(sentinelRedisInstance *ri, char *host, int port);
char *sentinelVoteLeader(sentinelRedisInstance *master, uint64_t req_epoch, char *req_runid, uint64_t *leader_epoch);
char *sentinelVoteLeader(sentinelRedisInstance *master, uint64_t req_epoch, char *req_runid, uint64_t *leader_epoch);
void sentinelFlushConfig(void);
void sentinelFlushConfig(void);
void sentinelGenerateInitialMonitorEvents(void);
/* ========================= Dictionary types =============================== */
/* ========================= Dictionary types =============================== */
...
@@ -427,6 +428,10 @@ void sentinelIsRunning(void) {
...
@@ -427,6 +428,10 @@ void sentinelIsRunning(void) {
server.configfile,strerror(errno));
server.configfile,strerror(errno));
exit(1);
exit(1);
}
}
/* We want to generate a +monitor event for every configured master
* at startup. */
sentinelGenerateInitialMonitorEvents();
}
}
/* ============================== sentinelAddr ============================== */
/* ============================== sentinelAddr ============================== */
...
@@ -558,6 +563,22 @@ void sentinelEvent(int level, char *type, sentinelRedisInstance *ri,
...
@@ -558,6 +563,22 @@ void sentinelEvent(int level, char *type, sentinelRedisInstance *ri,
}
}
}
}
/* This function is called only at startup and is used to generate a
* +monitor event for every configured master. The same events are also
* generated when a master to monitor is added at runtime via the
* SENTINEL MONITOR command. */
void sentinelGenerateInitialMonitorEvents(void) {
dictIterator *di;
dictEntry *de;
di = dictGetIterator(sentinel.masters);
while((de = dictNext(di)) != NULL) {
sentinelRedisInstance *ri = dictGetVal(de);
sentinelEvent(REDIS_WARNING,"+monitor",ri,"%@");
}
dictReleaseIterator(di);
}
/* ============================ script execution ============================ */
/* ============================ script execution ============================ */
/* Release a script job structure and all the associated data. */
/* Release a script job structure and all the associated data. */
...
...
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