Skip to content
Snippets Groups Projects
Commit 41cbb134 authored by Eric Cano's avatar Eric Cano
Browse files

Created archive reporter classes and refactored Xroot exception thrower.

Moved XrootCl exception and thrower to cta::exception
parent 71677faa
No related branches found
No related tags found
No related merge requests found
......@@ -116,6 +116,7 @@ ELSE(DEFINED PackageOnly)
add_subdirectory(catalogue)
add_subdirectory(cmdline)
add_subdirectory(common)
add_subdirectory(disk)
add_subdirectory(mediachanger)
add_subdirectory(objectstore)
add_subdirectory(rdbms)
......
......@@ -23,6 +23,8 @@ find_package (libuuid REQUIRED)
add_subdirectory (exception)
include_directories (${XROOTD_INCLUDE_DIR})
set_source_files_properties(CRC.cpp PROPERTIES COMPILE_FLAGS -O2)
set (COMMON_LIB_SRC_FILES
......@@ -87,6 +89,7 @@ set (COMMON_LIB_SRC_FILES
exception/NotAnOwner.cpp
exception/OutOfMemory.cpp
exception/TimeOut.cpp
exception/XrootCl.cpp
log/DummyLogger.cpp
log/LogContext.cpp
log/Logger.cpp
......@@ -136,7 +139,8 @@ target_link_libraries (ctacommon
pthread
uuid
z
cap)
cap
XrdCl)
set (COMMON_UNIT_TESTS_LIB_SRC_FILES
checksum/ChecksumTest.cpp
......
......@@ -25,7 +25,9 @@
#include "XrootCl.hpp"
#include <sstream>
castor::tape::server::exception::XrootCl::XrootCl(const XrdCl::XRootDStatus& status, const std::string & what) {
namespace cta { namespace exception {
XrootCl::XrootCl(const XrdCl::XRootDStatus& status, const std::string & what) {
std::stringstream w;
if (what.size())
w << what << " ";
......@@ -33,9 +35,11 @@ castor::tape::server::exception::XrootCl::XrootCl(const XrdCl::XRootDStatus& sta
getMessage().str(w.str());
}
void castor::tape::server::exception::XrootCl::throwOnError(const XrdCl::XRootDStatus& status, std::string context)
void XrootCl::throwOnError(const XrdCl::XRootDStatus& status, std::string context)
{
if (!status.IsOK()) {
throw XrootCl(status, context);
}
}
}} // namespace cta::exception
......@@ -24,12 +24,10 @@
#pragma once
#include "common/exception/Exception.hpp"
#include "Exception.hpp"
#include <xrootd/XrdCl/XrdClXRootDResponses.hh>
namespace castor {
namespace tape {
namespace server {
namespace cta {
namespace exception {
/**
* A class turning the XrootCl (xroot 4 object client) error codes
......@@ -44,4 +42,4 @@ namespace exception {
protected:
XrdCl::XRootDStatus m_status;
};
}}}}
}} // namespace cta::exception
# 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/>.
cmake_minimum_required (VERSION 2.6)
find_package (xrootdclient REQUIRED)
include_directories (${XROOTD_INCLUDE_DIR} ${CMAKE_SOURCE_DIR})
add_library (ctaclientsystem
DiskReporter.cpp
DiskReporterFactory.cpp
EOSReporter.cpp)
/*
* 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 "DiskReporter.hpp"
\ 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
namespace cta { namespace disk {
class DiskReporter {
public:
virtual void reportArchiveFullyComplete() = 0;
virtual ~DiskReporter() {};
};
}} // name space cta::clientsystem
\ 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/>.
*/
#include "DiskReporterFactory.hpp"
#include "EOSReporter.hpp"
#include "NullReporter.hpp"
#include "common/exception/Exception.hpp"
namespace cta { namespace disk {
DiskReporter* DiskReporterFactory::createDiskReporter(const std::string URL) {
auto regexResult = m_EosUrlRegex.exec(URL);
if (regexResult.size()) {
return new EOSReporter(regexResult[1], regexResult[2]);
}
regexResult = m_NullRegex.exec(URL);
if (regexResult.size()) {
return new NullReporter();
}
throw cta::exception::Exception(
std::string("In DiskReporterFactory::createDiskReporter failed to parse URL: ")+URL);
}
}} // 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 "DiskReporter.hpp"
#include "common/utils/Regex.hpp"
#include <string>
namespace cta { namespace disk {
class DiskReporterFactory {
public:
DiskReporter * createDiskReporter(const std::string URL);
private:
// The typical call to give report to EOS will be:
// xrdfs localhost query opaquefile "/eos/wfe/passwd?mgm.pcmd=event&mgm.fid=112&mgm.logid=cta&mgm.event=migrated&mgm.workflow=default&mgm.path=/eos/wfe/passwd&mgm.ruid=0&mgm.rgid=0"
// which will be encoded as eosQuery://eosserver.cern.ch/eos/wfe/passwd?mgm.pcmd=event&mgm.fid=112&mgm.logid=cta&mgm.event=migrated&mgm.workflow=default&mgm.path=/eos/wfe/passwd&mgm.ruid=0&mgm.rgid=0"
// which itself will be translated into (roughly) :
// XrdCl::FileSystem(XrdCl::URL("eoserver.cern.ch")).Query("/eos/wfe/passwd?mgm.pcmd=event&mgm.fid=112&mgm.logid=cta&mgm.event=migrated&mgm.workflow=default&mgm.path=/eos/wfe/passwd&mgm.ruid=0&mgm.rgid=0");
cta::utils::Regex m_EosUrlRegex{"^eosQuery://([^/]+)(/.*)$"};
cta::utils::Regex m_NullRegex{"^$"};
};
}} // 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/>.
*/
#include "EOSReporter.hpp"
#include "common/exception/XrootCl.hpp"
namespace cta { namespace disk {
EOSReporter::EOSReporter(const std::string& hostURL, const std::string& queryValue):
m_fs(hostURL) {}
void EOSReporter::reportArchiveFullyComplete() {
auto qcOpaque = XrdCl::QueryCode::OpaqueFile;
XrdCl::Buffer arg (m_query.size());
arg.FromString(m_query);
cta::exception::XrootCl::throwOnError(m_fs.Query(qcOpaque, arg, nullptr),
"In EOSReporter::reportArchiveFullyComplete(): failed to XrdCl::FileSystem::Query()");
}
}} // 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 "DiskReporter.hpp"
#include <XrdCl/XrdClFileSystem.hh>
namespace cta { namespace disk {
class EOSReporter: public DiskReporter {
public:
EOSReporter(const std::string & hostURL, const std::string & queryValue);
void reportArchiveFullyComplete() override;
private:
XrdCl::FileSystem m_fs;
std::string m_query;
};
}} // 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 "DiskReporter.hpp"
namespace cta { namespace disk {
class NullReporter: public DiskReporter {
public:
NullReporter() {};
void reportArchiveFullyComplete() override {};
};
}} // namespace cta::disk
\ No newline at end of file
......@@ -83,6 +83,8 @@ void cta::ArchiveJob::complete() {
m_catalogue.fileWrittenToTape (fileReport);
//m_ns.addTapeFile(SecurityIdentity(UserIdentity(std::numeric_limits<uint32_t>::max(),
// std::numeric_limits<uint32_t>::max()), ""), archiveFile.fileId, nameServerTapeFile);
// We will now report the successful archival to the EOS instance.
// if TODO TODO
// We can now record the success for the job in the database
m_dbJob->succeed();
}
......
......@@ -29,8 +29,7 @@ set(TAPESERVER_FILE_LIBRARY_SRCS
File.cpp
DiskFile.cpp
RadosStriperPool.cpp
Structures.cpp
../exception/XrootCl.cpp)
Structures.cpp)
if(CMAKE_COMPILER_IS_GNUCC)
if(GCC_VERSION_GE_4_8_0)
......
......@@ -26,7 +26,7 @@
#include "castor/tape/tapeserver/file/DiskFile.hpp"
#include "castor/tape/tapeserver/file/Structures.hpp"
#include "castor/tape/tapeserver/daemon/VolumeInfo.hpp"
#include "castor/tape/tapeserver/exception/XrootCl.hpp"
#include "common/exception/XrootCl.hpp"
#include "common/exception/Exception.hpp"
#include <xrootd/XrdCl/XrdClFile.hh>
#include <cryptopp/rsa.h>
......@@ -87,7 +87,7 @@ namespace castor {
mutable XrdCl::File m_xrootFile;
mutable uint64_t m_readPosition;
const uint16_t m_timeout;
typedef castor::tape::server::exception::XrootCl XrootClEx;
typedef cta::exception::XrootCl XrootClEx;
};
class XrootReadFile: public XrootBaseReadFile {
......@@ -118,7 +118,7 @@ namespace castor {
XrdCl::File m_xrootFile;
uint64_t m_writePosition;
const uint16_t m_timeout;
typedef castor::tape::server::exception::XrootCl XrootClEx;
typedef cta::exception::XrootCl XrootClEx;
bool m_closeTried;
};
......@@ -154,7 +154,7 @@ namespace castor {
mutable XrdCl::File m_xrootFile;
mutable uint64_t m_readPosition;
const uint16_t m_timeout;
typedef castor::tape::server::exception::XrootCl XrootClEx;
typedef cta::exception::XrootCl XrootClEx;
};
class EosWriteFile: public WriteFile {
......@@ -169,7 +169,7 @@ namespace castor {
XrdCl::File m_xrootFile;
uint64_t m_writePosition;
const uint16_t m_timeout;
typedef castor::tape::server::exception::XrootCl XrootClEx;
typedef cta::exception::XrootCl XrootClEx;
bool m_closeTried;
};
......
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