Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentinel get command #41

Open
wants to merge 75 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
c25c1f0
Add sentinel GET command
hwware Nov 10, 2021
a2b61d0
Update sentinel.c
hwware Nov 10, 2021
2d069a3
Update sentinel.c
hwware Nov 10, 2021
79f000e
Update sentinel.c
hwware Nov 10, 2021
fe66d23
Update sentinel.c
hwware Nov 11, 2021
0e8eb33
Update sentinel.c
hwware Nov 11, 2021
800e46a
Debuging
hwware Nov 11, 2021
6ff0e39
Add command in server.c
hwware Nov 11, 2021
76b0701
Update sentinel.c
hwware Nov 11, 2021
681eae7
Update sentinel.c
hwware Nov 11, 2021
7ec92ba
Update sentinel.c
hwware Nov 11, 2021
8c36a10
Update sentinel.c
hwware Nov 11, 2021
2f7111d
Update sentinel.c
hwware Nov 11, 2021
12dbc95
Update sentinel.c
hwware Nov 11, 2021
d291f8d
Update sentinel.c
hwware Nov 11, 2021
3c4b13d
Update sentinel.c
hwware Nov 11, 2021
e53f3ba
Update sentinel.c
hwware Nov 11, 2021
0333244
Update sentinel.c
hwware Nov 11, 2021
18e7eed
add new line
hwware Nov 11, 2021
da38638
Update sentinel.c
hwware Nov 11, 2021
479fc1c
Update sentinel.c
hwware Nov 11, 2021
b7dc3ad
Update sentinel.c
hwware Nov 11, 2021
fdb6680
Update sentinel.c
hwware Nov 11, 2021
ff3a223
Update sentinel.c
hwware Nov 11, 2021
b85a09d
Update sentinel.c
hwware Nov 11, 2021
0864e09
Update sentinel.c
hwware Nov 11, 2021
b6408d8
Update sentinel.c
hwware Nov 11, 2021
0d05ffc
Update sentinel.c
hwware Nov 11, 2021
22744e6
Update sentinel.c
hwware Nov 11, 2021
974b239
Update sentinel.c
hwware Nov 11, 2021
43a6a92
Update sentinel.c
hwware Nov 11, 2021
e3081e3
Update sentinel.c
hwware Nov 11, 2021
b629f43
Update sentinel.c
hwware Nov 11, 2021
8d13990
Update sentinel.c
hwware Nov 11, 2021
3b77bbe
Update sentinel.c
hwware Nov 11, 2021
6440d32
Update sentinel.c
hwware Nov 11, 2021
4005f6e
Update sentinel.c
hwware Nov 11, 2021
d3438ce
Update sentinel.c
hwware Nov 11, 2021
7cfaa68
Update sentinel.c
hwware Nov 11, 2021
693bf83
Update sentinel.c
hwware Nov 11, 2021
6bf4817
Revert "Update sentinel.c"
hwware Nov 11, 2021
d563944
Update sentinel.c
hwware Nov 12, 2021
973a0d1
Update sentinel.c
hwware Nov 12, 2021
12dceec
Update sentinel.c
hwware Nov 12, 2021
4418ad7
Update sentinel.c
hwware Nov 12, 2021
d4c9e77
Update sentinel.c
hwware Nov 12, 2021
d86c138
Update sentinel.c
hwware Nov 12, 2021
80e9aac
Update sentinel.c
hwware Nov 12, 2021
5e47cd0
Update sentinel.c
hwware Nov 12, 2021
ad3a001
Update sentinel.c
hwware Nov 12, 2021
8d27e00
Update sentinel.c
hwware Nov 12, 2021
4ad9a87
Update sentinel.c
hwware Nov 12, 2021
e857d01
Update sentinel.c
hwware Nov 12, 2021
4332ffb
Update sentinel.c
hwware Nov 12, 2021
dac91e0
Update sentinel.c
hwware Nov 12, 2021
15bec76
Update sentinel.c
hwware Nov 12, 2021
ec7ec6e
Update sentinel.c
hwware Nov 12, 2021
5d1fbae
Update sentinel.c
hwware Nov 12, 2021
acd1e3d
Update sentinel.c
hwware Nov 12, 2021
901745b
Update sentinel.c
hwware Nov 12, 2021
e1722c2
Update sentinel.c
hwware Nov 12, 2021
726676a
Update sentinel.c
hwware Nov 12, 2021
bdbd3ed
Update sentinel.c
hwware Nov 12, 2021
5ac2bbb
Update sentinel.c
hwware Nov 12, 2021
a161d21
Update sentinel.c
hwware Nov 12, 2021
615f96a
Update sentinel.c
hwware Nov 12, 2021
f68bd80
Update sentinel.c
hwware Nov 12, 2021
4fba736
Update sentinel.c
hwware Nov 12, 2021
afc4b41
Update sentinel.c
hwware Nov 12, 2021
d39427f
Update sentinel.c
hwware Nov 12, 2021
3603441
Update sentinel.c
hwware Nov 12, 2021
7900823
Update sentinel.c
hwware Nov 12, 2021
1fb7b5a
Update sentinel.c
hwware Nov 15, 2021
b28a8cf
Update sentinel.c
hwware Nov 15, 2021
6f02ea7
update some format and comments
hwware Nov 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions src/sentinel.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ dictType renamedCommandsDictType = {
/* =========================== Initialization =============================== */

void sentinelSetCommand(client *c);
void sentinelGetCommand(client *c);
void sentinelConfigGetCommand(client *c);
void sentinelConfigSetCommand(client *c);

Expand Down Expand Up @@ -3942,6 +3943,8 @@ NULL
} else if (!strcasecmp(c->argv[1]->ptr,"set")) {
if (c->argc <= 3) goto numargserr;
sentinelSetCommand(c);
} else if (!strcasecmp(c->argv[1]->ptr,"get")) {
sentinelGetCommand(c);
} else if (!strcasecmp(c->argv[1]->ptr,"config")) {
if (c->argc < 3) goto numargserr;
if (!strcasecmp(c->argv[2]->ptr,"set") && c->argc == 5)
Expand Down Expand Up @@ -4153,6 +4156,85 @@ void sentinelRoleCommand(client *c) {
dictReleaseIterator(di);
}

/* SENTINEL GET <mastername> <option> */
void sentinelGetCommand(client *c) {
sentinelRedisInstance *ri;
int has_all_masters = 0;
dictIterator *di;
dictEntry *de;
int matches = 0;
char *option = "";
int has_get_all = 0;

if (c->argc == 3) {
has_get_all = 1;
}
else{
option = c->argv[3]->ptr;
}

if (!strcasecmp(c->argv[2]->ptr,"all")) {
has_all_masters = 1;
}
else {
if ((ri = sentinelGetMasterByNameOrReplyError(c,c->argv[2])) == NULL)
return;
}

di = dictGetIterator(sentinel.masters);
void *replylen = addReplyDeferredLen(c);
while((de = dictNext(di)) != NULL) {
ri = dictGetVal(de);
if (!has_all_masters) {
if (ri != sentinelGetMasterByNameOrReplyError(c,c->argv[2]))
continue;
}

addReplyBulkCString(c,"# SENTINEL MASTER NAME");
addReplyBulkCString(c,ri->name);
matches++;

if (!strcasecmp(option,"down-after-milliseconds") || has_get_all) {
/* down-after-milliseconds <milliseconds> */
addReplyBulkCString(c,"sentinel down-after-milliseconds");
addReplyBulkLongLong(c,ri->down_after_period);
matches++;
}
if (!strcasecmp(option,"failover-timeout") || has_get_all) {
/* failover-timeout <milliseconds> */
addReplyBulkCString(c,"sentinel failover-timeout");
addReplyBulkLongLong(c,ri->failover_timeout);
matches++;
}
if (!strcasecmp(option,"parallel-syncs") || has_get_all) {
/* parallel-syncs <milliseconds> */
addReplyBulkCString(c,"sentinel parallel-syncs");
addReplyBulkCString(c,ri->parallel_syncs ? "yes" : "no");
matches++;
}
if (!strcasecmp(option,"quorum") || has_get_all) {
/* quorum <count> */
addReplyBulkCString(c, "sentinel quorum");
addReplyBulkLongLong(c, ri->quorum);
matches++;
}
if (!strcasecmp(option,"runid") || has_get_all) {
/* runid */
addReplyBulkCString(c, "sentinel runid");
addReplyBulkCString(c, ri->runid ? ri->runid : "");
matches++;
}
if (!strcasecmp(option,"config-epoch") || has_get_all) {
/* config-epoch <count> */
addReplyBulkCString(c, "sentinel config-epoch");
addReplyBulkLongLong(c, ri->config_epoch);
matches++;
}
}
dictReleaseIterator(di);
setDeferredMapLen(c, replylen, matches);
}

/* SENTINEL SET <mastername> [<option> <value> ...] */
void sentinelSetCommand(client *c) {
sentinelRedisInstance *ri;
Expand Down
3 changes: 3 additions & 0 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,9 @@ struct redisCommand sentinelSubcommands[] = {
{"set",sentinelCommand,-3,
"admin only-sentinel"},

{"get",sentinelCommand,-3,
"admin only-sentinel"},

{"simulate-failure",sentinelCommand,3,
"admin only-sentinel"},

Expand Down