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