From 7ae32875a3e3a9fc19a22b76253f3462b27166b7 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 25 Jun 2018 17:13:20 +0200 Subject: [PATCH] Sentinel command renaming: implement SENTINEL SET. --- src/sentinel.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/sentinel.c b/src/sentinel.c index c367efee3..f69713973 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -3467,6 +3467,25 @@ void sentinelSetCommand(client *c) { goto badfmt; ri->quorum = ll; changes++; + } else if (!strcasecmp(option,"rename-command") && moreargs > 1) { + /* rename-command + * + * Note: if newname is the empty string the command renaming + * entry is deleted. */ + sds oldname = c->argv[++j]->ptr; + sds newname = c->argv[++j]->ptr; + + /* Remove any older renaming for this command. */ + dictDelete(ri->renamed_commands,oldname); + + /* If the target name length is not zero, we need to add the + * actual entry to the renamed table. */ + if (sdslen(newname)) { + oldname = sdsdup(oldname); + newname = sdsdup(newname); + dictAdd(ri->renamed_commands,oldname,newname); + } + changes++; } else { addReplyErrorFormat(c,"Unknown option or number of arguments for " "SENTINEL SET '%s'", option);