diff options
author | brutalman <brutalman@yandex-team.ru> | 2022-02-10 16:52:07 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:52:07 +0300 |
commit | 23c799716c9f913b096312f8ea4e90b14b271e53 (patch) | |
tree | ab7fbbf3253d4c0e2793218f09378908beb025fb | |
parent | 33a36fa4bfa78e09ac7d34729ff62e5c6148e104 (diff) | |
download | ydb-23c799716c9f913b096312f8ea4e90b14b271e53.tar.gz |
Restoring authorship annotation for <brutalman@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | util/generic/hash.pxd | 62 | ||||
-rw-r--r-- | ydb/core/client/client_ut.cpp | 2 | ||||
-rw-r--r-- | ydb/core/client/server/msgbus_server_request.cpp | 2 | ||||
-rw-r--r-- | ydb/core/testlib/test_client.cpp | 92 | ||||
-rw-r--r-- | ydb/core/testlib/test_client.h | 34 | ||||
-rw-r--r-- | ydb/core/testlib/ya.make | 4 | ||||
-rw-r--r-- | ydb/public/lib/deprecated/client/msgbus_client.cpp | 82 | ||||
-rw-r--r-- | ydb/public/lib/deprecated/client/msgbus_client.h | 8 |
8 files changed, 143 insertions, 143 deletions
diff --git a/util/generic/hash.pxd b/util/generic/hash.pxd index 740edf9606..385c10d805 100644 --- a/util/generic/hash.pxd +++ b/util/generic/hash.pxd @@ -1,17 +1,17 @@ -from libcpp.pair cimport pair - -cdef extern from "util/generic/hash.h" nogil: +from libcpp.pair cimport pair + +cdef extern from "util/generic/hash.h" nogil: cdef cppclass THashMap[T, U]: - cppclass iterator: - pair[T, U]& operator*() - iterator operator++() - iterator operator--() - bint operator==(iterator) - bint operator!=(iterator) - - cppclass const_iterator(iterator): - pass - + cppclass iterator: + pair[T, U]& operator*() + iterator operator++() + iterator operator--() + bint operator==(iterator) + bint operator!=(iterator) + + cppclass const_iterator(iterator): + pass + cppclass reverse_iterator: pair[T, U]& operator*() iterator operator++() @@ -24,35 +24,35 @@ cdef extern from "util/generic/hash.h" nogil: THashMap() except + THashMap(THashMap&) except + - U& operator[](T&) + U& operator[](T&) THashMap& operator=(THashMap&) - + bint operator==(THashMap&) bint operator!=(THashMap&) bint operator<(THashMap&) bint operator>(THashMap&) bint operator<=(THashMap&) bint operator>=(THashMap&) - + U& at(T&) except + - iterator begin() - const_iterator const_begin "begin"() - void clear() - size_t count(T&) - bint empty() - iterator end() - const_iterator const_end "end"() - pair[iterator, iterator] equal_range(T&) + iterator begin() + const_iterator const_begin "begin"() + void clear() + size_t count(T&) + bint empty() + iterator end() + const_iterator const_end "end"() + pair[iterator, iterator] equal_range(T&) void erase(iterator) except + void erase(iterator, iterator) except + - size_t erase(T&) - iterator find(T&) + size_t erase(T&) + iterator find(T&) bint contains(T&) - const_iterator const_find "find"(T&) - pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]& - iterator insert(iterator, pair[T, U]) # XXX pair[T,U]& - size_t max_size() - size_t size() + const_iterator const_find "find"(T&) + pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]& + iterator insert(iterator, pair[T, U]) # XXX pair[T,U]& + size_t max_size() + size_t size() void swap(THashMap&) iterator lower_bound(T&) const_iterator const_lower_bound "lower_bound"(T&) diff --git a/ydb/core/client/client_ut.cpp b/ydb/core/client/client_ut.cpp index cfb2564813..b94c722588 100644 --- a/ydb/core/client/client_ut.cpp +++ b/ydb/core/client/client_ut.cpp @@ -25,7 +25,7 @@ namespace NKikimr { using NClient::TValue; -namespace Tests { +namespace Tests { using namespace NMiniKQL; // const ui32 TestDomain = 1; diff --git a/ydb/core/client/server/msgbus_server_request.cpp b/ydb/core/client/server/msgbus_server_request.cpp index 63796a8061..9223bea9f1 100644 --- a/ydb/core/client/server/msgbus_server_request.cpp +++ b/ydb/core/client/server/msgbus_server_request.cpp @@ -294,7 +294,7 @@ void TMessageBusServerRequest::Handle(TEvTxUserProxy::TEvProposeTransactionStatu return ReplyWithResult(MSTATUS_INPROGRESS, msg->Record, ctx); case TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ProxyNotReady: return HandleError(MSTATUS_NOTREADY, status, ctx); - case TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecAborted: + case TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecAborted: return HandleError(MSTATUS_ABORTED, status, ctx); case TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::EmptyAffectedSet: case TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecError: diff --git a/ydb/core/testlib/test_client.cpp b/ydb/core/testlib/test_client.cpp index 7900dac35e..d4907c26f1 100644 --- a/ydb/core/testlib/test_client.cpp +++ b/ydb/core/testlib/test_client.cpp @@ -1,4 +1,4 @@ -#include "test_client.h" +#include "test_client.h" #include <ydb/core/testlib/basics/runtime.h> #include <ydb/core/base/appdata.h> @@ -97,9 +97,9 @@ #include <util/system/valgrind.h> #include <util/system/env.h> -namespace NKikimr { - -namespace Tests { +namespace NKikimr { + +namespace Tests { @@ -120,7 +120,7 @@ namespace Tests { NValgrind::PlainOrUnderValgrind(TDuration::Seconds(60), TDuration::Seconds(120)), TDuration::Seconds(120) ).MilliSeconds(); - + NMiniKQL::IFunctionRegistry* DefaultFrFactory(const NScheme::TTypeRegistry& typeRegistry) { Y_UNUSED(typeRegistry); // register test UDFs @@ -140,7 +140,7 @@ namespace Tests { TServer::TServer(TServerSettings::TConstPtr settings, bool init) : Settings(settings) , UseStoragePools(!Settings->StoragePoolTypes.empty()) - { + { if (Settings->SupportsRedirect && IsServerRedirected()) return; @@ -357,7 +357,7 @@ namespace Tests { Settings->StoragePoolTypes); app.AddDomain(domain.Release()); } - + void TServer::CreateBootstrapTablets() { const ui32 domainId = Settings->Domain; Y_VERIFY(TDomainsInfo::MakeTxAllocatorIDFixed(domainId, 1) == ChangeStateStorage(TxAllocator, domainId)); @@ -848,8 +848,8 @@ namespace Tests { if (Settings->LoggerInitializer) { Settings->LoggerInitializer(*Runtime); } - } - + } + void TServer::StartDummyTablets() { if (!Runtime) ythrow TWithBackTrace<yexception>() << "Server is redirected"; @@ -891,9 +891,9 @@ namespace Tests { Bus->Stop(); Bus.Drop(); } - } - - + } + + TClient::TClient(const TServerSettings& settings) : Domain(settings.Domain) , DomainName(settings.DomainName) @@ -915,26 +915,26 @@ namespace Tests { ClientConfig.BusSessionConfig.ConnectTimeout = ConnectTimeoutMilliSeconds; ClientConfig.BusSessionConfig.NumRetries = 10; Client.reset(new NMsgBusProxy::TMsgBusClient(ClientConfig)); - Client->Init(); - } - - const NMsgBusProxy::TMsgBusClientConfig& TClient::GetClientConfig() const { - return ClientConfig; - } - - TClient::~TClient() { - Client->Shutdown(); - } - - + Client->Init(); + } + + const NMsgBusProxy::TMsgBusClientConfig& TClient::GetClientConfig() const { + return ClientConfig; + } + + TClient::~TClient() { + Client->Shutdown(); + } + + std::shared_ptr<NMsgBusProxy::TMsgBusClient> TClient::GetClient() const { - return Client; - } - + return Client; + } + const NScheme::TTypeRegistry& TClient::GetTypeRegistry() const { - return TypeRegistry; - } - + return TypeRegistry; + } + bool TClient::LoadTypes() { TAutoPtr<NMsgBusProxy::TBusTypesRequest> request(new NMsgBusProxy::TBusTypesRequest()); if (TypesEtag.Defined()) { @@ -971,26 +971,26 @@ namespace Tests { return *FunctionRegistry; } - ui64 TClient::GetPatchedSchemeRoot(ui64 schemeRoot, ui32 domain, bool supportsRedirect) { - if (!supportsRedirect || !IsServerRedirected()) + ui64 TClient::GetPatchedSchemeRoot(ui64 schemeRoot, ui32 domain, bool supportsRedirect) { + if (!supportsRedirect || !IsServerRedirected()) return ChangeStateStorage(schemeRoot, domain); TString domainRedirect = GetEnv(DomainRedirectEnvVar); - if (!domainRedirect) - ythrow TWithBackTrace<yexception>() << "Please set domain redirect, format: KIKIMR_TEST_DOMAIN=domain/RootShardTabletId"; + if (!domainRedirect) + ythrow TWithBackTrace<yexception>() << "Please set domain redirect, format: KIKIMR_TEST_DOMAIN=domain/RootShardTabletId"; - TStringBuf domainUidStr; - TStringBuf tabletIdStr; - TStringBuf(domainRedirect).Split('/', domainUidStr, tabletIdStr); - const ui32 domainUid = FromString<ui32>(domainUidStr); - if (domainUid != domain) { - ythrow TWithBackTrace<yexception>() << "Mismatch domain redirect, expected domain: " << domain - << ", redirected domain: " << domainUid; + TStringBuf domainUidStr; + TStringBuf tabletIdStr; + TStringBuf(domainRedirect).Split('/', domainUidStr, tabletIdStr); + const ui32 domainUid = FromString<ui32>(domainUidStr); + if (domainUid != domain) { + ythrow TWithBackTrace<yexception>() << "Mismatch domain redirect, expected domain: " << domain + << ", redirected domain: " << domainUid; } - return FromString<ui64>(tabletIdStr); - } - + return FromString<ui64>(tabletIdStr); + } + void TClient::WaitRootIsUp(const TString& root) { while (true) { TAutoPtr<NMsgBusProxy::TBusResponse> resp = Ls(root); @@ -2476,5 +2476,5 @@ namespace Tests { } -} -} +} +} diff --git a/ydb/core/testlib/test_client.h b/ydb/core/testlib/test_client.h index 26a6efe036..2064752ab4 100644 --- a/ydb/core/testlib/test_client.h +++ b/ydb/core/testlib/test_client.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "tablet_helpers.h" #include <ydb/core/base/appdata.h> @@ -29,10 +29,10 @@ #include <functional> #include <algorithm> - -namespace NKikimr { -namespace Tests { - + +namespace NKikimr { +namespace Tests { + #ifdef WITH_VALGRIND const ui64 TIME_LIMIT_MS = TDuration::Seconds(600).MilliSeconds(); #else @@ -53,7 +53,7 @@ namespace Tests { const ui64 TxAllocator = 0x820001; const ui64 SchemeRoot = 0x850100; const ui64 Hive = 0xA001; - + struct TServerSetup { TString IpAddress; ui16 Port = 0; @@ -260,8 +260,8 @@ namespace Tests { TIntrusivePtr<NMonitoring::TDynamicCounters> GRpcServerRootCounters; }; - class TClient { - public: + class TClient { + public: struct TFlatQueryOptions { TString Params; bool IsQueryCompiled = false; @@ -277,11 +277,11 @@ namespace Tests { TClient(const TServerSettings& settings); virtual ~TClient(); - - const NMsgBusProxy::TMsgBusClientConfig& GetClientConfig() const; + + const NMsgBusProxy::TMsgBusClientConfig& GetClientConfig() const; std::shared_ptr<NMsgBusProxy::TMsgBusClient> GetClient() const; bool LoadTypes(); - const NScheme::TTypeRegistry& GetTypeRegistry() const; + const NScheme::TTypeRegistry& GetTypeRegistry() const; const NScheme::TTypeMetadataRegistry& GetTypeMetadataRegistry() const; const NMiniKQL::IFunctionRegistry& GetFunctionRegistry() const; @@ -337,7 +337,7 @@ namespace Tests { TAutoPtr<NBus::TBusMessage> InitRootSchemeWithReply(const TString& root); void InitRootScheme(); void InitRootScheme(const TString& root); - + void ExecuteTraceCommand(NKikimrClient::TMessageBusTraceRequest::ECommand command, const TString &path = TString()); TString StartTrace(const TString &path); void StopTrace(); @@ -513,14 +513,14 @@ namespace Tests { const TStoragePoolKinds StoragePoolTypes; NScheme::TKikimrTypeRegistry TypeRegistry; TIntrusivePtr<NMiniKQL::IFunctionRegistry> FunctionRegistry; - NMsgBusProxy::TMsgBusClientConfig ClientConfig; + NMsgBusProxy::TMsgBusClientConfig ClientConfig; std::shared_ptr<NMsgBusProxy::TMsgBusClient> Client; TMaybe<ui64> TypesEtag; NScheme::TTypeMetadataRegistry LoadedTypeMetadataRegistry; TIntrusivePtr<NMiniKQL::IFunctionRegistry> LoadedFunctionRegistry; TString SecurityToken; - }; - + }; + struct TTenants { private: Tests::TServer::TPtr Server; @@ -560,5 +560,5 @@ namespace Tests { void FreeNodeIdx(ui32 nodeIdx); }; -} -} +} +} diff --git a/ydb/core/testlib/ya.make b/ydb/core/testlib/ya.make index b7a03ce60f..137fa829f3 100644 --- a/ydb/core/testlib/ya.make +++ b/ydb/core/testlib/ya.make @@ -20,8 +20,8 @@ SRCS( tablet_helpers.h tenant_runtime.cpp tenant_runtime.h - test_client.cpp - test_client.h + test_client.cpp + test_client.h service_mocks/access_service_mock.h service_mocks/datastreams_service_mock.h service_mocks/iam_token_service_mock.h diff --git a/ydb/public/lib/deprecated/client/msgbus_client.cpp b/ydb/public/lib/deprecated/client/msgbus_client.cpp index d8490740de..4d5f2427eb 100644 --- a/ydb/public/lib/deprecated/client/msgbus_client.cpp +++ b/ydb/public/lib/deprecated/client/msgbus_client.cpp @@ -33,20 +33,20 @@ void TMsgBusClientConfig::CrackAddress(const TString& address, TString& hostname -struct TMessageCookie -{ - virtual void Signal(TAutoPtr<NBus::TBusMessage>& msg, NBus::EMessageStatus errorStatus, TAutoPtr<NBus::TBusMessage> reply) = 0; - virtual ~TMessageCookie() - { - } -}; - -struct TSyncMessageCookie : public TMessageCookie { - TAutoPtr<NBus::TBusMessage> Reply; - NBus::EMessageStatus ErrorStatus = NBus::MESSAGE_UNKNOWN; +struct TMessageCookie +{ + virtual void Signal(TAutoPtr<NBus::TBusMessage>& msg, NBus::EMessageStatus errorStatus, TAutoPtr<NBus::TBusMessage> reply) = 0; + virtual ~TMessageCookie() + { + } +}; + +struct TSyncMessageCookie : public TMessageCookie { + TAutoPtr<NBus::TBusMessage> Reply; + NBus::EMessageStatus ErrorStatus = NBus::MESSAGE_UNKNOWN; TManualEvent Ev; - TSyncMessageCookie() + TSyncMessageCookie() : Ev() {} @@ -54,42 +54,42 @@ struct TSyncMessageCookie : public TMessageCookie { Ev.Wait(); } - virtual void Signal(TAutoPtr<NBus::TBusMessage>& msg, NBus::EMessageStatus errorStatus, TAutoPtr<NBus::TBusMessage> reply) { + virtual void Signal(TAutoPtr<NBus::TBusMessage>& msg, NBus::EMessageStatus errorStatus, TAutoPtr<NBus::TBusMessage> reply) { Y_UNUSED(msg.Release()); - ErrorStatus = errorStatus; - Reply = reply; + ErrorStatus = errorStatus; + Reply = reply; Ev.Signal(); } }; - + template <typename CallbackType> -struct TAsyncMessageCookie : public TMessageCookie { +struct TAsyncMessageCookie : public TMessageCookie { CallbackType Callback; void* Data; - + explicit TAsyncMessageCookie(CallbackType callback, void* data) - : Callback(callback) + : Callback(callback) , Data(data) - {} - + {} + void Signal(TAutoPtr<NBus::TBusMessage>& msg, NBus::EMessageStatus errorStatus, TAutoPtr<NBus::TBusMessage> reply) override; -}; - +}; + template <> void TAsyncMessageCookie<TMsgBusClient::TOnCall>::Signal(TAutoPtr<NBus::TBusMessage>& msg, NBus::EMessageStatus errorStatus, TAutoPtr<NBus::TBusMessage> reply) { msg->Data = Data; Callback(errorStatus, reply); delete this; // we must cleanup cookie after use } - + template <> void TAsyncMessageCookie<TMsgBusClient::TOnCallWithRequest>::Signal(TAutoPtr<NBus::TBusMessage>& msg, NBus::EMessageStatus errorStatus, TAutoPtr<NBus::TBusMessage> reply) { msg->Data = Data; Callback(errorStatus, msg, reply); delete this; // we must cleanup cookie after use } - + TMsgBusClientConfig::TMsgBusClientConfig() : Ip("localhost") @@ -130,7 +130,7 @@ void TMsgBusClient::Shutdown() { NBus::EMessageStatus TMsgBusClient::SyncCall(TAutoPtr<NBus::TBusMessage> msg, TAutoPtr<NBus::TBusMessage> &reply) { Y_VERIFY(!msg->Data); - TAutoPtr<TSyncMessageCookie> cookie(new TSyncMessageCookie()); + TAutoPtr<TSyncMessageCookie> cookie(new TSyncMessageCookie()); msg->Data = cookie.Get(); // msgbus would recreate second TAutoPtr for our msg pointer (wut?!) Second copy terminates in OnRelease/OnError where we release it. @@ -145,24 +145,24 @@ NBus::EMessageStatus TMsgBusClient::SyncCall(TAutoPtr<NBus::TBusMessage> msg, TA } } -NBus::EMessageStatus TMsgBusClient::AsyncCall(TAutoPtr<NBus::TBusMessage> msg, TOnCall callback) { +NBus::EMessageStatus TMsgBusClient::AsyncCall(TAutoPtr<NBus::TBusMessage> msg, TOnCall callback) { TAutoPtr<TMessageCookie> cookie(new TAsyncMessageCookie<TOnCall>(callback, msg->Data)); - msg->Data = cookie.Get(); + msg->Data = cookie.Get(); if (Config.UseCompression) { msg->SetCompressed(true); msg->SetCompressedResponse(true); } - NBus::EMessageStatus status = Session->SendMessage(msg.Get(), NetAddr.Get(), false); + NBus::EMessageStatus status = Session->SendMessage(msg.Get(), NetAddr.Get(), false); if (status == NBus::MESSAGE_OK) { // would be destructed in onresult/onerror Y_UNUSED(cookie.Release()); Y_UNUSED(msg.Release()); } - - return status; + + return status; } NBus::EMessageStatus TMsgBusClient::AsyncCall(TAutoPtr<NBus::TBusMessage> msg, TOnCallWithRequest callback) { @@ -186,18 +186,18 @@ NBus::EMessageStatus TMsgBusClient::AsyncCall(TAutoPtr<NBus::TBusMessage> msg, T } void TMsgBusClient::OnResult(TAutoPtr<NBus::TBusMessage> pMessage, NBus::EMessageStatus status, TAutoPtr<NBus::TBusMessage> pReply) { - static_cast<TMessageCookie*>(pMessage->Data)->Signal(pMessage, status, pReply); -} - -void TMsgBusClient::OnReply(TAutoPtr<NBus::TBusMessage> pMessage, TAutoPtr<NBus::TBusMessage> pReply) { + static_cast<TMessageCookie*>(pMessage->Data)->Signal(pMessage, status, pReply); +} + +void TMsgBusClient::OnReply(TAutoPtr<NBus::TBusMessage> pMessage, TAutoPtr<NBus::TBusMessage> pReply) { OnResult(pMessage, NBus::MESSAGE_OK, pReply); -} - +} + void TMsgBusClient::OnError(TAutoPtr<NBus::TBusMessage> pMessage, NBus::EMessageStatus status) { if (status == NBus::MESSAGE_UNKNOWN) // timeouted request return; - OnResult(pMessage, status, TAutoPtr<NBus::TBusMessage>()); + OnResult(pMessage, status, TAutoPtr<NBus::TBusMessage>()); } const TMsgBusClientConfig& TMsgBusClient::GetConfig() { @@ -205,10 +205,10 @@ const TMsgBusClientConfig& TMsgBusClient::GetConfig() { } EDataReqStatusExcerpt ExtractDataRequestStatus(const NKikimrClient::TResponse *record) { - if (!record) + if (!record) return EDataReqStatusExcerpt::Unknown; - - switch (record->GetStatus()) { + + switch (record->GetStatus()) { case MSTATUS_OK: return EDataReqStatusExcerpt::Complete; case MSTATUS_INPROGRESS: diff --git a/ydb/public/lib/deprecated/client/msgbus_client.h b/ydb/public/lib/deprecated/client/msgbus_client.h index 8012b27616..7d721946d8 100644 --- a/ydb/public/lib/deprecated/client/msgbus_client.h +++ b/ydb/public/lib/deprecated/client/msgbus_client.h @@ -21,19 +21,19 @@ class TMsgBusClient : NBus::IBusClientHandler { private: void OnReply(TAutoPtr<NBus::TBusMessage> pMessage, TAutoPtr<NBus::TBusMessage> pReply) override; void OnError(TAutoPtr<NBus::TBusMessage> pMessage, NBus::EMessageStatus status) override; - void OnResult(TAutoPtr<NBus::TBusMessage> pMessage, NBus::EMessageStatus status, TAutoPtr<NBus::TBusMessage> pReply); - + void OnResult(TAutoPtr<NBus::TBusMessage> pMessage, NBus::EMessageStatus status, TAutoPtr<NBus::TBusMessage> pReply); + public: typedef std::function<void (NBus::EMessageStatus status, TAutoPtr<NBus::TBusMessage> reply)> TOnCall; typedef std::function<void (NBus::EMessageStatus status, TAutoPtr<NBus::TBusMessage> message, TAutoPtr<NBus::TBusMessage> reply)> TOnCallWithRequest; - + TMsgBusClient(const TMsgBusClientConfig &config); ~TMsgBusClient(); NBus::EMessageStatus SyncCall(TAutoPtr<NBus::TBusMessage> msg, TAutoPtr<NBus::TBusMessage> &reply); - NBus::EMessageStatus AsyncCall(TAutoPtr<NBus::TBusMessage> msg, TOnCall callback); + NBus::EMessageStatus AsyncCall(TAutoPtr<NBus::TBusMessage> msg, TOnCall callback); NBus::EMessageStatus AsyncCall(TAutoPtr<NBus::TBusMessage> msg, TOnCallWithRequest callback); void Init(); void Shutdown(); |