MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sentinelSetCommand

Function sentinelSetCommand

app/redis-6.2.6/src/sentinel.c:3989–4148  ·  view source on GitHub ↗

SENTINEL SET [ ...] */

Source from the content-addressed store, hash-verified

3987
3988/* SENTINEL SET <mastername> [<option> <value> ...] */
3989void sentinelSetCommand(client *c) {
3990 sentinelRedisInstance *ri;
3991 int j, changes = 0;
3992 int badarg = 0; /* Bad argument position for error reporting. */
3993 char *option;
3994
3995 if ((ri = sentinelGetMasterByNameOrReplyError(c,c->argv[2]))
3996 == NULL) return;
3997
3998 /* Process option - value pairs. */
3999 for (j = 3; j < c->argc; j++) {
4000 int moreargs = (c->argc-1) - j;
4001 option = c->argv[j]->ptr;
4002 long long ll;
4003 int old_j = j; /* Used to know what to log as an event. */
4004
4005 if (!strcasecmp(option,"down-after-milliseconds") && moreargs > 0) {
4006 /* down-after-millisecodns <milliseconds> */
4007 robj *o = c->argv[++j];
4008 if (getLongLongFromObject(o,&ll) == C_ERR || ll <= 0) {
4009 badarg = j;
4010 goto badfmt;
4011 }
4012 ri->down_after_period = ll;
4013 sentinelPropagateDownAfterPeriod(ri);
4014 changes++;
4015 } else if (!strcasecmp(option,"failover-timeout") && moreargs > 0) {
4016 /* failover-timeout <milliseconds> */
4017 robj *o = c->argv[++j];
4018 if (getLongLongFromObject(o,&ll) == C_ERR || ll <= 0) {
4019 badarg = j;
4020 goto badfmt;
4021 }
4022 ri->failover_timeout = ll;
4023 changes++;
4024 } else if (!strcasecmp(option,"parallel-syncs") && moreargs > 0) {
4025 /* parallel-syncs <milliseconds> */
4026 robj *o = c->argv[++j];
4027 if (getLongLongFromObject(o,&ll) == C_ERR || ll <= 0) {
4028 badarg = j;
4029 goto badfmt;
4030 }
4031 ri->parallel_syncs = ll;
4032 changes++;
4033 } else if (!strcasecmp(option,"notification-script") && moreargs > 0) {
4034 /* notification-script <path> */
4035 char *value = c->argv[++j]->ptr;
4036 if (sentinel.deny_scripts_reconfig) {
4037 addReplyError(c,
4038 "Reconfiguration of scripts path is denied for "
4039 "security reasons. Check the deny-scripts-reconfig "
4040 "configuration directive in your Sentinel configuration");
4041 goto seterr;
4042 }
4043
4044 if (strlen(value) && access(value,X_OK) == -1) {
4045 addReplyError(c,
4046 "Notification script seems non existing or non executable");

Callers 1

sentinelCommandFunction · 0.85

Calls 15

strcasecmpFunction · 0.85
getLongLongFromObjectFunction · 0.85
addReplyErrorFunction · 0.85
sdsfreeFunction · 0.85
sdsnewFunction · 0.85
sdslenFunction · 0.85
dictSdsKeyCaseCompareFunction · 0.85
sdsdupFunction · 0.85
addReplyErrorFormatFunction · 0.85
sentinelEventFunction · 0.85

Tested by

no test coverage detected