Commit cbe37199 authored by Eric Cano's avatar Eric Cano
Browse files

#533: Added tapeserver side support for disk system in the catalogue interface.

The implemantation currently returns an empty disk system.
parent 3640b55a
......@@ -59,6 +59,7 @@
#include "common/log/LogContext.hpp"
#include "common/log/Logger.hpp"
#include "common/optional.hpp"
#include "disk/DiskSystem.hpp"
#include <list>
#include <map>
......@@ -491,6 +492,8 @@ public:
virtual void deleteActivitiesFairShareWeight(const common::dataStructures::SecurityIdentity &admin, const std::string & diskInstanceName, const std::string & acttivity) = 0;
virtual std::list<common::dataStructures::ActivitiesFairShareWeights> getActivitiesFairShareWeights() const = 0;
virtual cta::disk::DiskSystemList getDiskSystems() const = 0;
/**
* Returns the specified archive files. Please note that the list of files
* is ordered by archive file ID.
......
......@@ -361,6 +361,10 @@ public:
return retryOnLostConnection(m_log, [&]{return m_catalogue->getActivitiesFairShareWeights();}, m_maxTriesToConnect);
}
cta::disk::DiskSystemList getDiskSystems() const override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->getDiskSystems();}, m_maxTriesToConnect);
}
ArchiveFileItor getArchiveFilesItor(const TapeFileSearchCriteria &searchCriteria = TapeFileSearchCriteria()) const override {
return retryOnLostConnection(m_log, [&]{return m_catalogue->getArchiveFilesItor(searchCriteria);}, m_maxTriesToConnect);
......
......@@ -57,7 +57,8 @@ public:
void deleteTapePool(const std::string& name) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
void filesWrittenToTape(const std::set<TapeItemWrittenPointer>& event) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
std::list<common::dataStructures::ActivitiesFairShareWeights> getActivitiesFairShareWeights() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
std::list<common::dataStructures::AdminUser> getAdminUsers() const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
cta::disk::DiskSystemList getDiskSystems() const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
std::list<common::dataStructures::AdminUser> getAdminUsers() const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
common::dataStructures::ArchiveFile getArchiveFileById(const uint64_t id) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
ArchiveFileItor getArchiveFilesItor(const TapeFileSearchCriteria& searchCriteria) const { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
std::list<common::dataStructures::ArchiveFile> getFilesForRepack(const std::string &vid, const uint64_t startFSeq, const uint64_t maxNbFiles) const override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
......
......@@ -4198,6 +4198,13 @@ std::list<common::dataStructures::ActivitiesFairShareWeights> RdbmsCatalogue::ge
}
}
//------------------------------------------------------------------------------
// getDiskSystems
//------------------------------------------------------------------------------
cta::disk::DiskSystemList RdbmsCatalogue::getDiskSystems() const {
return cta::disk::DiskSystemList();
}
//------------------------------------------------------------------------------
// insertArchiveFile
//------------------------------------------------------------------------------
......
......@@ -505,6 +505,8 @@ public:
void deleteActivitiesFairShareWeight(const common::dataStructures::SecurityIdentity &admin, const std::string & diskInstanceName, const std::string & activity) override;
std::list<common::dataStructures::ActivitiesFairShareWeights> getActivitiesFairShareWeights() const override;
cta::disk::DiskSystemList getDiskSystems() const override;
/**
* Throws a UserError exception if the specified searchCriteria is not valid
......
......@@ -47,7 +47,7 @@ Regex::~Regex() {
::regfree(&m_re);
}
std::vector<std::string> Regex::exec(const std::string &s) {
std::vector<std::string> Regex::exec(const std::string &s) const {
regmatch_t matches[100];
if (REG_NOMATCH != ::regexec(&m_re, s.c_str(), 100, matches, 0)) {
std::vector<std::string> ret;
......
......@@ -35,7 +35,7 @@ class Regex {
/*!
* Return a list of matching substrings
*/
std::vector<std::string> exec(const std::string &s);
std::vector<std::string> exec(const std::string &s) const;
/*!
* Return true if there is at least one matching substring
......
......@@ -27,6 +27,7 @@ add_library(ctadisk SHARED
EOSReporter.cpp
DiskFile.cpp
RadosStriperPool.cpp
DiskSystem.cpp
)
target_link_libraries (ctadisk XrdCl cryptopp radosstriper)
......
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 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 "DiskSystem.hpp"
#include <algorithm>
namespace cta { namespace disk {
const DiskSystem& DiskSystemList::at(const std::string& name) {
auto dsi = std::find_if(begin(), end(), [&](const DiskSystem& ds){ return ds.name == name;});
if (dsi != end()) return *dsi;
throw std::out_of_range("In DiskSystemList::at(): name not found.");
}
std::string DiskSystemList::getFSNAme(const std::string& fileURL) {
// First if the regexes have not been created yet, do so.
if (m_pointersAndRegexes.empty() && size()) {
for (const auto &ds: *this) {
m_pointersAndRegexes.emplace_back(PointerAndRegex({ds, utils::Regex(ds.fileRegexp.c_str())}));
}
}
// Try and find the fileURL
auto pri = std::find_if(m_pointersAndRegexes.begin(), m_pointersAndRegexes.end(),
[&](const PointerAndRegex & pr){ return !pr.regex.exec(fileURL).empty(); });
if (pri != m_pointersAndRegexes.end()) {
// We found a match. Let's move the pointer and regex to the front so next file will be faster (most likely).
if (pri != m_pointersAndRegexes.begin())
m_pointersAndRegexes.splice(m_pointersAndRegexes.begin(), m_pointersAndRegexes, pri);
return pri->ds.name;
}
throw std::out_of_range("In DiskSystemList::getFSNAme(): not match for fileURL");
}
}} // namespace cta::disk
\ No newline at end of file
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 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/>.
*/
#pragma once
#include <string>
#include <list>
#include "common/utils/Regex.hpp"
namespace cta { namespace disk {
/**
* Description of a disk system as defined by operators.
* Defines:
* - a name used an index
* - a regular expression allowing matching destination URLs for this disk system
* - a query URL that describes a method to query the free space from the filesystem
* - a refresh interval (seconds) defining how long do we use a
* - a targeted free space (margin) based on the free space update latency (inherent to the file system and induced by the refresh
* interval), and the expected external bandwidth from sources external to CTA.
*/
struct DiskSystem {
std::string name;
std::string fileRegexp;
std::string freeSpaceQueryURL;
uint64_t refreshInterval;
uint64_t targetedFreeSpace;
};
class DiskSystemList: public std::list<DiskSystem> {
using std::list<DiskSystem>::list;
public:
/** Get the filesystem for a given destination URL */
std::string getFSNAme(const std::string &fileURL);
/** Get the file system parameters from a file system name */
const DiskSystem & at(const std::string &name);
private:
struct PointerAndRegex {
const DiskSystem & ds;
utils::Regex regex;
};
std::list<PointerAndRegex> m_pointersAndRegexes;
};
}} // namespace cta::disk
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment