greatsharp commented on code in PR #2954:
URL: https://github.com/apache/kvrocks/pull/2954#discussion_r2106063850
##########
src/commands/cmd_server.cc:
##########
@@ -309,6 +309,58 @@ class CommandDBSize : public Commander {
}
};
+class CommandSlotSize : public Commander {
+ public:
+ Status Parse(const std::vector<std::string> &args) override {
+ if (args.size() < 2 || args.size() > 3) {
+ return {Status::RedisParseErr, errWrongNumOfArguments};
+ }
+ if (args.size() == 3 && !util::EqualICase(args[2], "scan") &&
!util::EqualICase(args[2], "clear")) {
+ return {Status::RedisParseErr, "Invalid slotsize command, eg: slotsize
{SlotRange} {scan|clear}"};
+ }
+ return Status::OK();
+ }
+
+ Status Execute([[maybe_unused]] engine::Context &ctx, Server *srv,
[[maybe_unused]] Connection *conn,
+ std::string *output) override {
+ if (!srv->storage->IsSlotIdEncoded()) {
+ return {Status::RedisExecErr, "It is not in cluster mode"};
+ }
+
+ std::vector<SlotRange> slot_ranges;
+ Status s = CommandTable::ParseSlotRanges(args_[1], slot_ranges);
+ if (!s.IsOK()) {
+ return s;
+ }
+
+ if (args_.size() == 2) {
+ std::vector<std::string> stats;
+ s = srv->GetSlotStats(slot_ranges, &stats);
+ if (!s.IsOK()) {
+ return s;
+ }
+ *output = redis::ArrayOfBulkStrings(stats);
+ } else if (args_.size() == 3 && util::EqualICase(args_[2], "scan")) {
+ s = srv->AsyncScanSlots(slot_ranges);
+ if (s.IsOK()) {
+ *output = redis::RESP_OK;
+ } else {
+ return s;
+ }
+ } else if (args_.size() == 3 && util::EqualICase(args_[2], "clear")) {
+ s = srv->ClearSlots(slot_ranges);
+ if (s.IsOK()) {
+ *output = redis::RESP_OK;
+ } else {
+ return s;
+ }
Review Comment:
I removed the clear slot function, add dump function.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]