diff options
author | danibw <danibw@yandex-team.ru> | 2022-02-10 16:50:12 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:12 +0300 |
commit | 4b28e15652a7672062edb6804bc985eedc333257 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 | |
parent | e8fdd1e6c0645bf1702aaf85cc7460dbd09977cb (diff) | |
download | ydb-4b28e15652a7672062edb6804bc985eedc333257.tar.gz |
Restoring authorship annotation for <danibw@yandex-team.ru>. Commit 2 of 2.
-rw-r--r-- | build/ya.conf.json | 72 | ||||
-rw-r--r-- | library/cpp/logger/rotating_file.cpp | 64 | ||||
-rw-r--r-- | library/cpp/logger/rotating_file.h | 2 | ||||
-rw-r--r-- | library/cpp/logger/rotating_file_ut.cpp | 68 | ||||
-rw-r--r-- | library/cpp/monlib/metrics/atomics_array.h | 12 | ||||
-rw-r--r-- | library/cpp/monlib/metrics/histogram_collector.h | 10 | ||||
-rw-r--r-- | library/cpp/monlib/metrics/histogram_collector_explicit.cpp | 8 | ||||
-rw-r--r-- | library/cpp/monlib/metrics/histogram_collector_exponential.cpp | 8 | ||||
-rw-r--r-- | library/cpp/monlib/metrics/histogram_collector_linear.cpp | 8 | ||||
-rw-r--r-- | library/cpp/monlib/metrics/metric.h | 4 | ||||
-rw-r--r-- | library/cpp/monlib/metrics/metric_registry.cpp | 56 | ||||
-rw-r--r-- | library/cpp/monlib/metrics/metric_registry.h | 4 |
12 files changed, 158 insertions, 158 deletions
diff --git a/build/ya.conf.json b/build/ya.conf.json index 72a9971a1e..5f7cc875d6 100644 --- a/build/ya.conf.json +++ b/build/ya.conf.json @@ -354,9 +354,9 @@ "vmexec": { "description": "VMEXEC run script inside qemu-vm" }, - "yd-migrate": { - "description": "Run deploy migration" - }, + "yd-migrate": { + "description": "Run deploy migration" + }, "yfm-docs": { "description": "YFM-extended markdown processor for Cloud deploy (v3)" }, @@ -3606,28 +3606,28 @@ } ] }, - "yd-migrate": { - "tools": { - "yd-migrate": { - "bottle": "yd-migrate", - "executable": "yd-migrate" - } - }, - "platforms": [ - { - "host": { - "os": "LINUX" - }, - "default": true - }, - { - "host": { - "os": "DARWIN" - }, - "default": true - } - ] - }, + "yd-migrate": { + "tools": { + "yd-migrate": { + "bottle": "yd-migrate", + "executable": "yd-migrate" + } + }, + "platforms": [ + { + "host": { + "os": "LINUX" + }, + "default": true + }, + { + "host": { + "os": "DARWIN" + }, + "default": true + } + ] + }, "dctl": { "tools": { "dctl": { @@ -6850,19 +6850,19 @@ ] } }, - "yd-migrate": { - "formula": { - "sandbox_id": [ + "yd-migrate": { + "formula": { + "sandbox_id": [ 990283171 - ], + ], "match": "yd_migrate" - }, - "executable": { - "yd-migrate": [ - "migrate" - ] - } - }, + }, + "executable": { + "yd-migrate": [ + "migrate" + ] + } + }, "dctl": { "formula": { "sandbox_id": [ diff --git a/library/cpp/logger/rotating_file.cpp b/library/cpp/logger/rotating_file.cpp index 3391d26002..a62f48f25d 100644 --- a/library/cpp/logger/rotating_file.cpp +++ b/library/cpp/logger/rotating_file.cpp @@ -2,7 +2,7 @@ #include "file.h" #include "record.h" -#include <util/string/builder.h> +#include <util/string/builder.h> #include <util/system/fstat.h> #include <util/system/rwlock.h> #include <util/system/fs.h> @@ -11,36 +11,36 @@ /* * rotating file log - * if Size_ > MaxSizeBytes - * Path.(N-1) -> Path.N - * Path.(N-2) -> Path.(N-1) - * ... - * Path.1 -> Path.2 - * Path -> Path.1 + * if Size_ > MaxSizeBytes + * Path.(N-1) -> Path.N + * Path.(N-2) -> Path.(N-1) + * ... + * Path.1 -> Path.2 + * Path -> Path.1 */ class TRotatingFileLogBackend::TImpl { public: - inline TImpl(const TString& path, const ui64 maxSizeBytes, const ui32 rotatedFilesCount) - : Log_(path) - , Path_(path) - , MaxSizeBytes_(maxSizeBytes) - , Size_(TFileStat(Path_).Size) - , RotatedFilesCount_(rotatedFilesCount) - { - Y_ENSURE(RotatedFilesCount_ != 0); - } - + inline TImpl(const TString& path, const ui64 maxSizeBytes, const ui32 rotatedFilesCount) + : Log_(path) + , Path_(path) + , MaxSizeBytes_(maxSizeBytes) + , Size_(TFileStat(Path_).Size) + , RotatedFilesCount_(rotatedFilesCount) + { + Y_ENSURE(RotatedFilesCount_ != 0); + } + inline void WriteData(const TLogRecord& rec) { if (static_cast<ui64>(AtomicGet(Size_)) > MaxSizeBytes_) { TWriteGuard guard(Lock_); if (static_cast<ui64>(AtomicGet(Size_)) > MaxSizeBytes_) { - TString newLogPath(TStringBuilder{} << Path_ << "." << RotatedFilesCount_); - for (size_t fileId = RotatedFilesCount_ - 1; fileId; --fileId) { - TString oldLogPath(TStringBuilder{} << Path_ << "." << fileId); - NFs::Rename(oldLogPath, newLogPath); - newLogPath = oldLogPath; - } - NFs::Rename(Path_, newLogPath); + TString newLogPath(TStringBuilder{} << Path_ << "." << RotatedFilesCount_); + for (size_t fileId = RotatedFilesCount_ - 1; fileId; --fileId) { + TString oldLogPath(TStringBuilder{} << Path_ << "." << fileId); + NFs::Rename(oldLogPath, newLogPath); + newLogPath = oldLogPath; + } + NFs::Rename(Path_, newLogPath); Log_.ReopenLog(); AtomicSet(Size_, 0); } @@ -54,23 +54,23 @@ public: TWriteGuard guard(Lock_); Log_.ReopenLog(); - AtomicSet(Size_, TFileStat(Path_).Size); + AtomicSet(Size_, TFileStat(Path_).Size); } private: TRWMutex Lock_; TFileLogBackend Log_; - const TString Path_; + const TString Path_; const ui64 MaxSizeBytes_; TAtomic Size_; - const ui32 RotatedFilesCount_; + const ui32 RotatedFilesCount_; }; -TRotatingFileLogBackend::TRotatingFileLogBackend(const TString& path, const ui64 maxSizeByte, const ui32 rotatedFilesCount) - : Impl_(new TImpl(path, maxSizeByte, rotatedFilesCount)) -{ -} - +TRotatingFileLogBackend::TRotatingFileLogBackend(const TString& path, const ui64 maxSizeByte, const ui32 rotatedFilesCount) + : Impl_(new TImpl(path, maxSizeByte, rotatedFilesCount)) +{ +} + TRotatingFileLogBackend::~TRotatingFileLogBackend() { } diff --git a/library/cpp/logger/rotating_file.h b/library/cpp/logger/rotating_file.h index 8f5f834fbb..cb047f25fb 100644 --- a/library/cpp/logger/rotating_file.h +++ b/library/cpp/logger/rotating_file.h @@ -8,7 +8,7 @@ class TRotatingFileLogBackend: public TLogBackend { public: TRotatingFileLogBackend(const TString& preRotatePath, const TString& postRotatePath, const ui64 maxSizeBytes); - TRotatingFileLogBackend(const TString& path, const ui64 maxSizeBytes, const ui32 rotatedFilesCount); + TRotatingFileLogBackend(const TString& path, const ui64 maxSizeBytes, const ui32 rotatedFilesCount); ~TRotatingFileLogBackend() override; void WriteData(const TLogRecord& rec) override; diff --git a/library/cpp/logger/rotating_file_ut.cpp b/library/cpp/logger/rotating_file_ut.cpp index 6cfa41da80..84966933d9 100644 --- a/library/cpp/logger/rotating_file_ut.cpp +++ b/library/cpp/logger/rotating_file_ut.cpp @@ -8,38 +8,38 @@ #include <library/cpp/testing/unittest/registar.h> #include <library/cpp/testing/unittest/tests_data.h> -Y_UNIT_TEST_SUITE(NewRotatingFileSuite) { - const TString PATH = GetWorkPath() + "/my.log"; - - Y_UNIT_TEST(TestFileWrite) { - TRotatingFileLogBackend log(PATH, 4000, 2); - TString data = "my data"; - log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); - UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); - } - - Y_UNIT_TEST(TestFileRotate) { - const ui64 maxSize = 40; - TRotatingFileLogBackend log(PATH, maxSize, 2); - TStringBuilder data; - for (size_t i = 0; i < 10; ++i) - data << "data\n"; - log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); - UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); - data.clear(); - data << "more data"; - log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); - UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); - UNIT_ASSERT_C(TFileStat(TStringBuilder{} << PATH << ".1").Size > 0, "file " << PATH << ".1 has zero size"); - UNIT_ASSERT_C(TFileStat(PATH).Size < maxSize, "size of file " << PATH << " is greater than the size limit of " << maxSize << " bytes"); - } - - Y_UNIT_TEST(TestDoubleFileRotate) { - const ui64 maxSize = 40; - TRotatingFileLogBackend log(PATH, maxSize, 2); - TStringBuilder data; - for (size_t i = 0; i < 10; ++i) - data << "data\n"; +Y_UNIT_TEST_SUITE(NewRotatingFileSuite) { + const TString PATH = GetWorkPath() + "/my.log"; + + Y_UNIT_TEST(TestFileWrite) { + TRotatingFileLogBackend log(PATH, 4000, 2); + TString data = "my data"; + log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); + UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); + } + + Y_UNIT_TEST(TestFileRotate) { + const ui64 maxSize = 40; + TRotatingFileLogBackend log(PATH, maxSize, 2); + TStringBuilder data; + for (size_t i = 0; i < 10; ++i) + data << "data\n"; + log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); + UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); + data.clear(); + data << "more data"; + log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); + UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); + UNIT_ASSERT_C(TFileStat(TStringBuilder{} << PATH << ".1").Size > 0, "file " << PATH << ".1 has zero size"); + UNIT_ASSERT_C(TFileStat(PATH).Size < maxSize, "size of file " << PATH << " is greater than the size limit of " << maxSize << " bytes"); + } + + Y_UNIT_TEST(TestDoubleFileRotate) { + const ui64 maxSize = 40; + TRotatingFileLogBackend log(PATH, maxSize, 2); + TStringBuilder data; + for (size_t i = 0; i < 10; ++i) + data << "data\n"; log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); UNIT_ASSERT_C(TFileStat(PATH).Size > 0, "file " << PATH << " has zero size"); log.WriteData(TLogRecord(ELogPriority::TLOG_INFO, data.data(), data.size())); @@ -53,5 +53,5 @@ Y_UNIT_TEST_SUITE(NewRotatingFileSuite) { UNIT_ASSERT_C(TFileStat(TStringBuilder{} << PATH << ".1").Size > 0, "file " << PATH << ".1 has zero size"); UNIT_ASSERT_C(TFileStat(TStringBuilder{} << PATH << ".2").Size > 0, "file " << PATH << ".2 has zero size"); UNIT_ASSERT_C(TFileStat(PATH).Size < maxSize, "size of file " << PATH << " is greater than the size limit of " << maxSize << " bytes"); - } -} + } +} diff --git a/library/cpp/monlib/metrics/atomics_array.h b/library/cpp/monlib/metrics/atomics_array.h index e044f14b00..f19aebf291 100644 --- a/library/cpp/monlib/metrics/atomics_array.h +++ b/library/cpp/monlib/metrics/atomics_array.h @@ -31,12 +31,12 @@ namespace NMonitoring { Values_[index].fetch_add(count, std::memory_order_relaxed); } - void Reset() noexcept { - for (size_t i = 0; i < Size_; i++) { - Values_[i].store(0, std::memory_order_relaxed); - } - } - + void Reset() noexcept { + for (size_t i = 0; i < Size_; i++) { + Values_[i].store(0, std::memory_order_relaxed); + } + } + TVector<ui64> Copy() const { TVector<ui64> copy(Reserve(Size_)); for (size_t i = 0; i < Size_; i++) { diff --git a/library/cpp/monlib/metrics/histogram_collector.h b/library/cpp/monlib/metrics/histogram_collector.h index 5afbf63c8e..9f6bbbdfb7 100644 --- a/library/cpp/monlib/metrics/histogram_collector.h +++ b/library/cpp/monlib/metrics/histogram_collector.h @@ -33,11 +33,11 @@ namespace NMonitoring { } /** - * Reset collector values - */ - virtual void Reset() = 0; - - /** + * Reset collector values + */ + virtual void Reset() = 0; + + /** * @return snapshot of the state of this collector. */ virtual IHistogramSnapshotPtr Snapshot() const = 0; diff --git a/library/cpp/monlib/metrics/histogram_collector_explicit.cpp b/library/cpp/monlib/metrics/histogram_collector_explicit.cpp index 7684468a2d..377fc233ef 100644 --- a/library/cpp/monlib/metrics/histogram_collector_explicit.cpp +++ b/library/cpp/monlib/metrics/histogram_collector_explicit.cpp @@ -27,10 +27,10 @@ namespace NMonitoring { Values_.Add(index, count); } - void Reset() override { - Values_.Reset(); - } - + void Reset() override { + Values_.Reset(); + } + IHistogramSnapshotPtr Snapshot() const override { auto values = Values_.Copy(); return ExplicitHistogramSnapshot(Bounds_, values); diff --git a/library/cpp/monlib/metrics/histogram_collector_exponential.cpp b/library/cpp/monlib/metrics/histogram_collector_exponential.cpp index e4dc327dff..2f8a50a5f9 100644 --- a/library/cpp/monlib/metrics/histogram_collector_exponential.cpp +++ b/library/cpp/monlib/metrics/histogram_collector_exponential.cpp @@ -35,10 +35,10 @@ namespace NMonitoring { Values_.Add(index, count); } - void Reset() override { - Values_.Reset(); - } - + void Reset() override { + Values_.Reset(); + } + IHistogramSnapshotPtr Snapshot() const override { return new TExponentialHistogramSnapshot(Base_, Scale_, Values_.Copy()); } diff --git a/library/cpp/monlib/metrics/histogram_collector_linear.cpp b/library/cpp/monlib/metrics/histogram_collector_linear.cpp index 8cd6aafcb7..f8ad86f3a4 100644 --- a/library/cpp/monlib/metrics/histogram_collector_linear.cpp +++ b/library/cpp/monlib/metrics/histogram_collector_linear.cpp @@ -36,10 +36,10 @@ namespace NMonitoring { Values_.Add(index, count); } - void Reset() override { - Values_.Reset(); - } - + void Reset() override { + Values_.Reset(); + } + IHistogramSnapshotPtr Snapshot() const override { return new TLinearHistogramSnapshot( StartValue_, BucketWidth_, Values_.Copy()); diff --git a/library/cpp/monlib/metrics/metric.h b/library/cpp/monlib/metrics/metric.h index 725d4fecef..b8ce12d753 100644 --- a/library/cpp/monlib/metrics/metric.h +++ b/library/cpp/monlib/metrics/metric.h @@ -379,8 +379,8 @@ namespace NMonitoring { } void Reset() override { - Collector_->Reset(); - } + Collector_->Reset(); + } private: IHistogramCollectorPtr Collector_; diff --git a/library/cpp/monlib/metrics/metric_registry.cpp b/library/cpp/monlib/metrics/metric_registry.cpp index d1bb063aab..b083163a7b 100644 --- a/library/cpp/monlib/metrics/metric_registry.cpp +++ b/library/cpp/monlib/metrics/metric_registry.cpp @@ -124,34 +124,34 @@ namespace NMonitoring { return Metric<THistogram, EMetricType::HIST_RATE>(std::move(labels), std::move(collector), true); } - void TMetricRegistry::Reset() { - TWriteGuard g{Lock_}; - for (auto& [label, metric] : Metrics_) { - switch (metric->Type()) { - case EMetricType::GAUGE: - static_cast<TGauge*>(metric.Get())->Set(.0); - break; - case EMetricType::IGAUGE: - static_cast<TIntGauge*>(metric.Get())->Set(0); - break; - case EMetricType::COUNTER: - static_cast<TCounter*>(metric.Get())->Reset(); - break; - case EMetricType::RATE: - static_cast<TRate*>(metric.Get())->Reset(); - break; - case EMetricType::HIST: - case EMetricType::HIST_RATE: - static_cast<THistogram*>(metric.Get())->Reset(); - break; - case EMetricType::UNKNOWN: - case EMetricType::DSUMMARY: - case EMetricType::LOGHIST: - break; - } - } - } - + void TMetricRegistry::Reset() { + TWriteGuard g{Lock_}; + for (auto& [label, metric] : Metrics_) { + switch (metric->Type()) { + case EMetricType::GAUGE: + static_cast<TGauge*>(metric.Get())->Set(.0); + break; + case EMetricType::IGAUGE: + static_cast<TIntGauge*>(metric.Get())->Set(0); + break; + case EMetricType::COUNTER: + static_cast<TCounter*>(metric.Get())->Reset(); + break; + case EMetricType::RATE: + static_cast<TRate*>(metric.Get())->Reset(); + break; + case EMetricType::HIST: + case EMetricType::HIST_RATE: + static_cast<THistogram*>(metric.Get())->Reset(); + break; + case EMetricType::UNKNOWN: + case EMetricType::DSUMMARY: + case EMetricType::LOGHIST: + break; + } + } + } + void TMetricRegistry::Clear() { TWriteGuard g{Lock_}; Metrics_.clear(); diff --git a/library/cpp/monlib/metrics/metric_registry.h b/library/cpp/monlib/metrics/metric_registry.h index ade57cfef3..670cf8651e 100644 --- a/library/cpp/monlib/metrics/metric_registry.h +++ b/library/cpp/monlib/metrics/metric_registry.h @@ -82,12 +82,12 @@ namespace NMonitoring { /** * Set all registered metrics to zero */ - void Reset(); + void Reset(); /** * Remove all registered metrics from registry */ void Clear(); - + void Accept(TInstant time, IMetricConsumer* consumer) const override; void Append(TInstant time, IMetricConsumer* consumer) const override; |