liboblog support rpc authentication

This commit is contained in:
liucc1997 2023-08-03 03:12:17 +00:00 committed by ob-robot
parent f9b9ce2307
commit b654ef984b
4 changed files with 27 additions and 3 deletions

View File

@ -246,6 +246,27 @@ int ObPocRpcServer::start(int port, int net_thread_count, frame::ObReqDeliver* d
return ret;
}
int ObPocRpcServer::start_net_client(int net_thread_count)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(has_start_)) {
RPC_LOG(WARN, "client has already started!");
} else {
int count = 0;
const int listen_none = -1;
if ((count = pn_provision(listen_none, DEFAULT_PNIO_GROUP, net_thread_count)) != net_thread_count) {
ret = OB_ERR_SYS;
RPC_LOG(WARN, "pn_provision error", K(count), K(net_thread_count));
} else if((count = pn_provision(listen_none, RATELIMIT_PNIO_GROUP, net_thread_count)) != net_thread_count) {
ret = OB_ERR_SYS;
RPC_LOG(WARN, "pn_provision for RATELIMIT_PNIO_GROUP error", K(count), K(net_thread_count));
} else {
has_start_ = true;
}
}
return ret;
}
void ObPocRpcServer::stop()
{
for (uint64_t gid = 1; gid < END_GROUP; gid++) {

View File

@ -63,6 +63,7 @@ public:
ObPocRpcServer() : has_start_(false){}
~ObPocRpcServer() {}
int start(int port, int net_thread_count, rpc::frame::ObReqDeliver* deliver);
int start_net_client(int net_thread_count);
void stop();
void wait();
bool has_start() {return has_start_;}

View File

@ -176,6 +176,8 @@ int ObLogRpc::init(const int64_t io_thread_num)
LOG_ERROR("invalid argument", KR(ret), K(io_thread_num));
} else if (OB_FAIL(init_client_id_())) {
LOG_ERROR("init client identity failed", KR(ret));
} else if (OB_FAIL(global_poc_server.start_net_client(opt.rpc_io_cnt_))) {
LOG_ERROR("start net client failed", KR(ret), K(io_thread_num));
} else if (OB_FAIL(net_client_.init(opt))) {
LOG_ERROR("init net client fail", KR(ret), K(io_thread_num));
} else if (OB_FAIL(reload_rpc_client_auth_method())) {

View File

@ -420,9 +420,9 @@ OB_DEF_SERIALIZE_SIZE(ObServerConfig)
namespace obrpc {
bool enable_pkt_nio() {
bool bool_ret = false;
if (OB_UNLIKELY(OBSERVER.is_arbitration_mode())) {
bool enable_clent_auth = (get_client_auth_methods() != USSL_AUTH_NONE);
bool_ret = GCONF._enable_pkt_nio && enable_clent_auth;
if (OB_UNLIKELY(OBSERVER.is_stopped() || OBSERVER.is_arbitration_mode())) {
bool enable_client_auth = (get_client_auth_methods() != USSL_AUTH_NONE);
bool_ret = GCONF._enable_pkt_nio && enable_client_auth;
} else {
bool_ret = GCONF._enable_pkt_nio && GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_2_0_0;
}