diff options
author | ienkovich <ienkovich@yandex-team.ru> | 2022-02-10 16:47:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:49 +0300 |
commit | 5bd76e73fa8dd777999be2668ff56928cc3dbecb (patch) | |
tree | cee73b6c84f7566d11209bd978e29a7fd9ccec54 /library/cpp | |
parent | b031b9d140bcd39f4ef2764e24d37bee317aaf23 (diff) | |
download | ydb-5bd76e73fa8dd777999be2668ff56928cc3dbecb.tar.gz |
Restoring authorship annotation for <ienkovich@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/actors/core/hfunc.h | 6 | ||||
-rw-r--r-- | library/cpp/actors/core/interconnect.h | 100 | ||||
-rw-r--r-- | library/cpp/actors/core/log_settings.h | 4 | ||||
-rw-r--r-- | library/cpp/actors/interconnect/interconnect_nameserver_table.cpp | 34 | ||||
-rw-r--r-- | library/cpp/actors/testlib/test_runtime.cpp | 8 | ||||
-rw-r--r-- | library/cpp/actors/testlib/test_runtime.h | 32 | ||||
-rw-r--r-- | library/cpp/monlib/dynamic_counters/counters.cpp | 54 | ||||
-rw-r--r-- | library/cpp/monlib/dynamic_counters/counters.h | 22 | ||||
-rw-r--r-- | library/cpp/monlib/dynamic_counters/counters_ut.cpp | 248 | ||||
-rw-r--r-- | library/cpp/monlib/service/service.cpp | 6 | ||||
-rw-r--r-- | library/cpp/monlib/service/service.h | 2 | ||||
-rw-r--r-- | library/cpp/packedtypes/zigzag.h | 4 |
12 files changed, 260 insertions, 260 deletions
diff --git a/library/cpp/actors/core/hfunc.h b/library/cpp/actors/core/hfunc.h index 26f3c65013..618c641fff 100644 --- a/library/cpp/actors/core/hfunc.h +++ b/library/cpp/actors/core/hfunc.h @@ -64,9 +64,9 @@ HandleFunc(ctx); \ break; -#define cFunc(TEventType, HandleFunc) \ - case TEventType: \ - HandleFunc(); \ +#define cFunc(TEventType, HandleFunc) \ + case TEventType: \ + HandleFunc(); \ break; #define FFunc(TEventType, HandleFunc) \ diff --git a/library/cpp/actors/core/interconnect.h b/library/cpp/actors/core/interconnect.h index 679a4b8cc6..662b22fdfc 100644 --- a/library/cpp/actors/core/interconnect.h +++ b/library/cpp/actors/core/interconnect.h @@ -128,9 +128,9 @@ namespace NActors { EvRegisterNodeResult, EvListNodes, EvNodesInfo, - EvDisconnect, - EvGetNode, - EvNodeInfo, + EvDisconnect, + EvGetNode, + EvNodeInfo, EvClosePeerSocket, EvCloseInputSession, EvPoisonSession, @@ -146,7 +146,7 @@ namespace NActors { static_assert(EvEnd < EventSpaceEnd(TEvents::ES_INTERCONNECT), "expect EvEnd < EventSpaceEnd(TEvents::ES_INTERCONNECT)"); struct TEvResolveNode; - struct TEvNodeAddress; + struct TEvNodeAddress; struct TEvConnectNode: public TEventBase<TEvConnectNode, EvConnectNode> { DEFINE_SIMPLE_LOCAL_EVENT(TEvConnectNode, "TEvInterconnect::TEvConnectNode") @@ -178,38 +178,38 @@ namespace NActors { struct TEvListNodes: public TEventLocal<TEvListNodes, EvListNodes> { }; - struct TNodeInfo { - ui32 NodeId; - TString Address; - TString Host; - TString ResolveHost; - ui16 Port; + struct TNodeInfo { + ui32 NodeId; + TString Address; + TString Host; + TString ResolveHost; + ui16 Port; TNodeLocation Location; TNodeInfo() = default; TNodeInfo(const TNodeInfo&) = default; TNodeInfo& operator =(const TNodeInfo&) = default; - TNodeInfo(ui32 nodeId, - const TString& address, - const TString& host, - const TString& resolveHost, - ui16 port, + TNodeInfo(ui32 nodeId, + const TString& address, + const TString& host, + const TString& resolveHost, + ui16 port, const TNodeLocation& location) - : NodeId(nodeId) - , Address(address) - , Host(host) - , ResolveHost(resolveHost) - , Port(port) - , Location(location) - { - } - - operator ui32() const { - return NodeId; - } - }; - - struct TEvNodesInfo: public TEventLocal<TEvNodesInfo, EvNodesInfo> { + : NodeId(nodeId) + , Address(address) + , Host(host) + , ResolveHost(resolveHost) + , Port(port) + , Location(location) + { + } + + operator ui32() const { + return NodeId; + } + }; + + struct TEvNodesInfo: public TEventLocal<TEvNodesInfo, EvNodesInfo> { TVector<TNodeInfo> Nodes; const TNodeInfo* GetNodeInfo(ui32 nodeId) const { @@ -220,29 +220,29 @@ namespace NActors { return nullptr; } }; - - struct TEvDisconnect; - - struct TEvGetNode: public TEventLocal<TEvGetNode, EvGetNode> { - ui32 NodeId; + + struct TEvDisconnect; + + struct TEvGetNode: public TEventLocal<TEvGetNode, EvGetNode> { + ui32 NodeId; TInstant Deadline; - + TEvGetNode(ui32 nodeId, TInstant deadline = TInstant::Max()) - : NodeId(nodeId) + : NodeId(nodeId) , Deadline(deadline) - { - } - }; - - struct TEvNodeInfo: public TEventLocal<TEvNodeInfo, EvNodeInfo> { - TEvNodeInfo(ui32 nodeId) - : NodeId(nodeId) - { - } - - ui32 NodeId; - THolder<TNodeInfo> Node; - }; + { + } + }; + + struct TEvNodeInfo: public TEventLocal<TEvNodeInfo, EvNodeInfo> { + TEvNodeInfo(ui32 nodeId) + : NodeId(nodeId) + { + } + + ui32 NodeId; + THolder<TNodeInfo> Node; + }; struct TEvClosePeerSocket : TEventLocal<TEvClosePeerSocket, EvClosePeerSocket> {}; diff --git a/library/cpp/actors/core/log_settings.h b/library/cpp/actors/core/log_settings.h index 7fe4504edd..4e2b45ae48 100644 --- a/library/cpp/actors/core/log_settings.h +++ b/library/cpp/actors/core/log_settings.h @@ -118,8 +118,8 @@ namespace NActors { return func(static_cast<T>(c)); } ); - } - + } + inline bool Satisfies(EPriority priority, EComponent component, ui64 sampleBy = 0) const { // by using Mask we don't get outside of array boundaries TComponentSettings settings = GetComponentSettings(component); diff --git a/library/cpp/actors/interconnect/interconnect_nameserver_table.cpp b/library/cpp/actors/interconnect/interconnect_nameserver_table.cpp index 43419bf70d..26e57f5156 100644 --- a/library/cpp/actors/interconnect/interconnect_nameserver_table.cpp +++ b/library/cpp/actors/interconnect/interconnect_nameserver_table.cpp @@ -48,34 +48,34 @@ namespace NActors { for (const auto& x : StaticNodeTable) infos.push_back(&x.second); - auto CompareAddressLambda = + auto CompareAddressLambda = [](const TNodeInfo* left, const TNodeInfo* right) { return left->Port == right->Port ? left->Address < right->Address : left->Port < right->Port; }; - Sort(infos, CompareAddressLambda); + Sort(infos, CompareAddressLambda); for (ui32 idx = 1, end = StaticNodeTable.size(); idx < end; ++idx) { const TNodeInfo* left = infos[idx - 1]; const TNodeInfo* right = infos[idx]; - if (left->Address && left->Address == right->Address && left->Port == right->Port) - return false; - } - - auto CompareHostLambda = - [](const TNodeInfo* left, const TNodeInfo* right) { - return left->Port == right->Port ? left->ResolveHost < right->ResolveHost : left->Port < right->Port; - }; - - Sort(infos, CompareHostLambda); - - for (ui32 idx = 1, end = StaticNodeTable.size(); idx < end; ++idx) { - const TNodeInfo* left = infos[idx - 1]; - const TNodeInfo* right = infos[idx]; - if (left->ResolveHost == right->ResolveHost && left->Port == right->Port) + if (left->Address && left->Address == right->Address && left->Port == right->Port) return false; } + auto CompareHostLambda = + [](const TNodeInfo* left, const TNodeInfo* right) { + return left->Port == right->Port ? left->ResolveHost < right->ResolveHost : left->Port < right->Port; + }; + + Sort(infos, CompareHostLambda); + + for (ui32 idx = 1, end = StaticNodeTable.size(); idx < end; ++idx) { + const TNodeInfo* left = infos[idx - 1]; + const TNodeInfo* right = infos[idx]; + if (left->ResolveHost == right->ResolveHost && left->Port == right->Port) + return false; + } + return true; } diff --git a/library/cpp/actors/testlib/test_runtime.cpp b/library/cpp/actors/testlib/test_runtime.cpp index 6fa25b9965..66b353d49d 100644 --- a/library/cpp/actors/testlib/test_runtime.cpp +++ b/library/cpp/actors/testlib/test_runtime.cpp @@ -815,9 +815,9 @@ namespace NActors { } void TTestActorRuntimeBase::AdvanceCurrentTime(TDuration duration) { - UpdateCurrentTime(GetCurrentTime() + duration); - } - + UpdateCurrentTime(GetCurrentTime() + duration); + } + TIntrusivePtr<ITimeProvider> TTestActorRuntimeBase::GetTimeProvider() { Y_VERIFY(!UseRealThreads); return TimeProvider; @@ -1650,7 +1650,7 @@ namespace NActors { common.Reset(new TInterconnectProxyCommon); common->NameserviceId = nameserviceId; common->MonCounters = interconnectCounters; - common->TechnicalSelfHostName = "::1"; + common->TechnicalSelfHostName = "::1"; if (!UseRealThreads) { common->Settings.DeadPeer = TDuration::Max(); diff --git a/library/cpp/actors/testlib/test_runtime.h b/library/cpp/actors/testlib/test_runtime.h index 26e3b45c98..b788acfb36 100644 --- a/library/cpp/actors/testlib/test_runtime.h +++ b/library/cpp/actors/testlib/test_runtime.h @@ -231,7 +231,7 @@ namespace NActors { TIntrusivePtr<ITimeProvider> GetTimeProvider(); TInstant GetCurrentTime() const; void UpdateCurrentTime(TInstant newTime); - void AdvanceCurrentTime(TDuration duration); + void AdvanceCurrentTime(TDuration duration); void AddLocalService(const TActorId& actorId, const TActorSetupCmd& cmd, ui32 nodeIndex = 0); virtual void Initialize(); ui32 GetNodeId(ui32 index = 0) const; @@ -269,21 +269,21 @@ namespace NActors { bool IsScheduleForActorEnabled(const TActorId& actorId) const; TIntrusivePtr<NMonitoring::TDynamicCounters> GetDynamicCounters(ui32 nodeIndex = 0); void SetupMonitoring(); - - template<typename T> - void AppendToLogSettings(NLog::EComponent minVal, NLog::EComponent maxVal, T func) { - Y_VERIFY(!IsInitialized); - - for (const auto& pair : Nodes) { - pair.second->LogSettings->Append(minVal, maxVal, func); - } - } - - TIntrusivePtr<NLog::TSettings> GetLogSettings(ui32 nodeIdx) - { - return Nodes[FirstNodeId + nodeIdx]->LogSettings; - } - + + template<typename T> + void AppendToLogSettings(NLog::EComponent minVal, NLog::EComponent maxVal, T func) { + Y_VERIFY(!IsInitialized); + + for (const auto& pair : Nodes) { + pair.second->LogSettings->Append(minVal, maxVal, func); + } + } + + TIntrusivePtr<NLog::TSettings> GetLogSettings(ui32 nodeIdx) + { + return Nodes[FirstNodeId + nodeIdx]->LogSettings; + } + TActorSystem* SingleSys() const; TActorSystem* GetAnyNodeActorSystem(); TActorSystem* GetActorSystem(ui32 nodeId); diff --git a/library/cpp/monlib/dynamic_counters/counters.cpp b/library/cpp/monlib/dynamic_counters/counters.cpp index 3635d87d0d..9e7a970267 100644 --- a/library/cpp/monlib/dynamic_counters/counters.cpp +++ b/library/cpp/monlib/dynamic_counters/counters.cpp @@ -102,17 +102,17 @@ THistogramPtr TDynamicCounters::FindNamedHistogram(const TString& name,const TSt return AsHistogramRef(FindNamedCounterImpl<THistogramCounter>(name, value)); } -void TDynamicCounters::RemoveCounter(const TString &value) { - RemoveNamedCounter("sensor", value); -} - -void TDynamicCounters::RemoveNamedCounter(const TString& name, const TString &value) { +void TDynamicCounters::RemoveCounter(const TString &value) { + RemoveNamedCounter("sensor", value); +} + +void TDynamicCounters::RemoveNamedCounter(const TString& name, const TString &value) { auto g = LockForUpdate("RemoveNamedCounter", name, value); if (const auto it = Counters.find({name, value}); it != Counters.end() && AsCounter(it->second)) { - Counters.erase(it); + Counters.erase(it); } -} - +} + TIntrusivePtr<TDynamicCounters> TDynamicCounters::GetSubgroup(const TString& name, const TString& value) { auto res = FindSubgroup(name, value); if (!res) { @@ -134,21 +134,21 @@ TIntrusivePtr<TDynamicCounters> TDynamicCounters::FindSubgroup(const TString& na return it != Counters.end() ? AsDynamicCounters(it->second) : nullptr; } -void TDynamicCounters::RemoveSubgroup(const TString& name, const TString& value) { +void TDynamicCounters::RemoveSubgroup(const TString& name, const TString& value) { auto g = LockForUpdate("RemoveSubgroup", name, value); if (const auto it = Counters.find({name, value}); it != Counters.end() && AsDynamicCounters(it->second)) { - Counters.erase(it); + Counters.erase(it); } -} - +} + void TDynamicCounters::ReplaceSubgroup(const TString& name, const TString& value, TIntrusivePtr<TDynamicCounters> subgroup) { auto g = LockForUpdate("ReplaceSubgroup", name, value); const auto it = Counters.find({name, value}); Y_VERIFY(it != Counters.end() && AsDynamicCounters(it->second)); it->second = std::move(subgroup); -} - -void TDynamicCounters::MergeWithSubgroup(const TString& name, const TString& value) { +} + +void TDynamicCounters::MergeWithSubgroup(const TString& name, const TString& value) { auto g = LockForUpdate("MergeWithSubgroup", name, value); auto it = Counters.find({name, value}); Y_VERIFY(it != Counters.end()); @@ -159,30 +159,30 @@ void TDynamicCounters::MergeWithSubgroup(const TString& name, const TString& val AtomicAdd(ExpiringCount, AtomicSwap(&subgroup->ExpiringCount, 0)); } -void TDynamicCounters::ResetCounters(bool derivOnly) { +void TDynamicCounters::ResetCounters(bool derivOnly) { TReadGuard g(Lock); for (auto& [key, value] : Counters) { if (auto counter = AsCounter(value)) { if (!derivOnly || counter->ForDerivative()) { - *counter = 0; + *counter = 0; } } else if (auto subgroup = AsDynamicCounters(value)) { - subgroup->ResetCounters(derivOnly); - } - } -} - + subgroup->ResetCounters(derivOnly); + } + } +} + void TDynamicCounters::RegisterCountable(const TString& name, const TString& value, TCountablePtr countable) { Y_VERIFY(countable); auto g = LockForUpdate("RegisterCountable", name, value); const bool inserted = Counters.emplace(TChildId(name, value), std::move(countable)).second; Y_VERIFY(inserted); -} - -void TDynamicCounters::RegisterSubgroup(const TString& name, const TString& value, TIntrusivePtr<TDynamicCounters> subgroup) { +} + +void TDynamicCounters::RegisterSubgroup(const TString& name, const TString& value, TIntrusivePtr<TDynamicCounters> subgroup) { RegisterCountable(name, value, subgroup); -} - +} + void TDynamicCounters::OutputHtml(IOutputStream& os) const { HTML(os) { PRE() { diff --git a/library/cpp/monlib/dynamic_counters/counters.h b/library/cpp/monlib/dynamic_counters/counters.h index dc178cfbe0..1178703786 100644 --- a/library/cpp/monlib/dynamic_counters/counters.h +++ b/library/cpp/monlib/dynamic_counters/counters.h @@ -326,19 +326,19 @@ namespace NMonitoring { THistogramPtr FindHistogram(const TString& value) const; THistogramPtr FindNamedHistogram(const TString& name,const TString& value) const; - void RemoveCounter(const TString &value); - void RemoveNamedCounter(const TString& name, const TString &value); + void RemoveCounter(const TString &value); + void RemoveNamedCounter(const TString& name, const TString &value); TIntrusivePtr<TDynamicCounters> GetSubgroup(const TString& name, const TString& value); TIntrusivePtr<TDynamicCounters> FindSubgroup(const TString& name, const TString& value) const; - void RemoveSubgroup(const TString& name, const TString& value); - void ReplaceSubgroup(const TString& name, const TString& value, TIntrusivePtr<TDynamicCounters> subgroup); - - // Move all counters from specified subgroup and remove the subgroup. - void MergeWithSubgroup(const TString& name, const TString& value); - // Recursively reset all/deriv counters to 0. - void ResetCounters(bool derivOnly = false); - + void RemoveSubgroup(const TString& name, const TString& value); + void ReplaceSubgroup(const TString& name, const TString& value, TIntrusivePtr<TDynamicCounters> subgroup); + + // Move all counters from specified subgroup and remove the subgroup. + void MergeWithSubgroup(const TString& name, const TString& value); + // Recursively reset all/deriv counters to 0. + void ResetCounters(bool derivOnly = false); + void RegisterSubgroup(const TString& name, const TString& value, TIntrusivePtr<TDynamicCounters> subgroup); @@ -363,7 +363,7 @@ namespace NMonitoring { void RegisterCountable(const TString& name, const TString& value, TCountablePtr countable); void RemoveExpired() const; - + template <bool expiring, class TCounterType, class... TArgs> TCountablePtr GetNamedCounterImpl(const TString& name, const TString& value, TArgs&&... args); diff --git a/library/cpp/monlib/dynamic_counters/counters_ut.cpp b/library/cpp/monlib/dynamic_counters/counters_ut.cpp index 3591037e0a..dfbf76010b 100644 --- a/library/cpp/monlib/dynamic_counters/counters_ut.cpp +++ b/library/cpp/monlib/dynamic_counters/counters_ut.cpp @@ -96,134 +96,134 @@ Y_UNIT_TEST_SUITE(TDynamicCountersTest) { " users:count = 7\n" "}\n"); } - + Y_UNIT_TEST(MergeSubgroup) { - TDynamicCounterPtr rootGroup(new TDynamicCounters()); - - auto sensor1 = rootGroup->GetNamedCounter("sensor", "1"); - *sensor1 = 1; - - auto group1 = rootGroup->GetSubgroup("group", "1"); - auto sensor2 = group1->GetNamedCounter("sensor", "2"); - *sensor2 = 2; - - auto group2 = group1->GetSubgroup("group", "2"); - auto sensor3 = group2->GetNamedCounter("sensor", "3"); - *sensor3 = 3; - - rootGroup->MergeWithSubgroup("group", "1"); - - TStringStream ss; - TCountersPrinter printer(&ss); - rootGroup->Accept("root", "counters", printer); - - UNIT_ASSERT_STRINGS_EQUAL(ss.Str(), - "root:counters {\n" - " group:2 {\n" - " sensor:3 = 3\n" - " }\n" - " sensor:1 = 1\n" - " sensor:2 = 2\n" - "}\n"); - } - + TDynamicCounterPtr rootGroup(new TDynamicCounters()); + + auto sensor1 = rootGroup->GetNamedCounter("sensor", "1"); + *sensor1 = 1; + + auto group1 = rootGroup->GetSubgroup("group", "1"); + auto sensor2 = group1->GetNamedCounter("sensor", "2"); + *sensor2 = 2; + + auto group2 = group1->GetSubgroup("group", "2"); + auto sensor3 = group2->GetNamedCounter("sensor", "3"); + *sensor3 = 3; + + rootGroup->MergeWithSubgroup("group", "1"); + + TStringStream ss; + TCountersPrinter printer(&ss); + rootGroup->Accept("root", "counters", printer); + + UNIT_ASSERT_STRINGS_EQUAL(ss.Str(), + "root:counters {\n" + " group:2 {\n" + " sensor:3 = 3\n" + " }\n" + " sensor:1 = 1\n" + " sensor:2 = 2\n" + "}\n"); + } + Y_UNIT_TEST(ResetCounters) { - TDynamicCounterPtr rootGroup(new TDynamicCounters()); - - auto sensor1 = rootGroup->GetNamedCounter("sensor", "1"); - *sensor1 = 1; - - auto group1 = rootGroup->GetSubgroup("group", "1"); - auto sensor2 = group1->GetNamedCounter("sensor", "2"); - *sensor2 = 2; - - auto group2 = group1->GetSubgroup("group", "2"); - auto sensor3 = group2->GetNamedCounter("sensor", "3", true); - *sensor3 = 3; - - rootGroup->ResetCounters(true); - - TStringStream ss1; - TCountersPrinter printer1(&ss1); - rootGroup->Accept("root", "counters", printer1); - - UNIT_ASSERT_STRINGS_EQUAL(ss1.Str(), - "root:counters {\n" - " group:1 {\n" - " group:2 {\n" - " sensor:3 = 0\n" - " }\n" - " sensor:2 = 2\n" - " }\n" - " sensor:1 = 1\n" - "}\n"); - - rootGroup->ResetCounters(); - - TStringStream ss2; - TCountersPrinter printer2(&ss2); - rootGroup->Accept("root", "counters", printer2); - - UNIT_ASSERT_STRINGS_EQUAL(ss2.Str(), - "root:counters {\n" - " group:1 {\n" - " group:2 {\n" - " sensor:3 = 0\n" - " }\n" - " sensor:2 = 0\n" - " }\n" - " sensor:1 = 0\n" - "}\n"); - } - + TDynamicCounterPtr rootGroup(new TDynamicCounters()); + + auto sensor1 = rootGroup->GetNamedCounter("sensor", "1"); + *sensor1 = 1; + + auto group1 = rootGroup->GetSubgroup("group", "1"); + auto sensor2 = group1->GetNamedCounter("sensor", "2"); + *sensor2 = 2; + + auto group2 = group1->GetSubgroup("group", "2"); + auto sensor3 = group2->GetNamedCounter("sensor", "3", true); + *sensor3 = 3; + + rootGroup->ResetCounters(true); + + TStringStream ss1; + TCountersPrinter printer1(&ss1); + rootGroup->Accept("root", "counters", printer1); + + UNIT_ASSERT_STRINGS_EQUAL(ss1.Str(), + "root:counters {\n" + " group:1 {\n" + " group:2 {\n" + " sensor:3 = 0\n" + " }\n" + " sensor:2 = 2\n" + " }\n" + " sensor:1 = 1\n" + "}\n"); + + rootGroup->ResetCounters(); + + TStringStream ss2; + TCountersPrinter printer2(&ss2); + rootGroup->Accept("root", "counters", printer2); + + UNIT_ASSERT_STRINGS_EQUAL(ss2.Str(), + "root:counters {\n" + " group:1 {\n" + " group:2 {\n" + " sensor:3 = 0\n" + " }\n" + " sensor:2 = 0\n" + " }\n" + " sensor:1 = 0\n" + "}\n"); + } + Y_UNIT_TEST(RemoveCounter) { - TDynamicCounterPtr rootGroup(new TDynamicCounters()); - - rootGroup->GetNamedCounter("label", "1"); - rootGroup->GetCounter("2"); - rootGroup->GetCounter("3"); - rootGroup->GetSubgroup("group", "1"); - - rootGroup->RemoveNamedCounter("label", "1"); - rootGroup->RemoveNamedCounter("label", "5"); - rootGroup->RemoveNamedCounter("group", "1"); - rootGroup->RemoveCounter("2"); - rootGroup->RemoveCounter("5"); - - TStringStream ss; - TCountersPrinter printer(&ss); - rootGroup->Accept("root", "counters", printer); - - UNIT_ASSERT_STRINGS_EQUAL(ss.Str(), - "root:counters {\n" - " group:1 {\n" - " }\n" - " sensor:3 = 0\n" - "}\n"); - } - + TDynamicCounterPtr rootGroup(new TDynamicCounters()); + + rootGroup->GetNamedCounter("label", "1"); + rootGroup->GetCounter("2"); + rootGroup->GetCounter("3"); + rootGroup->GetSubgroup("group", "1"); + + rootGroup->RemoveNamedCounter("label", "1"); + rootGroup->RemoveNamedCounter("label", "5"); + rootGroup->RemoveNamedCounter("group", "1"); + rootGroup->RemoveCounter("2"); + rootGroup->RemoveCounter("5"); + + TStringStream ss; + TCountersPrinter printer(&ss); + rootGroup->Accept("root", "counters", printer); + + UNIT_ASSERT_STRINGS_EQUAL(ss.Str(), + "root:counters {\n" + " group:1 {\n" + " }\n" + " sensor:3 = 0\n" + "}\n"); + } + Y_UNIT_TEST(RemoveSubgroup) { - TDynamicCounterPtr rootGroup(new TDynamicCounters()); - - rootGroup->GetSubgroup("group", "1"); - rootGroup->GetSubgroup("group", "2"); - rootGroup->GetCounter("2"); - - rootGroup->RemoveSubgroup("group", "1"); - rootGroup->RemoveSubgroup("group", "3"); - rootGroup->RemoveSubgroup("sensor", "2"); - - TStringStream ss; - TCountersPrinter printer(&ss); - rootGroup->Accept("root", "counters", printer); - - UNIT_ASSERT_STRINGS_EQUAL(ss.Str(), - "root:counters {\n" - " group:2 {\n" - " }\n" - " sensor:2 = 0\n" - "}\n"); - } + TDynamicCounterPtr rootGroup(new TDynamicCounters()); + + rootGroup->GetSubgroup("group", "1"); + rootGroup->GetSubgroup("group", "2"); + rootGroup->GetCounter("2"); + + rootGroup->RemoveSubgroup("group", "1"); + rootGroup->RemoveSubgroup("group", "3"); + rootGroup->RemoveSubgroup("sensor", "2"); + + TStringStream ss; + TCountersPrinter printer(&ss); + rootGroup->Accept("root", "counters", printer); + + UNIT_ASSERT_STRINGS_EQUAL(ss.Str(), + "root:counters {\n" + " group:2 {\n" + " }\n" + " sensor:2 = 0\n" + "}\n"); + } Y_UNIT_TEST(ExpiringCounters) { TDynamicCounterPtr rootGroup{new TDynamicCounters()}; diff --git a/library/cpp/monlib/service/service.cpp b/library/cpp/monlib/service/service.cpp index 929efbf816..365c9b4eef 100644 --- a/library/cpp/monlib/service/service.cpp +++ b/library/cpp/monlib/service/service.cpp @@ -71,9 +71,9 @@ namespace NMonitoring { TStringBuf GetPostContent() const override { return TStringBuf(PostContent.Buffer().Data(), PostContent.Buffer().Size()); } - HTTP_METHOD GetMethod() const override { - return (HTTP_METHOD)Header.http_method; - } + HTTP_METHOD GetMethod() const override { + return (HTTP_METHOD)Header.http_method; + } void ScanPostParams() { PostParams.Scan(TStringBuf(PostContent.Buffer().data(), PostContent.Buffer().size())); } diff --git a/library/cpp/monlib/service/service.h b/library/cpp/monlib/service/service.h index 2f66dddaf8..b128645099 100644 --- a/library/cpp/monlib/service/service.h +++ b/library/cpp/monlib/service/service.h @@ -22,7 +22,7 @@ namespace NMonitoring { virtual const TCgiParameters& GetParams() const = 0; virtual const TCgiParameters& GetPostParams() const = 0; virtual TStringBuf GetPostContent() const = 0; - virtual HTTP_METHOD GetMethod() const = 0; + virtual HTTP_METHOD GetMethod() const = 0; virtual const THttpHeaders& GetHeaders() const = 0; virtual TString GetRemoteAddr() const = 0; }; diff --git a/library/cpp/packedtypes/zigzag.h b/library/cpp/packedtypes/zigzag.h index 548403f838..ea160864b8 100644 --- a/library/cpp/packedtypes/zigzag.h +++ b/library/cpp/packedtypes/zigzag.h @@ -10,8 +10,8 @@ template <typename TSignedInt> inline auto ZigZagEncode(TSignedInt n) -> std::make_unsigned_t<TSignedInt> { static_assert(std::is_signed<TSignedInt>::value && std::is_integral<TSignedInt>::value, "Expected signed integral type."); - auto un = static_cast<std::make_unsigned_t<TSignedInt>>(n); - return (un << 1) ^ (n >> (CHAR_BIT * sizeof(TSignedInt) - 1)); + auto un = static_cast<std::make_unsigned_t<TSignedInt>>(n); + return (un << 1) ^ (n >> (CHAR_BIT * sizeof(TSignedInt) - 1)); } template <typename TUnsignedInt> |