Skip to content
Snippets Groups Projects
Commit 94d0e06a authored by Steven Murray's avatar Steven Murray
Browse files

Moved SourcedParameter<FetchReportOrFlushLimits>::set() from...

Moved SourcedParameter<FetchReportOrFlushLimits>::set() from SourcedParameter.cpp to TapedConfiguration.cpp

SourcedParameter.cpp is the "common" CTA directory, in other words
CTA/commIit is located at on/SourcedParameter.cpp.  The
SourceParameter.cpp file should therefore not contain any code
specific to a particular CTA daemon such as cta-taped.
parent c3a99746
No related branches found
No related tags found
No related merge requests found
......@@ -54,38 +54,6 @@ void SourcedParameter<uint64_t>::set(const std::string & value, const std::strin
m_set = true;
}
template<>
void SourcedParameter<FetchReportOrFlushLimits>::set(const std::string & value,
const std::string & source) {
// We expect an entry in the form "<size limit>, <file limit>"
// There should be one and only one comma in the parameter.
if (1 != std::count(value.begin(), value.end(), ',')) {
BadlyFormattedSizeFileLimit ex;
ex.getMessage() << "In SourcedParameter<FetchReportOrFlushLimits>::set() : badly formatted entry: one (and only one) comma expected"
<< " for category=" << m_category << " key=" << m_key
<< " value=\'" << value << "' at:" << source;
throw ex;
}
// We can now split the entry
std::string bytes, files;
size_t commaPos=value.find(',');
bytes=value.substr(0, commaPos);
files=value.substr(commaPos+1);
bytes=utils::trimString(bytes);
files=utils::trimString(files);
if (!(utils::isValidUInt(bytes)&&utils::isValidUInt(files))) {
BadlyFormattedInteger ex;
ex.getMessage() << "In SourcedParameter<FetchReportOrFlushLimits>::set() : badly formatted integer"
<< " for category=" << m_category << " key=" << m_key
<< " value=\'" << value << "' at:" << source;
throw ex;
}
std::istringstream(bytes) >> m_value.maxBytes;
std::istringstream(files) >> m_value.maxFiles;
m_source = source;
m_set = true;
}
template<>
void SourcedParameter<std::string>::set(const std::string & value, const std::string & source) {
m_value = value;
......
......@@ -20,6 +20,8 @@
#include "common/ConfigurationFile.hpp"
#include "Tpconfig.hpp"
#include <algorithm>
namespace cta { namespace tape { namespace daemon {
//------------------------------------------------------------------------------
......@@ -43,6 +45,41 @@ void SourcedParameter<FetchReportOrFlushLimits>::addLogParamForValue(log::LogCon
lc.pushOrReplace({"maxFiles", m_value.maxFiles});
}
//------------------------------------------------------------------------------
// set
//------------------------------------------------------------------------------
template<>
void SourcedParameter<FetchReportOrFlushLimits>::set(const std::string & value,
const std::string & source) {
// We expect an entry in the form "<size limit>, <file limit>"
// There should be one and only one comma in the parameter.
if (1 != std::count(value.begin(), value.end(), ',')) {
BadlyFormattedSizeFileLimit ex;
ex.getMessage() << "In SourcedParameter<FetchReportOrFlushLimits>::set() : badly formatted entry: one (and only one) comma expected"
<< " for category=" << m_category << " key=" << m_key
<< " value=\'" << value << "' at:" << source;
throw ex;
}
// We can now split the entry
std::string bytes, files;
size_t commaPos=value.find(',');
bytes=value.substr(0, commaPos);
files=value.substr(commaPos+1);
bytes=utils::trimString(bytes);
files=utils::trimString(files);
if (!(utils::isValidUInt(bytes)&&utils::isValidUInt(files))) {
BadlyFormattedInteger ex;
ex.getMessage() << "In SourcedParameter<FetchReportOrFlushLimits>::set() : badly formatted integer"
<< " for category=" << m_category << " key=" << m_key
<< " value=\'" << value << "' at:" << source;
throw ex;
}
std::istringstream(bytes) >> m_value.maxBytes;
std::istringstream(files) >> m_value.maxFiles;
m_source = source;
m_set = true;
}
//------------------------------------------------------------------------------
// GlobalConfiguration::createFromCtaConf w path
//------------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment