diff --git a/include/dsn/dist/replication/replication_types.h b/include/dsn/dist/replication/replication_types.h index eece6262a6..63806a765c 100644 --- a/include/dsn/dist/replication/replication_types.h +++ b/include/dsn/dist/replication/replication_types.h @@ -249,7 +249,8 @@ struct detect_action enum type { START = 0, - STOP = 1 + STOP = 1, + QUERY = 2 }; }; @@ -7740,9 +7741,10 @@ inline std::ostream &operator<<(std::ostream &out, const detect_hotkey_request & typedef struct _detect_hotkey_response__isset { - _detect_hotkey_response__isset() : err(false), err_hint(false) {} + _detect_hotkey_response__isset() : err(false), err_hint(false), hotkey_result(false) {} bool err : 1; bool err_hint : 1; + bool hotkey_result : 1; } _detect_hotkey_response__isset; class detect_hotkey_response @@ -7752,11 +7754,12 @@ class detect_hotkey_response detect_hotkey_response(detect_hotkey_response &&); detect_hotkey_response &operator=(const detect_hotkey_response &); detect_hotkey_response &operator=(detect_hotkey_response &&); - detect_hotkey_response() : err_hint() {} + detect_hotkey_response() : err_hint(), hotkey_result() {} virtual ~detect_hotkey_response() throw(); ::dsn::error_code err; std::string err_hint; + std::string hotkey_result; _detect_hotkey_response__isset __isset; @@ -7764,6 +7767,8 @@ class detect_hotkey_response void __set_err_hint(const std::string &val); + void __set_hotkey_result(const std::string &val); + bool operator==(const detect_hotkey_response &rhs) const { if (!(err == rhs.err)) @@ -7772,6 +7777,10 @@ class detect_hotkey_response return false; else if (__isset.err_hint && !(err_hint == rhs.err_hint)) return false; + if (__isset.hotkey_result != rhs.__isset.hotkey_result) + return false; + else if (__isset.hotkey_result && !(hotkey_result == rhs.hotkey_result)) + return false; return true; } bool operator!=(const detect_hotkey_response &rhs) const { return !(*this == rhs); } diff --git a/src/common/replication_types.cpp b/src/common/replication_types.cpp index d8f8fc3d45..dd31aed20d 100644 --- a/src/common/replication_types.cpp +++ b/src/common/replication_types.cpp @@ -206,10 +206,10 @@ const std::map _hotkey_type_VALUES_TO_NAMES( ::apache::thrift::TEnumIterator(2, _khotkey_typeValues, _khotkey_typeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL)); -int _kdetect_actionValues[] = {detect_action::START, detect_action::STOP}; -const char *_kdetect_actionNames[] = {"START", "STOP"}; +int _kdetect_actionValues[] = {detect_action::START, detect_action::STOP, detect_action::QUERY}; +const char *_kdetect_actionNames[] = {"START", "STOP", "QUERY"}; const std::map _detect_action_VALUES_TO_NAMES( - ::apache::thrift::TEnumIterator(2, _kdetect_actionValues, _kdetect_actionNames), + ::apache::thrift::TEnumIterator(3, _kdetect_actionValues, _kdetect_actionNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL)); int _kdisk_migration_statusValues[] = {disk_migration_status::IDLE, @@ -18157,6 +18157,12 @@ void detect_hotkey_response::__set_err_hint(const std::string &val) __isset.err_hint = true; } +void detect_hotkey_response::__set_hotkey_result(const std::string &val) +{ + this->hotkey_result = val; + __isset.hotkey_result = true; +} + uint32_t detect_hotkey_response::read(::apache::thrift::protocol::TProtocol *iprot) { @@ -18192,6 +18198,14 @@ uint32_t detect_hotkey_response::read(::apache::thrift::protocol::TProtocol *ipr xfer += iprot->skip(ftype); } break; + case 3: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->hotkey_result); + this->__isset.hotkey_result = true; + } else { + xfer += iprot->skip(ftype); + } + break; default: xfer += iprot->skip(ftype); break; @@ -18219,6 +18233,11 @@ uint32_t detect_hotkey_response::write(::apache::thrift::protocol::TProtocol *op xfer += oprot->writeString(this->err_hint); xfer += oprot->writeFieldEnd(); } + if (this->__isset.hotkey_result) { + xfer += oprot->writeFieldBegin("hotkey_result", ::apache::thrift::protocol::T_STRING, 3); + xfer += oprot->writeString(this->hotkey_result); + xfer += oprot->writeFieldEnd(); + } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; @@ -18229,6 +18248,7 @@ void swap(detect_hotkey_response &a, detect_hotkey_response &b) using ::std::swap; swap(a.err, b.err); swap(a.err_hint, b.err_hint); + swap(a.hotkey_result, b.hotkey_result); swap(a.__isset, b.__isset); } @@ -18236,18 +18256,21 @@ detect_hotkey_response::detect_hotkey_response(const detect_hotkey_response &oth { err = other774.err; err_hint = other774.err_hint; + hotkey_result = other774.hotkey_result; __isset = other774.__isset; } detect_hotkey_response::detect_hotkey_response(detect_hotkey_response &&other775) { err = std::move(other775.err); err_hint = std::move(other775.err_hint); + hotkey_result = std::move(other775.hotkey_result); __isset = std::move(other775.__isset); } detect_hotkey_response &detect_hotkey_response::operator=(const detect_hotkey_response &other776) { err = other776.err; err_hint = other776.err_hint; + hotkey_result = other776.hotkey_result; __isset = other776.__isset; return *this; } @@ -18255,6 +18278,7 @@ detect_hotkey_response &detect_hotkey_response::operator=(detect_hotkey_response { err = std::move(other777.err); err_hint = std::move(other777.err_hint); + hotkey_result = std::move(other777.hotkey_result); __isset = std::move(other777.__isset); return *this; } @@ -18266,6 +18290,9 @@ void detect_hotkey_response::printTo(std::ostream &out) const out << ", " << "err_hint="; (__isset.err_hint ? (out << to_string(err_hint)) : (out << "")); + out << ", " + << "hotkey_result="; + (__isset.hotkey_result ? (out << to_string(hotkey_result)) : (out << "")); out << ")"; } } diff --git a/src/replica/replica_stub.cpp b/src/replica/replica_stub.cpp index a9e709d775..a2071b3ecb 100644 --- a/src/replica/replica_stub.cpp +++ b/src/replica/replica_stub.cpp @@ -2788,7 +2788,6 @@ void replica_stub::on_group_bulk_load(group_bulk_load_rpc rpc) } } -// TODO: (Tangyanzhao) implement it later void replica_stub::on_detect_hotkey(detect_hotkey_rpc rpc) { const auto &request = rpc.request(); diff --git a/src/replication.thrift b/src/replication.thrift index 0625a14641..a1f4226082 100644 --- a/src/replication.thrift +++ b/src/replication.thrift @@ -1144,7 +1144,8 @@ enum hotkey_type enum detect_action { START, - STOP + STOP, + QUERY } enum disk_migration_status { @@ -1167,6 +1168,7 @@ struct detect_hotkey_response { // - ERR_SERVICE_ALREADY_EXIST: hotkey detection is running now 1: dsn.error_code err; 2: optional string err_hint; + 3: optional string hotkey_result; } /*