/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
cloud/blockstore/vhost-server/critical_event.cpp
57 строк
1 KB
Kirill Pleshivtsev
Vhost server write encrypted zero blocks (#1728)
09 авг 2024, 14:51
Не верифицирован
09 авг 2024, 14:51
a97c4f2
Код
Авторство
О чём код?
#include "critical_event.h" #include <cloud/storage/core/libs/diagnostics/logging.h> #include <util/string/builder.h> #include <util/system/spinlock.h> namespace NCloud::NBlockStore::NVHostServer { //////////////////////////////////////////////////////////////////////////////// namespace { constexpr size_t MaxStoredCriticalEventCount = 1024; TLog Log; TCriticalEvents CriticalEventsAccumulator; TAdaptiveLock Guard; } // namespace void SetCriticalEventsLog(TLog log) { Log = std::move(log); } void ReportCriticalEvent(TString sensorName, TString message) { if (Log.IsOpen()) { TStringBuilder fullMessage; fullMessage << "CRITICAL_EVENT:" << sensorName; if (message) { fullMessage << ":" << message; } STORAGE_ERROR(fullMessage); } with_lock (Guard) { if (CriticalEventsAccumulator.size() >= MaxStoredCriticalEventCount) { return; } CriticalEventsAccumulator.emplace_back( std::move(sensorName), std::move(message)); } } TCriticalEvents TakeAccumulatedCriticalEvents() { TCriticalEvents result; with_lock (Guard) { CriticalEventsAccumulator.swap(result); } return result; } } // namespace NCloud::NBlockStore::NVHostServer