[FEAT MERGE] log4100 branch
Co-authored-by: tino247 <tino247@126.com> Co-authored-by: BinChenn <binchenn.bc@gmail.com> Co-authored-by: HaHaJeff <jeffzhouhhh@gmail.com>
This commit is contained in:
74
src/logservice/ob_net_keepalive_adapter.cpp
Normal file
74
src/logservice/ob_net_keepalive_adapter.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
// Copyright (c) 2021 OceanBase
|
||||
// OceanBase is licensed under Mulan PubL v2.
|
||||
// You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
// You may obtain a copy of Mulan PubL v2 at:
|
||||
// http://license.coscl.org.cn/MulanPubL-2.0
|
||||
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
// See the Mulan PubL v2 for more details.
|
||||
|
||||
#include "ob_net_keepalive_adapter.h"
|
||||
#include "rpc/obrpc/ob_net_keepalive.h" // ObNetKeepAlive
|
||||
#include "share/ob_lease_struct.h" // RSS_IS_STOPPED
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace logservice
|
||||
{
|
||||
ObNetKeepAliveAdapter::ObNetKeepAliveAdapter(obrpc::ObNetKeepAlive *net_keepalive)
|
||||
: net_keepalive_(net_keepalive)
|
||||
{
|
||||
}
|
||||
|
||||
ObNetKeepAliveAdapter::~ObNetKeepAliveAdapter()
|
||||
{
|
||||
net_keepalive_ = NULL;
|
||||
}
|
||||
|
||||
int ObNetKeepAliveAdapter::in_black_or_stopped_(const common::ObAddr &server,
|
||||
bool &in_blacklist,
|
||||
bool &is_server_stopped)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
obrpc::ObNetKeepAliveData ka_data;
|
||||
if (!server.is_valid()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
} else if (OB_FAIL(net_keepalive_->in_black(server, in_blacklist, &ka_data))) {
|
||||
CLOG_LOG(WARN, "in_black failed", K(ret), K(server));
|
||||
} else {
|
||||
is_server_stopped = (share::RSS_IS_STOPPED == ka_data.rs_server_status_);
|
||||
if (is_server_stopped
|
||||
&& REACH_TIME_INTERVAL(1 * 1000 * 1000)) {
|
||||
CLOG_LOG(INFO, "this server is stopped", K(server));
|
||||
}
|
||||
CLOG_LOG(TRACE, "in_black_or_stopped_ failed", K(in_blacklist), K(is_server_stopped), K(server));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ObNetKeepAliveAdapter::in_black_or_stopped(const common::ObAddr &server)
|
||||
{
|
||||
bool bool_ret = false;
|
||||
bool in_blacklist = false;
|
||||
bool is_server_stopped = false;
|
||||
if (OB_SUCCESS != in_black_or_stopped_(server, in_blacklist, is_server_stopped)) {
|
||||
} else {
|
||||
bool_ret = in_blacklist || is_server_stopped;
|
||||
}
|
||||
return bool_ret;
|
||||
}
|
||||
|
||||
bool ObNetKeepAliveAdapter::is_server_stopped(const common::ObAddr &server)
|
||||
{
|
||||
bool bool_ret = false;
|
||||
bool unused_in_blacklist = false;
|
||||
bool is_server_stopped = false;
|
||||
if (OB_SUCCESS != in_black_or_stopped_(server, unused_in_blacklist, is_server_stopped)) {
|
||||
} else {
|
||||
bool_ret = is_server_stopped;
|
||||
}
|
||||
return bool_ret;
|
||||
}
|
||||
} // end namespace logservice
|
||||
} // end namespace oceanbase
|
||||
Reference in New Issue
Block a user