Commit cc3de349 authored by zhujiashun's avatar zhujiashun

health_check_using_rpc: add necessary logs

parent 4acdf923
...@@ -118,7 +118,7 @@ friend int StreamCreate(StreamId*, Controller&, const StreamOptions*); ...@@ -118,7 +118,7 @@ friend int StreamCreate(StreamId*, Controller&, const StreamOptions*);
friend int StreamAccept(StreamId*, Controller&, const StreamOptions*); friend int StreamAccept(StreamId*, Controller&, const StreamOptions*);
friend void policy::ProcessMongoRequest(InputMessageBase*); friend void policy::ProcessMongoRequest(InputMessageBase*);
friend void policy::ProcessThriftRequest(InputMessageBase*); friend void policy::ProcessThriftRequest(InputMessageBase*);
friend class OnHealthCheckRPCDone; friend class OnAppHealthCheckDone;
friend class HealthCheckManager; friend class HealthCheckManager;
// << Flags >> // << Flags >>
static const uint32_t FLAGS_IGNORE_EOVERCROWDED = 1; static const uint32_t FLAGS_IGNORE_EOVERCROWDED = 1;
......
...@@ -1008,10 +1008,10 @@ int HealthCheckChannel::Init(SocketId id, const ChannelOptions* options) { ...@@ -1008,10 +1008,10 @@ int HealthCheckChannel::Init(SocketId id, const ChannelOptions* options) {
return 0; return 0;
} }
class OnHealthCheckRPCDone : public google::protobuf::Closure { class OnAppHealthCheckDone : public google::protobuf::Closure {
public: public:
void Run() { void Run() {
std::unique_ptr<OnHealthCheckRPCDone> self_guard(this); std::unique_ptr<OnAppHealthCheckDone> self_guard(this);
SocketUniquePtr ptr; SocketUniquePtr ptr;
const int rc = Socket::AddressFailedAsWell(id, &ptr); const int rc = Socket::AddressFailedAsWell(id, &ptr);
if (rc < 0) { if (rc < 0) {
...@@ -1020,12 +1020,13 @@ public: ...@@ -1020,12 +1020,13 @@ public:
return; return;
} }
if (!cntl.Failed() || ptr->Failed()) { if (!cntl.Failed() || ptr->Failed()) {
LOG_IF(INFO, !cntl.Failed()) << "AppRevived "
<< ptr->remote_side() << FLAGS_health_check_path;
ptr->_ninflight_app_health_check.fetch_sub( ptr->_ninflight_app_health_check.fetch_sub(
1, butil::memory_order_relaxed); 1, butil::memory_order_relaxed);
return; return;
} }
RPC_VLOG << "Fail to health check using rpc, error=" RPC_VLOG << "Fail to AppCheck, " << cntl.ErrorText();
<< cntl.ErrorText();
bthread_usleep(interval_s * 1000000); bthread_usleep(interval_s * 1000000);
cntl.Reset(); cntl.Reset();
cntl.http_request().uri() = FLAGS_health_check_path; cntl.http_request().uri() = FLAGS_health_check_path;
...@@ -1049,11 +1050,12 @@ public: ...@@ -1049,11 +1050,12 @@ public:
<< " was abandoned during health checking"; << " was abandoned during health checking";
return; return;
} }
OnHealthCheckRPCDone* done = new OnHealthCheckRPCDone; LOG(INFO) << "AppChecking " << ptr->remote_side() << FLAGS_health_check_path;
OnAppHealthCheckDone* done = new OnAppHealthCheckDone;
done->id = id; done->id = id;
done->interval_s = check_interval_s; done->interval_s = check_interval_s;
brpc::ChannelOptions options; brpc::ChannelOptions options;
options.protocol = "http"; options.protocol = PROTOCOL_HTTP;
options.max_retry = 0; options.max_retry = 0;
options.timeout_ms = FLAGS_health_check_timeout_ms; options.timeout_ms = FLAGS_health_check_timeout_ms;
if (done->channel.Init(id, &options) != 0) { if (done->channel.Init(id, &options) != 0) {
......
...@@ -186,7 +186,7 @@ friend class policy::ConsistentHashingLoadBalancer; ...@@ -186,7 +186,7 @@ friend class policy::ConsistentHashingLoadBalancer;
friend class policy::RtmpContext; friend class policy::RtmpContext;
friend class schan::ChannelBalancer; friend class schan::ChannelBalancer;
friend class HealthCheckTask; friend class HealthCheckTask;
friend class OnHealthCheckRPCDone; friend class OnAppHealthCheckDone;
friend class HealthCheckManager; friend class HealthCheckManager;
friend class policy::H2GlobalStreamCreator; friend class policy::H2GlobalStreamCreator;
class SharedPart; class SharedPart;
......
...@@ -732,7 +732,7 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) { ...@@ -732,7 +732,7 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) {
brpc::SocketUniquePtr ptr; brpc::SocketUniquePtr ptr;
ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr)); ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr));
ptr->_ninflight_app_level_health_check.store(1, butil::memory_order_relaxed); ptr->_ninflight_app_health_check.store(1, butil::memory_order_relaxed);
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
brpc::SocketUniquePtr ptr; brpc::SocketUniquePtr ptr;
brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL };
...@@ -743,7 +743,7 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) { ...@@ -743,7 +743,7 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) {
} }
ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr)); ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr));
ptr->_ninflight_app_level_health_check.store(1, butil::memory_order_relaxed); ptr->_ninflight_app_health_check.store(1, butil::memory_order_relaxed);
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
brpc::SocketUniquePtr ptr; brpc::SocketUniquePtr ptr;
brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL };
...@@ -753,9 +753,9 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) { ...@@ -753,9 +753,9 @@ TEST_F(LoadBalancerTest, health_check_no_valid_server) {
} }
ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr)); ASSERT_EQ(0, brpc::Socket::Address(ids[0].id, &ptr));
ptr->_ninflight_app_level_health_check.store(0, butil::memory_order_relaxed); ptr->_ninflight_app_health_check.store(0, butil::memory_order_relaxed);
ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr)); ASSERT_EQ(0, brpc::Socket::Address(ids[1].id, &ptr));
ptr->_ninflight_app_level_health_check.store(0, butil::memory_order_relaxed); ptr->_ninflight_app_health_check.store(0, butil::memory_order_relaxed);
// After reset health check state, the lb should work fine // After reset health check state, the lb should work fine
bool get_server1 = false; bool get_server1 = false;
bool get_server2 = false; bool get_server2 = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment