From 775eb6d2495070b5cc1899012f42231fb0c1e9d0 Mon Sep 17 00:00:00 2001 From: Steven Murray <Steven.Murray@cern.ch> Date: Thu, 11 Jun 2015 15:18:59 +0200 Subject: [PATCH] Created teh remotestorage directory --- CMakeLists.txt | 1 + remotestorage/CMakeLists.txt | 9 +++ .../EosRemoteStorage.cpp | 19 ++++-- .../EosRemoteStorage.hpp | 18 ++++-- remotestorage/MockRemoteStorage.cpp | 49 +++++++++++++++ remotestorage/MockRemoteStorage.hpp | 63 +++++++++++++++++++ .../RemoteStorage.cpp | 2 +- .../RemoteStorage.hpp | 16 +++-- scheduler/CMakeLists.txt | 2 - 9 files changed, 161 insertions(+), 18 deletions(-) create mode 100644 remotestorage/CMakeLists.txt rename {scheduler => remotestorage}/EosRemoteStorage.cpp (69%) rename {scheduler => remotestorage}/EosRemoteStorage.hpp (72%) create mode 100644 remotestorage/MockRemoteStorage.cpp create mode 100644 remotestorage/MockRemoteStorage.hpp rename {scheduler => remotestorage}/RemoteStorage.cpp (95%) rename {scheduler => remotestorage}/RemoteStorage.hpp (74%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 628615be88..e8380d37cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,7 @@ add_subdirectory(cmdline) add_subdirectory(common) add_subdirectory(objectstore) add_subdirectory(nameserver) +add_subdirectory(remotestorage) add_subdirectory(scheduler) add_subdirectory(tests) add_subdirectory(xroot_plugins) diff --git a/remotestorage/CMakeLists.txt b/remotestorage/CMakeLists.txt new file mode 100644 index 0000000000..457ca91a11 --- /dev/null +++ b/remotestorage/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required (VERSION 2.6) + +set (CTA_REMOTE_STORAGE_SRC_FILES + EosRemoteStorage.cpp + MockRemoteStorage.cpp + RemoteStorage.cpp) + +add_library (ctaremotestorage SHARED + ${CTA_REMOTE_STORAGE_SRC_FILES}) diff --git a/scheduler/EosRemoteStorage.cpp b/remotestorage/EosRemoteStorage.cpp similarity index 69% rename from scheduler/EosRemoteStorage.cpp rename to remotestorage/EosRemoteStorage.cpp index c3d031e06f..6de1a15a55 100644 --- a/scheduler/EosRemoteStorage.cpp +++ b/remotestorage/EosRemoteStorage.cpp @@ -16,9 +16,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "scheduler/EosRemoteStorage.hpp" #include "common/exception/Exception.hpp" -using cta::exception::Exception; +#include "remotestorage/EosRemoteStorage.hpp" //------------------------------------------------------------------------------ // destructor @@ -27,10 +26,18 @@ cta::EosRemoteStorage::~EosRemoteStorage() throw() { } //------------------------------------------------------------------------------ -// fileExists +// regularFileExists //------------------------------------------------------------------------------ -bool cta::EosRemoteStorage::fileExists(const std::string &remoteFile) { - throw Exception("EosRemoteStorage::fileExists() not implemented"); +bool cta::EosRemoteStorage::regularFileExists(const std::string &remoteFile) + const { + throw exception::Exception(std::string(__FUNCTION__) + " not implemented"); +} + +//------------------------------------------------------------------------------ +// dirExists +//------------------------------------------------------------------------------ +bool cta::EosRemoteStorage::dirExists(const std::string &remoteFile) const { + throw exception::Exception(std::string(__FUNCTION__) + " not implemented"); } //------------------------------------------------------------------------------ @@ -38,5 +45,5 @@ bool cta::EosRemoteStorage::fileExists(const std::string &remoteFile) { //------------------------------------------------------------------------------ void cta::EosRemoteStorage::rename(const std::string &remoteFile, const std::string &newRemoteFile) { - throw Exception("EosRemoteStorage::rename() not implemented"); + throw exception::Exception(std::string(__FUNCTION__) + " not implemented"); } diff --git a/scheduler/EosRemoteStorage.hpp b/remotestorage/EosRemoteStorage.hpp similarity index 72% rename from scheduler/EosRemoteStorage.hpp rename to remotestorage/EosRemoteStorage.hpp index 444ebaced2..b10ee5fc24 100644 --- a/scheduler/EosRemoteStorage.hpp +++ b/remotestorage/EosRemoteStorage.hpp @@ -18,7 +18,7 @@ #pragma once -#include "scheduler/RemoteStorage.hpp" +#include "remotestorage/RemoteStorage.hpp" namespace cta { @@ -34,12 +34,20 @@ public: ~EosRemoteStorage() throw(); /** - * Returns true if the specified remote file exists or false if not. + * Returns true if the specified regular file exists. * - * @param remoteFile The URL of the remote file. - * @return true if the specified remote file exists or false if not. + * @param path The absolute path of the file. + * @return True if the specified directory exists. */ - bool fileExists(const std::string &remoteFile); + bool regularFileExists(const std::string &path) const; + + /** + * Returns true if the specified directory exists. + * + * @param path The absolute path of the file. + * @return True if the specified directory exists. + */ + bool dirExists(const std::string &path) const; /** * Renames the specified remote file to the specified new name. diff --git a/remotestorage/MockRemoteStorage.cpp b/remotestorage/MockRemoteStorage.cpp new file mode 100644 index 0000000000..3c01b52e04 --- /dev/null +++ b/remotestorage/MockRemoteStorage.cpp @@ -0,0 +1,49 @@ +/* + * 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 "common/exception/Exception.hpp" +#include "remotestorage/MockRemoteStorage.hpp" + +//------------------------------------------------------------------------------ +// destructor +//------------------------------------------------------------------------------ +cta::MockRemoteStorage::~MockRemoteStorage() throw() { +} + +//------------------------------------------------------------------------------ +// regularFileExists +//------------------------------------------------------------------------------ +bool cta::MockRemoteStorage::regularFileExists(const std::string &remoteFile) + const { + throw exception::Exception(std::string(__FUNCTION__) + " not implemented"); +} + +//------------------------------------------------------------------------------ +// dirExists +//------------------------------------------------------------------------------ +bool cta::MockRemoteStorage::dirExists(const std::string &remoteFile) const { + throw exception::Exception(std::string(__FUNCTION__) + " not implemented"); +} + +//------------------------------------------------------------------------------ +// rename +//------------------------------------------------------------------------------ +void cta::MockRemoteStorage::rename(const std::string &remoteFile, + const std::string &newRemoteFile) { + throw exception::Exception(std::string(__FUNCTION__) + " not implemented"); +} diff --git a/remotestorage/MockRemoteStorage.hpp b/remotestorage/MockRemoteStorage.hpp new file mode 100644 index 0000000000..5894ce2209 --- /dev/null +++ b/remotestorage/MockRemoteStorage.hpp @@ -0,0 +1,63 @@ +/* + * 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 "remotestorage/RemoteStorage.hpp" + +namespace cta { + +/** + * A mock proxy class for a remote storage system. + */ +class MockRemoteStorage: public RemoteStorage { +public: + + /** + * Destructor. + */ + ~MockRemoteStorage() throw(); + + /** + * Returns true if the specified regular file exists. + * + * @param path The absolute path of the file. + * @return True if the specified directory exists. + */ + bool regularFileExists(const std::string &path) const; + + /** + * Returns true if the specified directory exists. + * + * @param path The absolute path of the file. + * @return True if the specified directory exists. + */ + bool dirExists(const std::string &path) const; + + /** + * Renames the specified remote file to the specified new name. + * + * @param remoteFile The current URL of the remote file. + * @param newRemoteFile The new URL of the remote file. + */ + void rename(const std::string &remoteFile, + const std::string &newRemoteFile); + +}; // class MockRemoteStorage + +} // namespace cta diff --git a/scheduler/RemoteStorage.cpp b/remotestorage/RemoteStorage.cpp similarity index 95% rename from scheduler/RemoteStorage.cpp rename to remotestorage/RemoteStorage.cpp index 5cc7176dc8..8d1219ad0a 100644 --- a/scheduler/RemoteStorage.cpp +++ b/remotestorage/RemoteStorage.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "scheduler/RemoteStorage.hpp" +#include "remotestorage/RemoteStorage.hpp" //------------------------------------------------------------------------------ // destructor diff --git a/scheduler/RemoteStorage.hpp b/remotestorage/RemoteStorage.hpp similarity index 74% rename from scheduler/RemoteStorage.hpp rename to remotestorage/RemoteStorage.hpp index 8f66f5066c..26dba5d300 100644 --- a/scheduler/RemoteStorage.hpp +++ b/remotestorage/RemoteStorage.hpp @@ -34,12 +34,20 @@ public: virtual ~RemoteStorage() throw() = 0; /** - * Returns true if the specified remote file exists or false if not. + * Returns true if the specified regular file exists. * - * @param remoteFile The URL of the remote file. - * @return true if the specified remote file exists or false if not. + * @param path The absolute path of the file. + * @return True if the specified directory exists. */ - virtual bool fileExists(const std::string &remoteFile) = 0; + virtual bool regularFileExists(const std::string &path) const = 0; + + /** + * Returns true if the specified directory exists. + * + * @param path The absolute path of the file. + * @return True if the specified directory exists. + */ + virtual bool dirExists(const std::string &path) const = 0; /** * Renames the specified remote file to the specified new name. diff --git a/scheduler/CMakeLists.txt b/scheduler/CMakeLists.txt index 37b9925aa2..102a04a4f3 100644 --- a/scheduler/CMakeLists.txt +++ b/scheduler/CMakeLists.txt @@ -20,7 +20,6 @@ set (CTA_SCHEDULER_SRC_FILES DirIterator.cpp DiskException.cpp DriveQuota.cpp - EosRemoteStorage.cpp FileAttribute.cpp FileSystemDirEntry.cpp FileSystemNode.cpp @@ -32,7 +31,6 @@ set (CTA_SCHEDULER_SRC_FILES MockSchedulerDatabaseFactory.cpp Mount.cpp MountCriteria.cpp - RemoteStorage.cpp RetrievalFileTransfer.cpp RetrievalMount.cpp RetrieveRequest.cpp -- GitLab