MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / initSentinel

Function initSentinel

src/sentinel.cpp:511–552  ·  view source on GitHub ↗

Perform the Sentinel mode initialization. */

Source from the content-addressed store, hash-verified

509
510/* Perform the Sentinel mode initialization. */
511void initSentinel(void) {
512 unsigned int j;
513
514 /* Remove usual Redis commands from the command table, then just add
515 * the SENTINEL command. */
516 dictEmpty(g_pserver->commands,NULL);
517 dictEmpty(g_pserver->orig_commands,NULL);
518 ACLClearCommandID();
519 for (j = 0; j < sizeof(sentinelcmds)/sizeof(sentinelcmds[0]); j++) {
520 int retval;
521 struct redisCommand *cmd = sentinelcmds+j;
522 cmd->id = ACLGetCommandID(cmd->name); /* Assign the ID used for ACL. */
523 retval = dictAdd(g_pserver->commands, sdsnew(cmd->name), cmd);
524 serverAssert(retval == DICT_OK);
525 retval = dictAdd(g_pserver->orig_commands, sdsnew(cmd->name), cmd);
526 serverAssert(retval == DICT_OK);
527
528 /* Translate the command string flags description into an actual
529 * set of flags. */
530 if (populateCommandTableParseFlags(cmd,cmd->sflags) == C_ERR)
531 serverPanic("Unsupported command flag");
532 }
533
534 /* Initialize various data structures. */
535 sentinel.current_epoch = 0;
536 sentinel.masters = dictCreate(&instancesDictType,NULL);
537 sentinel.tilt = 0;
538 sentinel.tilt_start_time = 0;
539 sentinel.previous_time = mstime();
540 sentinel.running_scripts = 0;
541 sentinel.scripts_queue = listCreate();
542 sentinel.announce_ip = NULL;
543 sentinel.announce_port = 0;
544 sentinel.simfailure_flags = SENTINEL_SIMFAILURE_NONE;
545 sentinel.deny_scripts_reconfig = SENTINEL_DEFAULT_DENY_SCRIPTS_RECONFIG;
546 sentinel.sentinel_auth_pass = NULL;
547 sentinel.sentinel_auth_user = NULL;
548 sentinel.resolve_hostnames = SENTINEL_DEFAULT_RESOLVE_HOSTNAMES;
549 sentinel.announce_hostnames = SENTINEL_DEFAULT_ANNOUNCE_HOSTNAMES;
550 memset(sentinel.myid,0,sizeof(sentinel.myid));
551 g_pserver->sentinel_config = NULL;
552}
553
554/* This function is for checking whether sentinel config file has been set,
555 * also checking whether we have write permissions. */

Callers 1

mainFunction · 0.85

Calls 9

dictEmptyFunction · 0.85
ACLClearCommandIDFunction · 0.85
ACLGetCommandIDFunction · 0.85
sdsnewFunction · 0.85
listCreateFunction · 0.85
dictAddFunction · 0.70
dictCreateFunction · 0.70
mstimeFunction · 0.70

Tested by

no test coverage detected