Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
kaijchen committed Sep 4, 2024
1 parent d395606 commit fc04b46
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
7 changes: 5 additions & 2 deletions be/src/cloud/cloud_backend_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,11 @@ void CloudBackendService::warm_up_tablets(TWarmUpTabletsResponse& response,
void CloudBackendService::warm_up_cache_async(TWarmUpCacheAsyncResponse& response,
const TWarmUpCacheAsyncRequest& request) {
std::string host = request.host;
if (!is_valid_ip(request.host)) {
Status status = ExecEnv::GetInstance()->dns_cache()->get(request.host, &host);
auto dns_cache = ExecEnv::GetInstance()->dns_cache();
if (dns_cache == nullptr) {
LOG(WARNING) << "DNS cache is not initialized, skipping hostname resolve";
} else if (!is_valid_ip(request.host)) {
Status status = dns_cache->get(request.host, &host);
if (!status.ok()) {
LOG(WARNING) << "failed to get ip from host " << request.host << ": "
<< status.to_string();
Expand Down
10 changes: 6 additions & 4 deletions be/src/util/brpc_client_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ class BrpcClientCache {
}

std::shared_ptr<T> get_client(const std::string& host, int port) {
std::string realhost;
realhost = host;
if (!is_valid_ip(host)) {
Status status = ExecEnv::GetInstance()->dns_cache()->get(host, &realhost);
std::string realhost = host;
auto dns_cache = ExecEnv::GetInstance()->dns_cache();
if (dns_cache == nullptr) {
LOG(WARNING) << "DNS cache is not initialized, skipping hostname resolve";
} else if (!is_valid_ip(host)) {
Status status = dns_cache->get(host, &realhost);
if (!status.ok()) {
LOG(WARNING) << "failed to get ip from host:" << status.to_string();
return nullptr;
Expand Down
7 changes: 5 additions & 2 deletions be/src/util/proto_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ Status transmit_block_httpv2(ExecEnv* exec_env, std::unique_ptr<Closure> closure
RETURN_IF_ERROR(request_embed_attachment_contain_blockv2(closure->request_.get(), closure));

std::string host = brpc_dest_addr.hostname;
if (!is_valid_ip(brpc_dest_addr.hostname)) {
Status status = ExecEnv::GetInstance()->dns_cache()->get(brpc_dest_addr.hostname, &host);
auto dns_cache = ExecEnv::GetInstance()->dns_cache();
if (dns_cache == nullptr) {
LOG(WARNING) << "DNS cache is not initialized, skipping hostname resolve";
} else if (!is_valid_ip(brpc_dest_addr.hostname)) {
Status status = dns_cache->get(brpc_dest_addr.hostname, &host);
if (!status.ok()) {
LOG(WARNING) << "failed to get ip from host " << brpc_dest_addr.hostname << ": "
<< status.to_string();
Expand Down
7 changes: 5 additions & 2 deletions be/src/vec/sink/writer/vtablet_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,11 @@ void VNodeChannel::try_send_pending_block(RuntimeState* state) {
}

std::string host = _node_info.host;
if (!is_valid_ip(_node_info.host)) {
Status status = ExecEnv::GetInstance()->dns_cache()->get(_node_info.host, &host);
auto dns_cache = ExecEnv::GetInstance()->dns_cache();
if (dns_cache == nullptr) {
LOG(WARNING) << "DNS cache is not initialized, skipping hostname resolve";
} else if (!is_valid_ip(_node_info.host)) {
Status status = dns_cache->get(_node_info.host, &host);
if (!status.ok()) {
LOG(WARNING) << "failed to get ip from host " << _node_info.host << ": "
<< status.to_string();
Expand Down

0 comments on commit fc04b46

Please sign in to comment.