diff options
author | hor911 <hor911@ydb.tech> | 2022-09-29 12:37:49 +0300 |
---|---|---|
committer | hor911 <hor911@ydb.tech> | 2022-09-29 12:37:49 +0300 |
commit | f0dccf23552f6620c69d0533c0ef596dbcb2e18e (patch) | |
tree | 2bf83ee50f5eecb589dec7d8843715ed76f99f9e | |
parent | 415be0d1a1a30e2256bbf072fcec6c81cce8d706 (diff) | |
download | ydb-f0dccf23552f6620c69d0533c0ef596dbcb2e18e.tar.gz |
Pre resolve self address for discovery
-rw-r--r-- | library/cpp/actors/interconnect/interconnect_resolve.cpp | 11 | ||||
-rw-r--r-- | ydb/core/yq/libs/actors/nodes_manager.cpp | 25 |
2 files changed, 34 insertions, 2 deletions
diff --git a/library/cpp/actors/interconnect/interconnect_resolve.cpp b/library/cpp/actors/interconnect/interconnect_resolve.cpp index 9d245f03ac..d638ff830c 100644 --- a/library/cpp/actors/interconnect/interconnect_resolve.cpp +++ b/library/cpp/actors/interconnect/interconnect_resolve.cpp @@ -1,6 +1,7 @@ #include "interconnect.h" #include "interconnect_address.h" #include "events_local.h" +#include "logging.h" #include <library/cpp/actors/core/actor_bootstrapped.h> #include <library/cpp/actors/core/hfunc.h> @@ -10,7 +11,10 @@ namespace NActors { using namespace NActors::NDnsResolver; - class TInterconnectResolveActor : public TActorBootstrapped<TInterconnectResolveActor> { + class TInterconnectResolveActor + : public TActorBootstrapped<TInterconnectResolveActor> + , public TInterconnectLoggingBase + { public: TInterconnectResolveActor( const TString& host, ui16 port, ui32 nodeId, const TString& defaultAddress, @@ -41,6 +45,7 @@ namespace NActors { void Bootstrap() { TMaybe<TString> errorText; if (auto addr = ExtractDefaultAddr(errorText)) { + LOG_TRACE_IC("ICR01", "Host: %s, CACHED address: %s", Host.c_str(), DefaultAddress.c_str()); if (NodeId) { return SendLocalNodeInfoAndDie({{*addr}}); } else { @@ -58,6 +63,7 @@ namespace NActors { return; } + LOG_DEBUG_IC("ICR02", "Host: %s, RESOLVING address ...", Host.c_str()); Send(MakeDnsResolverActorId(), NodeId ? static_cast<IEventBase*>(new TEvDns::TEvGetHostByName(Host, AF_UNSPEC)) @@ -111,6 +117,7 @@ namespace NActors { } void SendAddressInfoAndDie(NAddr::IRemoteAddrPtr addr) { + LOG_DEBUG_IC("ICR03", "Host: %s, RESOLVED address", Host.c_str()); auto reply = new TEvAddressInfo; reply->Address = std::move(addr); TActivationContext::Send(new IEventHandle(ReplyTo, ReplyFrom, reply)); @@ -118,6 +125,7 @@ namespace NActors { } void SendLocalNodeInfoAndDie(std::vector<NInterconnect::TAddress> addresses) { + LOG_DEBUG_IC("ICR04", "Host: %s, RESOLVED address", Host.c_str()); auto reply = std::make_unique<TEvLocalNodeInfo>(); reply->NodeId = *NodeId; reply->Addresses = std::move(addresses); @@ -126,6 +134,7 @@ namespace NActors { } void SendErrorAndDie(const TString& errorText) { + LOG_DEBUG_IC("ICR05", "Host: %s, ERROR resolving: %s", Host.c_str(), errorText.c_str()); auto *event = new TEvResolveError; event->Explain = errorText; event->Host = Host; diff --git a/ydb/core/yq/libs/actors/nodes_manager.cpp b/ydb/core/yq/libs/actors/nodes_manager.cpp index 746934c5de..9ebdd7f6f2 100644 --- a/ydb/core/yq/libs/actors/nodes_manager.cpp +++ b/ydb/core/yq/libs/actors/nodes_manager.cpp @@ -4,6 +4,7 @@ #include <library/cpp/actors/core/events.h> #include <library/cpp/actors/core/hfunc.h> #include <library/cpp/actors/core/actor_bootstrapped.h> +#include <library/cpp/actors/interconnect/events_local.h> #include <ydb/library/yql/providers/dq/worker_manager/interface/events.h> #include <ydb/library/yql/public/issue/yql_issue_message.h> #include <ydb/public/sdk/cpp/client/ydb_driver/driver.h> @@ -76,7 +77,7 @@ public: Become(&TNodesManagerActor::StateFunc); ServiceCounters.Counters->GetCounter("EvBootstrap", true)->Inc(); LOG_I("Bootstrap, InstanceId: " << InstanceId); - NodesHealthCheck(); + ResolveSelfAddress(); } private: @@ -176,6 +177,7 @@ private: hFunc(NDqs::TEvFreeWorkersNotify, Handle) hFunc(NActors::TEvents::TEvUndelivered, OnUndelivered) hFunc(NFq::TEvInternalService::TEvHealthCheckResponse, HandleResponse) + hFunc(NActors::TEvAddressInfo, Handle) ) void HandleWakeup(NActors::TEvents::TEvWakeup::TPtr& ev) { @@ -188,7 +190,26 @@ private: } } + void Handle(NActors::TEvAddressInfo::TPtr& ev) { + if (ev->Get()->Address) { + Address = NAddr::PrintHost(*ev->Get()->Address); + NodesHealthCheck(); + } else { + LOG_E("TNodesManagerActor error resolving"); + ResolveSelfAddress(); + } + } + + void ResolveSelfAddress() { + LOG_D("TNodesManagerActor::ResolveSelfAddress"); + auto resolve = MakeHolder<NActors::TEvResolveAddress>(); + resolve->Address = HostName(); + resolve->Port = IcPort; + Send(GetNameserviceActorId(), resolve.Release()); + } + void NodesHealthCheck() { + LOG_T("TNodesManagerActor::NodesHealthCheck"); const TDuration ttl = TDuration::Seconds(5); Schedule(ttl, new NActors::TEvents::TEvWakeup(WU_NodesHealthCheck)); @@ -200,6 +221,7 @@ private: node.set_node_id(SelfId().NodeId()); node.set_instance_id(InstanceId); node.set_hostname(HostName()); + node.set_node_address(Address); node.set_active_workers(AtomicGet(WorkerManagerCounters.ActiveWorkers->GetAtomic())); node.set_memory_limit(AtomicGet(WorkerManagerCounters.MkqlMemoryLimit->GetAtomic())); node.set_memory_allocated(AtomicGet(WorkerManagerCounters.MkqlMemoryAllocated->GetAtomic())); @@ -292,6 +314,7 @@ private: ui32 NextPeer = 0; TString InstanceId; TActorId InternalServiceId; + TString Address; }; TActorId MakeNodesManagerId() { |