Skip to content
Snippets Groups Projects
Commit a3426e05 authored by Cedric CAFFY's avatar Cedric CAFFY
Browse files

Changed the freeSpaceQueryURL Regex in order to prepare for the parsing of the...

Changed the freeSpaceQueryURL Regex in order to prepare for the parsing of the EOS Space name in DiskSystem
parent a7b41353
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,7 @@ set_property(TARGET ctadisk PROPERTY VERSION "${CTA_LIBVERSION}")
add_library(ctadiskunittests SHARED
CryptoPPTest.cpp
DiskSystemTest.cpp
)
set_property(TARGET ctadiskunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
......
......@@ -63,7 +63,7 @@ std::string DiskSystemList::getDSNAme(const std::string& fileURL) const {
//------------------------------------------------------------------------------
void DiskSystemFreeSpaceList::fetchDiskSystemFreeSpace(const std::set<std::string>& diskSystems, log::LogContext & lc) {
// The real deal: go fetch the file system's free space.
cta::utils::Regex eosDiskSystem("^eos://(.*)$");
cta::utils::Regex eosDiskSystem("^eos:(.*):(.*)$");
// For testing purposes
cta::utils::Regex constantFreeSpaceDiskSystem("^constantFreeSpace:(.*)");
for (auto const & ds: diskSystems) {
......@@ -71,7 +71,7 @@ void DiskSystemFreeSpaceList::fetchDiskSystemFreeSpace(const std::set<std::strin
std::vector<std::string> regexResult;
regexResult = eosDiskSystem.exec(m_systemList.at(ds).freeSpaceQueryURL);
if (regexResult.size()) {
freeSpace = fetchEosFreeSpace(regexResult.at(1), lc);
freeSpace = fetchEosFreeSpace(regexResult.at(1), regexResult.at(2), lc);
goto found;
}
regexResult = constantFreeSpaceDiskSystem.exec(m_systemList.at(ds).freeSpaceQueryURL);
......@@ -91,7 +91,7 @@ void DiskSystemFreeSpaceList::fetchDiskSystemFreeSpace(const std::set<std::strin
//------------------------------------------------------------------------------
// DiskSystemFreeSpaceList::fetchFileSystemFreeSpace()
//------------------------------------------------------------------------------
uint64_t DiskSystemFreeSpaceList::fetchEosFreeSpace(const std::string& instanceAddress, log::LogContext & lc) {
uint64_t DiskSystemFreeSpaceList::fetchEosFreeSpace(const std::string& instanceAddress, const std::string &spaceName, log::LogContext & lc) {
threading::SubProcess sp("/usr/bin/eos", {"/usr/bin/eos", std::string("root://")+instanceAddress, "space", "ls", "-m"});
sp.wait();
try {
......@@ -110,7 +110,7 @@ uint64_t DiskSystemFreeSpaceList::fetchEosFreeSpace(const std::string& instanceA
// Look for the result line for default space.
std::istringstream spStdoutIss(sp.stdout());
std::string defaultSpaceLine;
utils::Regex defaultSpaceRe("^.*name=default .*$");
utils::Regex defaultSpaceRe("^.*name="+spaceName+" .*$");
do {
std::string spStdoutLine;
std::getline(spStdoutIss, spStdoutLine);
......
......@@ -83,7 +83,7 @@ public:
const DiskSystemList &getDiskSystemList() { return m_systemList; }
private:
DiskSystemList &m_systemList;
uint64_t fetchEosFreeSpace(const std::string & instanceAddress, log::LogContext & lc);
uint64_t fetchEosFreeSpace(const std::string & instanceAddress, const std::string & spaceName,log::LogContext & lc);
uint64_t fetchConstantFreeSpace(const std::string & instanceAddress, log::LogContext & lc);
};
......
/**
* The CERN Tape Archive (CTA) project
* Copyright © 2018 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gtest/gtest.h>
#include "common/utils/Regex.hpp"
namespace unitTests {
TEST(DiskSystem, diskSystemFreeSpaceQueryURLRegex){
cta::utils::Regex eosDiskSystem("^eos:(.*):(.*)$");
std::vector<std::string> regexResult;
regexResult = eosDiskSystem.exec("eos:ctaeos:spinner");
ASSERT_EQ("ctaeos",regexResult.at(1));
ASSERT_EQ("spinner",regexResult.at(2));
}
}
\ No newline at end of file
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