提交 4e8dbd5f 编写于 作者: W wgs13579 提交者: guangshu.wgs

support encryption zone and replica

上级 1a623b67
...@@ -20,7 +20,7 @@ namespace oceanbase ...@@ -20,7 +20,7 @@ namespace oceanbase
namespace common namespace common
{ {
static const char *zone_type_strs[] = { "ReadWrite", "ReadOnly", "Invalid" }; static const char *zone_type_strs[] = { "ReadWrite", "ReadOnly", "Encryption", "Invalid" };
const char *zone_type_to_str(ObZoneType zone_type) const char *zone_type_to_str(ObZoneType zone_type)
{ {
const char *zone_type_str = NULL; const char *zone_type_str = NULL;
......
...@@ -21,7 +21,8 @@ enum ObZoneType ...@@ -21,7 +21,8 @@ enum ObZoneType
{ {
ZONE_TYPE_READWRITE = 0, ZONE_TYPE_READWRITE = 0,
ZONE_TYPE_READONLY = 1, ZONE_TYPE_READONLY = 1,
ZONE_TYPE_INVALID = 2, ZONE_TYPE_ENCRYPTION = 2,
ZONE_TYPE_INVALID = 3,
}; };
const char *zone_type_to_str(ObZoneType zone_type); const char *zone_type_to_str(ObZoneType zone_type);
......
...@@ -946,8 +946,9 @@ inline bool is_not_supported_err(int err) ...@@ -946,8 +946,9 @@ inline bool is_not_supported_err(int err)
* |--- 4 bits ---|--- 2 bits ---|--- 2 bits ---| LSB * |--- 4 bits ---|--- 2 bits ---|--- 2 bits ---| LSB
* |--- clog ---|-- SSStore ---|--- MemStore--| LSB * |--- clog ---|-- SSStore ---|--- MemStore--| LSB
*/ */
static const int64_t SSSTORE_BITS_SHIFT = 2; static const int64_t SSSTORE_BITS_SHIFT = 2;
static const int64_t CLOG_BITS_SHIFT = 4; static const int64_t CLOG_BITS_SHIFT = 4;
static const int64_t ENCRYPTION_BITS_SHIFT = 8;
// replica type associated with memstore // replica type associated with memstore
static const int64_t WITH_MEMSTORE = 0; static const int64_t WITH_MEMSTORE = 0;
static const int64_t WITHOUT_MEMSTORE = 1; static const int64_t WITHOUT_MEMSTORE = 1;
...@@ -957,6 +958,9 @@ static const int64_t WITHOUT_SSSTORE = 1 << SSSTORE_BITS_SHIFT; ...@@ -957,6 +958,9 @@ static const int64_t WITHOUT_SSSTORE = 1 << SSSTORE_BITS_SHIFT;
// replica type associated with clog // replica type associated with clog
static const int64_t SYNC_CLOG = 0 << CLOG_BITS_SHIFT; static const int64_t SYNC_CLOG = 0 << CLOG_BITS_SHIFT;
static const int64_t ASYNC_CLOG = 1 << CLOG_BITS_SHIFT; static const int64_t ASYNC_CLOG = 1 << CLOG_BITS_SHIFT;
// replica type associated with encryption
const int64_t WITHOUT_ENCRYPTION = 0 << ENCRYPTION_BITS_SHIFT;
const int64_t WITH_ENCRYPTION = 1 << ENCRYPTION_BITS_SHIFT;
// Need to manually maintain the replica_type_to_str function in utility.cpp, // Need to manually maintain the replica_type_to_str function in utility.cpp,
// Currently there are only three types: REPLICA_TYPE_FULL, REPLICA_TYPE_READONLY, and REPLICA_TYPE_LOGONLY // Currently there are only three types: REPLICA_TYPE_FULL, REPLICA_TYPE_READONLY, and REPLICA_TYPE_LOGONLY
...@@ -974,6 +978,8 @@ enum ObReplicaType ...@@ -974,6 +978,8 @@ enum ObReplicaType
REPLICA_TYPE_READONLY = (ASYNC_CLOG | WITH_SSSTORE | WITH_MEMSTORE), // 16 REPLICA_TYPE_READONLY = (ASYNC_CLOG | WITH_SSSTORE | WITH_MEMSTORE), // 16
// Incremental copy: not a member of paxos; no ssstore; memstore // Incremental copy: not a member of paxos; no ssstore; memstore
REPLICA_TYPE_MEMONLY = (ASYNC_CLOG | WITHOUT_SSSTORE | WITH_MEMSTORE), // 20 REPLICA_TYPE_MEMONLY = (ASYNC_CLOG | WITHOUT_SSSTORE | WITH_MEMSTORE), // 20
// Encrypted log copy: encrypted; paxos member; no sstore; no memstore
REPLICA_TYPE_ENCRYPTION_LOGONLY = (WITH_ENCRYPTION | SYNC_CLOG | WITHOUT_SSSTORE | WITHOUT_MEMSTORE), // 261
// invalid value // invalid value
REPLICA_TYPE_MAX, REPLICA_TYPE_MAX,
}; };
...@@ -995,7 +1001,8 @@ public: ...@@ -995,7 +1001,8 @@ public:
} }
static bool is_paxos_replica(const int32_t replica_type) static bool is_paxos_replica(const int32_t replica_type)
{ {
return (replica_type >= REPLICA_TYPE_FULL && replica_type <= REPLICA_TYPE_LOGONLY); return (replica_type >= REPLICA_TYPE_FULL && replica_type <= REPLICA_TYPE_LOGONLY)
|| (REPLICA_TYPE_ENCRYPTION_LOGONLY == replica_type);
} }
static bool is_writable_replica(const int32_t replica_type) static bool is_writable_replica(const int32_t replica_type)
{ {
......
...@@ -1658,6 +1658,8 @@ int ObServerStateRefreshUtils::get_server_state_info( ...@@ -1658,6 +1658,8 @@ int ObServerStateRefreshUtils::get_server_state_info(
} else { } else {
if (server_state.zone_state_->is_readonly_zone()) { if (server_state.zone_state_->is_readonly_zone()) {
server_state.replica_.replica_type_ = REPLICA_TYPE_READONLY; server_state.replica_.replica_type_ = REPLICA_TYPE_READONLY;
} else if (server_state.zone_state_->is_encryption_zone()) {
server_state.replica_.replica_type_ = REPLICA_TYPE_ENCRYPTION_LOGONLY;
} else { } else {
server_state.replica_.replica_type_ = REPLICA_TYPE_FULL; server_state.replica_.replica_type_ = REPLICA_TYPE_FULL;
} }
......
...@@ -36,6 +36,7 @@ struct ObZoneStateInfo ...@@ -36,6 +36,7 @@ struct ObZoneStateInfo
int set_idc_name(const common::ObString &idc_name); int set_idc_name(const common::ObString &idc_name);
int64_t to_string(char *buffer, const int64_t size) const; int64_t to_string(char *buffer, const int64_t size) const;
bool is_readonly_zone() { return common::ZONE_TYPE_READONLY == zone_type_; } bool is_readonly_zone() { return common::ZONE_TYPE_READONLY == zone_type_; }
bool is_encryption_zone() { return common::ZONE_TYPE_ENCRYPTION == zone_type_; }
ObZoneStateInfo &operator=(const ObZoneStateInfo &other); ObZoneStateInfo &operator=(const ObZoneStateInfo &other);
common::ObString zone_name_; common::ObString zone_name_;
......
...@@ -4275,7 +4275,8 @@ inline void ObMysqlTransact::handle_server_failed(ObTransState &s) ...@@ -4275,7 +4275,8 @@ inline void ObMysqlTransact::handle_server_failed(ObTransState &s)
break; break;
} }
case -OB_ERR_READ_ONLY: { case -OB_ERR_READ_ONLY: {
if (ZONE_TYPE_READONLY == s.pll_info_.route_.cur_chosen_server_.zone_type_) { if (ZONE_TYPE_READONLY == s.pll_info_.route_.cur_chosen_server_.zone_type_
|| ZONE_TYPE_ENCRYPTION == s.pll_info_.route_.cur_chosen_server_.zone_type_) {
LOG_WARN("zone is readonly, but server tell error response, " LOG_WARN("zone is readonly, but server tell error response, "
"maybe this new server do not support old agreement, try next server", "maybe this new server do not support old agreement, try next server",
"origin_name", s.pll_info_.te_name_, "origin_name", s.pll_info_.te_name_,
......
...@@ -399,7 +399,8 @@ int ObLDCLocation::fill_strong_read_location(const ObProxyPartitionLocation *pl, ...@@ -399,7 +399,8 @@ int ObLDCLocation::fill_strong_read_location(const ObProxyPartitionLocation *pl,
&& !replica.is_leader()) { && !replica.is_leader()) {
//do not use it //do not use it
need_use_it = false; need_use_it = false;
} else if (REPLICA_TYPE_LOGONLY == replica.get_replica_type()) { } else if (REPLICA_TYPE_LOGONLY == replica.get_replica_type()
|| REPLICA_TYPE_ENCRYPTION_LOGONLY == replica.get_replica_type()) {
// log relica, skip // log relica, skip
need_use_it = false; need_use_it = false;
} else { } else {
...@@ -457,7 +458,9 @@ int ObLDCLocation::fill_strong_read_location(const ObProxyPartitionLocation *pl, ...@@ -457,7 +458,9 @@ int ObLDCLocation::fill_strong_read_location(const ObProxyPartitionLocation *pl,
for (int64_t j = 0; OB_SUCC(ret) && j < dummy_ldc.item_count_; ++j) { for (int64_t j = 0; OB_SUCC(ret) && j < dummy_ldc.item_count_; ++j) {
const ObLDCItem &dummy_item = dummy_ldc.item_array_[j]; const ObLDCItem &dummy_item = dummy_ldc.item_array_[j];
// skip log relica // skip log relica
if (dummy_item.is_used_ || REPLICA_TYPE_LOGONLY == dummy_item.replica_->get_replica_type()) { if (dummy_item.is_used_
|| REPLICA_TYPE_LOGONLY == dummy_item.replica_->get_replica_type()
|| REPLICA_TYPE_ENCRYPTION_LOGONLY == dummy_item.replica_->get_replica_type()) {
//continue //continue
} else if (is_only_readwrite_zone && common::ZONE_TYPE_READWRITE != dummy_item.zone_type_) { } else if (is_only_readwrite_zone && common::ZONE_TYPE_READWRITE != dummy_item.zone_type_) {
//do not use id //do not use id
......
...@@ -65,6 +65,10 @@ ObString ObProxyReplicaLocation::get_replica_type_string(const ObReplicaType typ ...@@ -65,6 +65,10 @@ ObString ObProxyReplicaLocation::get_replica_type_string(const ObReplicaType typ
string = ObString::make_string("MEMONLY"); string = ObString::make_string("MEMONLY");
break; break;
} }
case REPLICA_TYPE_ENCRYPTION_LOGONLY: {
string = ObString::make_string("ENCRYPTION_LOGONLY");
break;
}
case REPLICA_TYPE_MAX: { case REPLICA_TYPE_MAX: {
string = ObString::make_string("MAX"); string = ObString::make_string("MAX");
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册