Used the network util in DataExchanger.
Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/c886f7af Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/c886f7af Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/c886f7af Branch: refs/heads/exact-filter Commit: c886f7af5835a8577f516b2c7a39692d18d5b9b2 Parents: 8f1b0e5 Author: Zuyu Zhang <zu...@apache.org> Authored: Sun Nov 13 15:55:31 2016 -0800 Committer: Zuyu Zhang <zu...@apache.org> Committed: Sun Nov 20 20:08:27 2016 -0800 ---------------------------------------------------------------------- storage/CMakeLists.txt | 1 + storage/DataExchangerAsync.cpp | 9 +++++---- storage/DataExchangerAsync.hpp | 2 -- 3 files changed, 6 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c886f7af/storage/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/storage/CMakeLists.txt b/storage/CMakeLists.txt index 559d86d..61a8a99 100644 --- a/storage/CMakeLists.txt +++ b/storage/CMakeLists.txt @@ -625,6 +625,7 @@ if (ENABLE_DISTRIBUTED) quickstep_storage_StorageManager quickstep_threading_Thread quickstep_utility_Macros + quickstep_utility_NetworkUtil ${GRPCPLUSPLUS_LIBRARIES}) endif() http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c886f7af/storage/DataExchangerAsync.cpp ---------------------------------------------------------------------- diff --git a/storage/DataExchangerAsync.cpp b/storage/DataExchangerAsync.cpp index 1d2f7db..d349430 100644 --- a/storage/DataExchangerAsync.cpp +++ b/storage/DataExchangerAsync.cpp @@ -28,6 +28,7 @@ #include "storage/DataExchange.grpc.pb.h" #include "storage/DataExchange.pb.h" #include "storage/StorageManager.hpp" +#include "utility/NetworkUtil.hpp" #include "glog/logging.h" @@ -127,18 +128,18 @@ void CallContext::Proceed() { } // namespace -const char *DataExchangerAsync::kLocalNetworkAddress = "0.0.0.0:"; - DataExchangerAsync::DataExchangerAsync() { + const std::string ipv4_address(GetIpv4Address() + ':'); + grpc::ServerBuilder builder; - builder.AddListeningPort(kLocalNetworkAddress, grpc::InsecureServerCredentials(), &port_); + builder.AddListeningPort(ipv4_address, grpc::InsecureServerCredentials(), &port_); builder.RegisterService(&service_); queue_ = builder.AddCompletionQueue(); server_ = builder.BuildAndStart(); DCHECK_GT(port_, 0); - server_address_ = kLocalNetworkAddress + std::to_string(port_); + server_address_ = ipv4_address + std::to_string(port_); LOG(INFO) << "DataExchangerAsync Service listening on " << server_address_; } http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/c886f7af/storage/DataExchangerAsync.hpp ---------------------------------------------------------------------- diff --git a/storage/DataExchangerAsync.hpp b/storage/DataExchangerAsync.hpp index b777108..4504c08 100644 --- a/storage/DataExchangerAsync.hpp +++ b/storage/DataExchangerAsync.hpp @@ -79,8 +79,6 @@ class DataExchangerAsync final : public Thread { void run() override; private: - static const char *kLocalNetworkAddress; - DataExchange::AsyncService service_; int port_ = -1;