This is an automated email from the ASF dual-hosted git repository. lingbin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push: new b3c5f0f Remove unneeded headers included in agent-util (#2929) b3c5f0f is described below commit b3c5f0fac7d453da5cbefb023e107ec818915f80 Author: LingBin <lingbi...@gmail.com> AuthorDate: Tue Feb 18 13:18:56 2020 +0800 Remove unneeded headers included in agent-util (#2929) --- be/src/agent/utils.cpp | 99 +++++++++++++--------------------- be/src/agent/utils.h | 21 +++----- be/src/olap/task/engine_clone_task.cpp | 8 +-- 3 files changed, 48 insertions(+), 80 deletions(-) diff --git a/be/src/agent/utils.cpp b/be/src/agent/utils.cpp index b7515e8..c5e48a9 100644 --- a/be/src/agent/utils.cpp +++ b/be/src/agent/utils.cpp @@ -16,45 +16,23 @@ // under the License. #include "agent/utils.h" -#include <arpa/inet.h> + #include <cstdio> -#include <errno.h> #include <fstream> -#include <iostream> -#include <netdb.h> -#include <netinet/in.h> #include <sstream> -#include <sys/socket.h> -#include <sys/wait.h> -#include <unistd.h> - -#include <boost/filesystem.hpp> -#include <thrift/Thrift.h> -#include <thrift/transport/TSocket.h> -#include <thrift/transport/TTransportException.h> -#include <thrift/transport/TTransportUtils.h> + #include <rapidjson/document.h> #include <rapidjson/rapidjson.h> #include <rapidjson/stringbuffer.h> #include <rapidjson/writer.h> #include "common/status.h" -#include "gen_cpp/AgentService_types.h" -#include "gen_cpp/HeartbeatService_types.h" -#include "gen_cpp/FrontendService.h" -#include "gen_cpp/Status_types.h" -#include "olap/utils.h" -#include "runtime/exec_env.h" using std::map; -using std::pair; using std::string; using std::stringstream; using std::vector; -using apache::thrift::protocol::TBinaryProtocol; using apache::thrift::TException; -using apache::thrift::transport::TSocket; -using apache::thrift::transport::TBufferedTransport; using apache::thrift::transport::TTransportException; namespace doris { @@ -77,9 +55,10 @@ AgentStatus MasterServerClient::finish_task( &client_status); if (!client_status.ok()) { - LOG(WARNING) << "master client. get client from cache failed. host: " - << _master_info.network_address.hostname << ". port: " << _master_info.network_address.port - << ". code: " << client_status.code(); + LOG(WARNING) << "fail to get master client from cache. " + << "host=" << _master_info.network_address.hostname + << ", port=" << _master_info.network_address.port + << ", code=" << client_status.code(); return DORIS_ERROR; } @@ -87,27 +66,23 @@ AgentStatus MasterServerClient::finish_task( try { client->finishTask(*result, request); } catch (TTransportException& e) { - OLAP_LOG_WARNING("master client, retry finishTask: %s", e.what()); + LOG(WARNING) << "master client, retry finishTask: " << e.what(); client_status = client.reopen(config::thrift_rpc_timeout_ms); - if (!client_status.ok()) { - OLAP_LOG_WARNING("master client, get client from cache failed." - "host: %s, port: %d, code: %d", - _master_info.network_address.hostname.c_str(), - _master_info.network_address.port, - client_status.code()); + LOG(WARNING) << "fail to get master client from cache. " + << "host=" << _master_info.network_address.hostname + << ", port=" << _master_info.network_address.port + << ", code=" << client_status.code(); return DORIS_ERROR; } - client->finishTask(*result, request); } } catch (TException& e) { client.reopen(config::thrift_rpc_timeout_ms); - OLAP_LOG_WARNING("master client, finishTask execute failed." - "host: %s, port: %d, error: %s", - _master_info.network_address.hostname.c_str(), - _master_info.network_address.port, - e.what()); + LOG(WARNING) << "fail to finish_task. " + << "host=" << _master_info.network_address.hostname + << ", port=" << _master_info.network_address.port + << ", error=" << e.what(); return DORIS_ERROR; } @@ -123,11 +98,10 @@ AgentStatus MasterServerClient::report(const TReportRequest& request, TMasterRes &client_status); if (!client_status.ok()) { - OLAP_LOG_WARNING("master client, get client from cache failed." - "host: %s, port: %d, code: %d", - _master_info.network_address.hostname.c_str(), - _master_info.network_address.port, - client_status.code()); + LOG(WARNING) << "fail to get master client from cache. " + << "host=" << _master_info.network_address.hostname + << ", port=" << _master_info.network_address.port + << ", code=" << client_status.code(); return DORIS_ERROR; } @@ -138,30 +112,31 @@ AgentStatus MasterServerClient::report(const TReportRequest& request, TMasterRes TTransportException::TTransportExceptionType type = e.getType(); if (type != TTransportException::TTransportExceptionType::TIMED_OUT) { // if not TIMED_OUT, retry - OLAP_LOG_WARNING("master client, retry report: %s", e.what()); + LOG(WARNING) << "master client, retry finishTask: " << e.what(); client_status = client.reopen(config::thrift_rpc_timeout_ms); if (!client_status.ok()) { - OLAP_LOG_WARNING("master client, get client from cache failed." - "host: %s, port: %d, code: %d", - _master_info.network_address.hostname.c_str(), - _master_info.network_address.port, - client_status.code()); + LOG(WARNING) << "fail to get master client from cache. " + << "host=" << _master_info.network_address.hostname + << ", port=" << _master_info.network_address.port + << ", code=" << client_status.code(); return DORIS_ERROR; - } + } client->report(*result, request); } else { // TIMED_OUT exception. do not retry // actually we don't care what FE returns. - OLAP_LOG_WARNING("master client, report failed: %s", e.what()); + LOG(WARNING) << "fail to report to master: " << e.what(); return DORIS_ERROR; - } - } + } + } } catch (TException& e) { client.reopen(config::thrift_rpc_timeout_ms); - LOG(WARNING) << "master client. finish report failed. host: " << _master_info.network_address.hostname - << ". port: " << _master_info.network_address.port << ". code: " << client_status.code(); + LOG(WARNING) << "fail to report to master. " + << "host=" << _master_info.network_address.hostname + << ", port=" << _master_info.network_address.port + << ", code=" << client_status.code(); return DORIS_ERROR; } @@ -277,7 +252,7 @@ bool AgentUtils::exec_cmd(const string& command, string* errmsg) { // Waits for the associated process to terminate and returns. rc = pclose(fp); if (rc == -1) { - if (errno==ECHILD) { + if (errno == ECHILD) { *errmsg += "pclose cannot obtain the child status.\n"; } else { stringstream err_stream; @@ -302,7 +277,7 @@ bool AgentUtils::write_json_to_file(const map<string, string>& info, const strin for (auto &it : info) { json_info.AddMember( rapidjson::Value(it.first.c_str(), json_info.GetAllocator()).Move(), - rapidjson::Value(it.second.c_str(), json_info.GetAllocator()).Move(), + rapidjson::Value(it.second.c_str(), json_info.GetAllocator()).Move(), json_info.GetAllocator()); } rapidjson::StringBuffer json_info_str; @@ -314,8 +289,8 @@ bool AgentUtils::write_json_to_file(const map<string, string>& info, const strin } fp << json_info_str.GetString() << std::endl; fp.close(); - - return true; -} + + return true; +} } // namespace doris diff --git a/be/src/agent/utils.h b/be/src/agent/utils.h index 0445269..1bb41a5 100644 --- a/be/src/agent/utils.h +++ b/be/src/agent/utils.h @@ -18,18 +18,10 @@ #ifndef DORIS_BE_SRC_AGENT_UTILS_H #define DORIS_BE_SRC_AGENT_UTILS_H -#include <pthread.h> -#include <memory> -#include "thrift/transport/TSocket.h" -#include "thrift/transport/TTransportUtils.h" #include "agent/status.h" -#include "gen_cpp/BackendService.h" #include "gen_cpp/FrontendService.h" -#include "gen_cpp/AgentService_types.h" +#include "gen_cpp/FrontendService_types.h" #include "gen_cpp/HeartbeatService_types.h" -#include "gen_cpp/Status_types.h" -#include "gen_cpp/Types_types.h" -#include "olap/olap_define.h" #include "runtime/client_cache.h" namespace doris { @@ -38,7 +30,7 @@ class MasterServerClient { public: MasterServerClient(const TMasterInfo& master_info, FrontendServiceClientCache* client_cache); virtual ~MasterServerClient() {}; - + // Reprot finished task to the master server // // Input parameters: @@ -47,7 +39,7 @@ public: // Output parameters: // * result: The result of report task virtual AgentStatus finish_task(const TFinishTaskRequest& request, TMasterResult* result); - + // Report tasks/olap tablet/disk state to the master server // // Input parameters: @@ -58,11 +50,12 @@ public: virtual AgentStatus report(const TReportRequest& request, TMasterResult* result); private: - const TMasterInfo& _master_info; + DISALLOW_COPY_AND_ASSIGN(MasterServerClient); + // Not ownder. Reference to the ExecEnv::_master_info + const TMasterInfo& _master_info; FrontendServiceClientCache* _client_cache; - DISALLOW_COPY_AND_ASSIGN(MasterServerClient); -}; // class MasterServerClient +}; class AgentUtils { public: diff --git a/be/src/olap/task/engine_clone_task.cpp b/be/src/olap/task/engine_clone_task.cpp index 477c756..aece472 100644 --- a/be/src/olap/task/engine_clone_task.cpp +++ b/be/src/olap/task/engine_clone_task.cpp @@ -19,6 +19,9 @@ #include <set> +#include "env/env.h" +#include "gen_cpp/Types_constants.h" +#include "gen_cpp/BackendService.h" #include "gutil/strings/stringpiece.h" #include "gutil/strings/split.h" #include "gutil/strings/substitute.h" @@ -28,12 +31,9 @@ #include "olap/snapshot_manager.h" #include "olap/rowset/rowset.h" #include "olap/rowset/rowset_factory.h" +#include "runtime/client_cache.h" #include "util/thrift_rpc_helper.h" -#include "env/env.h" - -#include "gen_cpp/Types_constants.h" - using std::set; using std::stringstream; using strings::Substitute; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org