diff --git a/compile_thrift.py b/compile_thrift.py index ecd8ebd4fe..d72dc30abd 100755 --- a/compile_thrift.py +++ b/compile_thrift.py @@ -28,23 +28,6 @@ "_types.cpp": "src/runtime" } }, - { - "name": "fd", - "path": "src/failure_detector", - "file_move": { - "_types.h": "include/dsn/dist/failure_detector" - }, - "include_fix": { - "_types.h": { - "add": [""], - "remove": ["\"dsn_types.h\""] - }, - "_types.cpp": { - "add": [""], - "remove": ["\"fd_types.h\""] - }, - } - }, { "name": "replication", "path": "src/", @@ -63,10 +46,6 @@ }, }, }, - { - "name": "simple_kv", - "path": "src/replica/storage/simple_kv" - }, ] diff --git a/include/dsn/dist/failure_detector/fd.code.definition.h b/include/dsn/dist/failure_detector/fd.code.definition.h index 40e75065b7..3d9a0fec58 100644 --- a/include/dsn/dist/failure_detector/fd.code.definition.h +++ b/include/dsn/dist/failure_detector/fd.code.definition.h @@ -36,7 +36,8 @@ #pragma once #include -#include +#include +#include "fd_types.h" namespace dsn { namespace fd { diff --git a/include/dsn/dist/failure_detector/fd_types.h b/include/dsn/dist/failure_detector/fd_types.h deleted file mode 100644 index 28625de849..0000000000 --- a/include/dsn/dist/failure_detector/fd_types.h +++ /dev/null @@ -1,222 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.3) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -#ifndef fd_TYPES_H -#define fd_TYPES_H - -#include -#include - -#include -#include -#include -#include - -#include - -namespace dsn { -namespace fd { - -class beacon_msg; - -class beacon_ack; - -class config_master_message; - -typedef struct _beacon_msg__isset -{ - _beacon_msg__isset() : time(false), from_addr(false), to_addr(false), start_time(false) {} - bool time : 1; - bool from_addr : 1; - bool to_addr : 1; - bool start_time : 1; -} _beacon_msg__isset; - -class beacon_msg -{ -public: - beacon_msg(const beacon_msg &); - beacon_msg(beacon_msg &&); - beacon_msg &operator=(const beacon_msg &); - beacon_msg &operator=(beacon_msg &&); - beacon_msg() : time(0), start_time(0) {} - - virtual ~beacon_msg() throw(); - int64_t time; - ::dsn::rpc_address from_addr; - ::dsn::rpc_address to_addr; - int64_t start_time; - - _beacon_msg__isset __isset; - - void __set_time(const int64_t val); - - void __set_from_addr(const ::dsn::rpc_address &val); - - void __set_to_addr(const ::dsn::rpc_address &val); - - void __set_start_time(const int64_t val); - - bool operator==(const beacon_msg &rhs) const - { - if (!(time == rhs.time)) - return false; - if (!(from_addr == rhs.from_addr)) - return false; - if (!(to_addr == rhs.to_addr)) - return false; - if (__isset.start_time != rhs.__isset.start_time) - return false; - else if (__isset.start_time && !(start_time == rhs.start_time)) - return false; - return true; - } - bool operator!=(const beacon_msg &rhs) const { return !(*this == rhs); } - - bool operator<(const beacon_msg &) const; - - uint32_t read(::apache::thrift::protocol::TProtocol *iprot); - uint32_t write(::apache::thrift::protocol::TProtocol *oprot) const; - - virtual void printTo(std::ostream &out) const; -}; - -void swap(beacon_msg &a, beacon_msg &b); - -inline std::ostream &operator<<(std::ostream &out, const beacon_msg &obj) -{ - obj.printTo(out); - return out; -} - -typedef struct _beacon_ack__isset -{ - _beacon_ack__isset() - : time(false), this_node(false), primary_node(false), is_master(false), allowed(false) - { - } - bool time : 1; - bool this_node : 1; - bool primary_node : 1; - bool is_master : 1; - bool allowed : 1; -} _beacon_ack__isset; - -class beacon_ack -{ -public: - beacon_ack(const beacon_ack &); - beacon_ack(beacon_ack &&); - beacon_ack &operator=(const beacon_ack &); - beacon_ack &operator=(beacon_ack &&); - beacon_ack() : time(0), is_master(0), allowed(0) {} - - virtual ~beacon_ack() throw(); - int64_t time; - ::dsn::rpc_address this_node; - ::dsn::rpc_address primary_node; - bool is_master; - bool allowed; - - _beacon_ack__isset __isset; - - void __set_time(const int64_t val); - - void __set_this_node(const ::dsn::rpc_address &val); - - void __set_primary_node(const ::dsn::rpc_address &val); - - void __set_is_master(const bool val); - - void __set_allowed(const bool val); - - bool operator==(const beacon_ack &rhs) const - { - if (!(time == rhs.time)) - return false; - if (!(this_node == rhs.this_node)) - return false; - if (!(primary_node == rhs.primary_node)) - return false; - if (!(is_master == rhs.is_master)) - return false; - if (!(allowed == rhs.allowed)) - return false; - return true; - } - bool operator!=(const beacon_ack &rhs) const { return !(*this == rhs); } - - bool operator<(const beacon_ack &) const; - - uint32_t read(::apache::thrift::protocol::TProtocol *iprot); - uint32_t write(::apache::thrift::protocol::TProtocol *oprot) const; - - virtual void printTo(std::ostream &out) const; -}; - -void swap(beacon_ack &a, beacon_ack &b); - -inline std::ostream &operator<<(std::ostream &out, const beacon_ack &obj) -{ - obj.printTo(out); - return out; -} - -typedef struct _config_master_message__isset -{ - _config_master_message__isset() : master(false), is_register(false) {} - bool master : 1; - bool is_register : 1; -} _config_master_message__isset; - -class config_master_message -{ -public: - config_master_message(const config_master_message &); - config_master_message(config_master_message &&); - config_master_message &operator=(const config_master_message &); - config_master_message &operator=(config_master_message &&); - config_master_message() : is_register(0) {} - - virtual ~config_master_message() throw(); - ::dsn::rpc_address master; - bool is_register; - - _config_master_message__isset __isset; - - void __set_master(const ::dsn::rpc_address &val); - - void __set_is_register(const bool val); - - bool operator==(const config_master_message &rhs) const - { - if (!(master == rhs.master)) - return false; - if (!(is_register == rhs.is_register)) - return false; - return true; - } - bool operator!=(const config_master_message &rhs) const { return !(*this == rhs); } - - bool operator<(const config_master_message &) const; - - uint32_t read(::apache::thrift::protocol::TProtocol *iprot); - uint32_t write(::apache::thrift::protocol::TProtocol *oprot) const; - - virtual void printTo(std::ostream &out) const; -}; - -void swap(config_master_message &a, config_master_message &b); - -inline std::ostream &operator<<(std::ostream &out, const config_master_message &obj) -{ - obj.printTo(out); - return out; -} -} -} // namespace - -#endif diff --git a/src/failure_detector/CMakeLists.txt b/src/failure_detector/CMakeLists.txt index 18860fa8c3..68f3610674 100644 --- a/src/failure_detector/CMakeLists.txt +++ b/src/failure_detector/CMakeLists.txt @@ -1,8 +1,13 @@ set(MY_PROJ_NAME dsn.failure_detector) -# Source files under CURRENT project directory will be automatically included. -# You can manually set MY_PROJ_SRC to include source files under other directories. -set(MY_PROJ_SRC "") +thrift_generate_cpp( + FD_THRIFT_SRCS + FD_THRIFT_HDRS + ${CMAKE_CURRENT_SOURCE_DIR}/fd.thrift +) + +seT(MY_PROJ_SRC ${FD_THRIFT_SRCS}) + # Search mode for source files under CURRENT project directory? # "GLOB_RECURSE" for recursive search diff --git a/src/failure_detector/fd.thrift b/src/failure_detector/fd.thrift index 8e3b8b0f25..41e2807b36 100644 --- a/src/failure_detector/fd.thrift +++ b/src/failure_detector/fd.thrift @@ -24,8 +24,3 @@ struct config_master_message 1: dsn.rpc_address master; 2: bool is_register; } - -service failure_detector -{ - beacon_ack ping(1:beacon_msg beacon) -} diff --git a/src/failure_detector/fd_types.cpp b/src/failure_detector/fd_types.cpp deleted file mode 100644 index 0c3041ec6c..0000000000 --- a/src/failure_detector/fd_types.cpp +++ /dev/null @@ -1,476 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.3) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -#include - -#include -#include - -#include - -namespace dsn { -namespace fd { - -beacon_msg::~beacon_msg() throw() {} - -void beacon_msg::__set_time(const int64_t val) { this->time = val; } - -void beacon_msg::__set_from_addr(const ::dsn::rpc_address &val) { this->from_addr = val; } - -void beacon_msg::__set_to_addr(const ::dsn::rpc_address &val) { this->to_addr = val; } - -void beacon_msg::__set_start_time(const int64_t val) -{ - this->start_time = val; - __isset.start_time = true; -} - -uint32_t beacon_msg::read(::apache::thrift::protocol::TProtocol *iprot) -{ - - apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - while (true) { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) { - case 1: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->time); - this->__isset.time = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 2: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->from_addr.read(iprot); - this->__isset.from_addr = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->to_addr.read(iprot); - this->__isset.to_addr = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 4: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->start_time); - this->__isset.start_time = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t beacon_msg::write(::apache::thrift::protocol::TProtocol *oprot) const -{ - uint32_t xfer = 0; - apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("beacon_msg"); - - xfer += oprot->writeFieldBegin("time", ::apache::thrift::protocol::T_I64, 1); - xfer += oprot->writeI64(this->time); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("from_addr", ::apache::thrift::protocol::T_STRUCT, 2); - xfer += this->from_addr.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("to_addr", ::apache::thrift::protocol::T_STRUCT, 3); - xfer += this->to_addr.write(oprot); - xfer += oprot->writeFieldEnd(); - - if (this->__isset.start_time) { - xfer += oprot->writeFieldBegin("start_time", ::apache::thrift::protocol::T_I64, 4); - xfer += oprot->writeI64(this->start_time); - xfer += oprot->writeFieldEnd(); - } - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(beacon_msg &a, beacon_msg &b) -{ - using ::std::swap; - swap(a.time, b.time); - swap(a.from_addr, b.from_addr); - swap(a.to_addr, b.to_addr); - swap(a.start_time, b.start_time); - swap(a.__isset, b.__isset); -} - -beacon_msg::beacon_msg(const beacon_msg &other0) -{ - time = other0.time; - from_addr = other0.from_addr; - to_addr = other0.to_addr; - start_time = other0.start_time; - __isset = other0.__isset; -} -beacon_msg::beacon_msg(beacon_msg &&other1) -{ - time = std::move(other1.time); - from_addr = std::move(other1.from_addr); - to_addr = std::move(other1.to_addr); - start_time = std::move(other1.start_time); - __isset = std::move(other1.__isset); -} -beacon_msg &beacon_msg::operator=(const beacon_msg &other2) -{ - time = other2.time; - from_addr = other2.from_addr; - to_addr = other2.to_addr; - start_time = other2.start_time; - __isset = other2.__isset; - return *this; -} -beacon_msg &beacon_msg::operator=(beacon_msg &&other3) -{ - time = std::move(other3.time); - from_addr = std::move(other3.from_addr); - to_addr = std::move(other3.to_addr); - start_time = std::move(other3.start_time); - __isset = std::move(other3.__isset); - return *this; -} -void beacon_msg::printTo(std::ostream &out) const -{ - using ::apache::thrift::to_string; - out << "beacon_msg("; - out << "time=" << to_string(time); - out << ", " - << "from_addr=" << to_string(from_addr); - out << ", " - << "to_addr=" << to_string(to_addr); - out << ", " - << "start_time="; - (__isset.start_time ? (out << to_string(start_time)) : (out << "")); - out << ")"; -} - -beacon_ack::~beacon_ack() throw() {} - -void beacon_ack::__set_time(const int64_t val) { this->time = val; } - -void beacon_ack::__set_this_node(const ::dsn::rpc_address &val) { this->this_node = val; } - -void beacon_ack::__set_primary_node(const ::dsn::rpc_address &val) { this->primary_node = val; } - -void beacon_ack::__set_is_master(const bool val) { this->is_master = val; } - -void beacon_ack::__set_allowed(const bool val) { this->allowed = val; } - -uint32_t beacon_ack::read(::apache::thrift::protocol::TProtocol *iprot) -{ - - apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - while (true) { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) { - case 1: - if (ftype == ::apache::thrift::protocol::T_I64) { - xfer += iprot->readI64(this->time); - this->__isset.time = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 2: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->this_node.read(iprot); - this->__isset.this_node = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 3: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->primary_node.read(iprot); - this->__isset.primary_node = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 4: - if (ftype == ::apache::thrift::protocol::T_BOOL) { - xfer += iprot->readBool(this->is_master); - this->__isset.is_master = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 5: - if (ftype == ::apache::thrift::protocol::T_BOOL) { - xfer += iprot->readBool(this->allowed); - this->__isset.allowed = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t beacon_ack::write(::apache::thrift::protocol::TProtocol *oprot) const -{ - uint32_t xfer = 0; - apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("beacon_ack"); - - xfer += oprot->writeFieldBegin("time", ::apache::thrift::protocol::T_I64, 1); - xfer += oprot->writeI64(this->time); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("this_node", ::apache::thrift::protocol::T_STRUCT, 2); - xfer += this->this_node.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("primary_node", ::apache::thrift::protocol::T_STRUCT, 3); - xfer += this->primary_node.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("is_master", ::apache::thrift::protocol::T_BOOL, 4); - xfer += oprot->writeBool(this->is_master); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("allowed", ::apache::thrift::protocol::T_BOOL, 5); - xfer += oprot->writeBool(this->allowed); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(beacon_ack &a, beacon_ack &b) -{ - using ::std::swap; - swap(a.time, b.time); - swap(a.this_node, b.this_node); - swap(a.primary_node, b.primary_node); - swap(a.is_master, b.is_master); - swap(a.allowed, b.allowed); - swap(a.__isset, b.__isset); -} - -beacon_ack::beacon_ack(const beacon_ack &other4) -{ - time = other4.time; - this_node = other4.this_node; - primary_node = other4.primary_node; - is_master = other4.is_master; - allowed = other4.allowed; - __isset = other4.__isset; -} -beacon_ack::beacon_ack(beacon_ack &&other5) -{ - time = std::move(other5.time); - this_node = std::move(other5.this_node); - primary_node = std::move(other5.primary_node); - is_master = std::move(other5.is_master); - allowed = std::move(other5.allowed); - __isset = std::move(other5.__isset); -} -beacon_ack &beacon_ack::operator=(const beacon_ack &other6) -{ - time = other6.time; - this_node = other6.this_node; - primary_node = other6.primary_node; - is_master = other6.is_master; - allowed = other6.allowed; - __isset = other6.__isset; - return *this; -} -beacon_ack &beacon_ack::operator=(beacon_ack &&other7) -{ - time = std::move(other7.time); - this_node = std::move(other7.this_node); - primary_node = std::move(other7.primary_node); - is_master = std::move(other7.is_master); - allowed = std::move(other7.allowed); - __isset = std::move(other7.__isset); - return *this; -} -void beacon_ack::printTo(std::ostream &out) const -{ - using ::apache::thrift::to_string; - out << "beacon_ack("; - out << "time=" << to_string(time); - out << ", " - << "this_node=" << to_string(this_node); - out << ", " - << "primary_node=" << to_string(primary_node); - out << ", " - << "is_master=" << to_string(is_master); - out << ", " - << "allowed=" << to_string(allowed); - out << ")"; -} - -config_master_message::~config_master_message() throw() {} - -void config_master_message::__set_master(const ::dsn::rpc_address &val) { this->master = val; } - -void config_master_message::__set_is_register(const bool val) { this->is_register = val; } - -uint32_t config_master_message::read(::apache::thrift::protocol::TProtocol *iprot) -{ - - apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - while (true) { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) { - case 1: - if (ftype == ::apache::thrift::protocol::T_STRUCT) { - xfer += this->master.read(iprot); - this->__isset.master = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 2: - if (ftype == ::apache::thrift::protocol::T_BOOL) { - xfer += iprot->readBool(this->is_register); - this->__isset.is_register = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t config_master_message::write(::apache::thrift::protocol::TProtocol *oprot) const -{ - uint32_t xfer = 0; - apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("config_master_message"); - - xfer += oprot->writeFieldBegin("master", ::apache::thrift::protocol::T_STRUCT, 1); - xfer += this->master.write(oprot); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("is_register", ::apache::thrift::protocol::T_BOOL, 2); - xfer += oprot->writeBool(this->is_register); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(config_master_message &a, config_master_message &b) -{ - using ::std::swap; - swap(a.master, b.master); - swap(a.is_register, b.is_register); - swap(a.__isset, b.__isset); -} - -config_master_message::config_master_message(const config_master_message &other8) -{ - master = other8.master; - is_register = other8.is_register; - __isset = other8.__isset; -} -config_master_message::config_master_message(config_master_message &&other9) -{ - master = std::move(other9.master); - is_register = std::move(other9.is_register); - __isset = std::move(other9.__isset); -} -config_master_message &config_master_message::operator=(const config_master_message &other10) -{ - master = other10.master; - is_register = other10.is_register; - __isset = other10.__isset; - return *this; -} -config_master_message &config_master_message::operator=(config_master_message &&other11) -{ - master = std::move(other11.master); - is_register = std::move(other11.is_register); - __isset = std::move(other11.__isset); - return *this; -} -void config_master_message::printTo(std::ostream &out) const -{ - using ::apache::thrift::to_string; - out << "config_master_message("; - out << "master=" << to_string(master); - out << ", " - << "is_register=" << to_string(is_register); - out << ")"; -} -} -} // namespace diff --git a/src/replica/storage/simple_kv/CMakeLists.txt b/src/replica/storage/simple_kv/CMakeLists.txt index 6b17f38e2a..aaf7029fe8 100644 --- a/src/replica/storage/simple_kv/CMakeLists.txt +++ b/src/replica/storage/simple_kv/CMakeLists.txt @@ -1,8 +1,12 @@ set(MY_PROJ_NAME dsn.replication.simple_kv) -# Source files under CURRENT project directory will be automatically included. -# You can manually set MY_PROJ_SRC to include source files under other directories. -set(MY_PROJ_SRC "") +thrift_generate_cpp( + SIMPLE_KV_THRIFT_SRCS + SIMPLE_KV_THRIFT_HDRS + ${CMAKE_CURRENT_SOURCE_DIR}/simple_kv.thrift +) + +set(MY_PROJ_SRC ${SIMPLE_KV_THRIFT_SRCS}) # Search mode for source files under CURRENT project directory? # "GLOB_RECURSE" for recursive search diff --git a/src/replica/storage/simple_kv/simple_kv.thrift b/src/replica/storage/simple_kv/simple_kv.thrift index 11ce66befe..bcc9fde89e 100644 --- a/src/replica/storage/simple_kv/simple_kv.thrift +++ b/src/replica/storage/simple_kv/simple_kv.thrift @@ -5,10 +5,3 @@ struct kv_pair 1:string key; 2:string value; } - -service simple_kv -{ - string read(1:string key); - i32 write(2:kv_pair pr); - i32 append(2:kv_pair pr); -} diff --git a/src/replica/storage/simple_kv/simple_kv_types.cpp b/src/replica/storage/simple_kv/simple_kv_types.cpp deleted file mode 100644 index a242b1d431..0000000000 --- a/src/replica/storage/simple_kv/simple_kv_types.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.3) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -#include "simple_kv_types.h" - -#include -#include - -#include - -namespace dsn { -namespace replication { -namespace application { - -kv_pair::~kv_pair() throw() {} - -void kv_pair::__set_key(const std::string &val) { this->key = val; } - -void kv_pair::__set_value(const std::string &val) { this->value = val; } - -uint32_t kv_pair::read(::apache::thrift::protocol::TProtocol *iprot) -{ - - apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); - uint32_t xfer = 0; - std::string fname; - ::apache::thrift::protocol::TType ftype; - int16_t fid; - - xfer += iprot->readStructBegin(fname); - - using ::apache::thrift::protocol::TProtocolException; - - while (true) { - xfer += iprot->readFieldBegin(fname, ftype, fid); - if (ftype == ::apache::thrift::protocol::T_STOP) { - break; - } - switch (fid) { - case 1: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->key); - this->__isset.key = true; - } else { - xfer += iprot->skip(ftype); - } - break; - case 2: - if (ftype == ::apache::thrift::protocol::T_STRING) { - xfer += iprot->readString(this->value); - this->__isset.value = true; - } else { - xfer += iprot->skip(ftype); - } - break; - default: - xfer += iprot->skip(ftype); - break; - } - xfer += iprot->readFieldEnd(); - } - - xfer += iprot->readStructEnd(); - - return xfer; -} - -uint32_t kv_pair::write(::apache::thrift::protocol::TProtocol *oprot) const -{ - uint32_t xfer = 0; - apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); - xfer += oprot->writeStructBegin("kv_pair"); - - xfer += oprot->writeFieldBegin("key", ::apache::thrift::protocol::T_STRING, 1); - xfer += oprot->writeString(this->key); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldBegin("value", ::apache::thrift::protocol::T_STRING, 2); - xfer += oprot->writeString(this->value); - xfer += oprot->writeFieldEnd(); - - xfer += oprot->writeFieldStop(); - xfer += oprot->writeStructEnd(); - return xfer; -} - -void swap(kv_pair &a, kv_pair &b) -{ - using ::std::swap; - swap(a.key, b.key); - swap(a.value, b.value); - swap(a.__isset, b.__isset); -} - -kv_pair::kv_pair(const kv_pair &other0) -{ - key = other0.key; - value = other0.value; - __isset = other0.__isset; -} -kv_pair::kv_pair(kv_pair &&other1) -{ - key = std::move(other1.key); - value = std::move(other1.value); - __isset = std::move(other1.__isset); -} -kv_pair &kv_pair::operator=(const kv_pair &other2) -{ - key = other2.key; - value = other2.value; - __isset = other2.__isset; - return *this; -} -kv_pair &kv_pair::operator=(kv_pair &&other3) -{ - key = std::move(other3.key); - value = std::move(other3.value); - __isset = std::move(other3.__isset); - return *this; -} -void kv_pair::printTo(std::ostream &out) const -{ - using ::apache::thrift::to_string; - out << "kv_pair("; - out << "key=" << to_string(key); - out << ", " - << "value=" << to_string(value); - out << ")"; -} -} -} -} // namespace diff --git a/src/replica/storage/simple_kv/simple_kv_types.h b/src/replica/storage/simple_kv/simple_kv_types.h deleted file mode 100644 index 9a8aa3167b..0000000000 --- a/src/replica/storage/simple_kv/simple_kv_types.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.3) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -#ifndef simple_kv_TYPES_H -#define simple_kv_TYPES_H - -#include - -#include -#include -#include -#include - -#include - -namespace dsn { -namespace replication { -namespace application { - -class kv_pair; - -typedef struct _kv_pair__isset -{ - _kv_pair__isset() : key(false), value(false) {} - bool key : 1; - bool value : 1; -} _kv_pair__isset; - -class kv_pair -{ -public: - kv_pair(const std::string &_key, const std::string &_val) : key(_key), value(_val) {} - - kv_pair(const kv_pair &); - kv_pair(kv_pair &&); - kv_pair &operator=(const kv_pair &); - kv_pair &operator=(kv_pair &&); - kv_pair() : key(), value() {} - - virtual ~kv_pair() throw(); - std::string key; - std::string value; - - _kv_pair__isset __isset; - - void __set_key(const std::string &val); - - void __set_value(const std::string &val); - - bool operator==(const kv_pair &rhs) const - { - if (!(key == rhs.key)) - return false; - if (!(value == rhs.value)) - return false; - return true; - } - bool operator!=(const kv_pair &rhs) const { return !(*this == rhs); } - - uint32_t read(::apache::thrift::protocol::TProtocol *iprot); - uint32_t write(::apache::thrift::protocol::TProtocol *oprot) const; - - virtual void printTo(std::ostream &out) const; -}; - -void swap(kv_pair &a, kv_pair &b); - -inline std::ostream &operator<<(std::ostream &out, const kv_pair &obj) -{ - obj.printTo(out); - return out; -} -} -} -} // namespace - -#endif diff --git a/src/replica/storage/simple_kv/test/CMakeLists.txt b/src/replica/storage/simple_kv/test/CMakeLists.txt index 0ea05559ce..17eba92636 100644 --- a/src/replica/storage/simple_kv/test/CMakeLists.txt +++ b/src/replica/storage/simple_kv/test/CMakeLists.txt @@ -4,7 +4,6 @@ set(MY_PROJ_NAME dsn.rep_tests.simple_kv) # "GLOB_RECURSE" for recursive search # "GLOB" for non-recursive search set(MY_SRC_SEARCH_MODE "GLOB") -set(MY_PROJ_SRC ${MY_PROJ_SRC} ../simple_kv_types.cpp) set(MY_PROJ_LIBS dsn_replica_server dsn_meta_server