From 8aebb9396fd4a4c654a634b30ac4b1c6ad5341e6 Mon Sep 17 00:00:00 2001 From: Alexey Vasiliev Date: Thu, 28 Jul 2016 11:06:04 +0300 Subject: [PATCH] deduplicatord: supported layers [#MOBMET-3538] --- libs/libdaemon/include/daemon/GraphiteWriter.h | 5 ++++- libs/libdaemon/src/GraphiteWriter.cpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libs/libdaemon/include/daemon/GraphiteWriter.h b/libs/libdaemon/include/daemon/GraphiteWriter.h index d5f180ba12e..6bbb17ece40 100644 --- a/libs/libdaemon/include/daemon/GraphiteWriter.h +++ b/libs/libdaemon/include/daemon/GraphiteWriter.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -34,7 +35,9 @@ public: /// Для облачных демонов удобней использовать /// путь вида prefix.environment.layer.daemon_name.metrica - static std::string getPerLayerPath(const std::string & prefix = "one_min"); + static std::string getPerLayerPath( + const std::string & prefix = "one_min", + const boost::optional layer = {}); /// возвращает путь root_path.server_name static std::string getPerServerPath(const std::string & server_name, const std::string & root_path = "one_min"); diff --git a/libs/libdaemon/src/GraphiteWriter.cpp b/libs/libdaemon/src/GraphiteWriter.cpp index 90946142713..662544db11a 100644 --- a/libs/libdaemon/src/GraphiteWriter.cpp +++ b/libs/libdaemon/src/GraphiteWriter.cpp @@ -49,7 +49,7 @@ GraphiteWriter::GraphiteWriter(const std::string & config_name, const std::strin root_path += "." + sub_path; } -std::string getPostfix() +std::string getPostfix(const boost::optional layer) { /// Угадываем имя среды по имени машинки /// машинки имеют имена вида example01dt.yandex.ru @@ -73,7 +73,9 @@ std::string getPostfix() const BaseDaemon & daemon = BaseDaemon::instance(); - if (daemon.getLayer()) + if (layer) + path_full << "layer" << std::setfill('0') << std::setw(3) << *layer << "."; + else if (daemon.getLayer()) path_full << "layer" << std::setfill('0') << std::setw(3) << *daemon.getLayer() << "."; /// Когда несколько демонов запускается на одной машине @@ -88,9 +90,11 @@ std::string getPostfix() return path_full.str(); } -std::string GraphiteWriter::getPerLayerPath(const std::string & prefix) +std::string GraphiteWriter::getPerLayerPath( + const std::string & prefix, + const boost::optional layer) { - const std::string static postfix = getPostfix(); + const std::string static postfix = getPostfix(layer); return prefix + "." + postfix; }