Commit d1c53c27 authored by Michael Davis's avatar Michael Davis
Browse files

Deletes source code for deprecated OFS plugin

parent dbcdc6d4
......@@ -44,34 +44,6 @@ endif (OCCI_SUPPORT)
# Get some extra debug messages on stderr
#target_compile_definitions(XrdSsiCta PRIVATE XRDSSI_DEBUG)
####################################################################################################
#
# XRootD OFS plugin for CTA Frontend (DEPRECATED)
#
#add_library (XrdCtaOfs MODULE
# ListArchiveFilesCmd.cpp
# XrdCtaFilesystem.cpp
# XrdCtaFile.cpp
# XrdCtaDir.cpp)
#if(CMAKE_COMPILER_IS_GNUCC)
# # Add -Wno-implicit-fallthrough compiler flag if using gcc version 7 or greater
# if (GCC_VERSION VERSION_EQUAL 7 OR GCC_VERSION VERSION_GREATER 7)
# set_property(SOURCE XrdCtaFile.cpp APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-implicit-fallthrough")
# endif (GCC_VERSION VERSION_EQUAL 7 OR GCC_VERSION VERSION_GREATER 7)
#endif(CMAKE_COMPILER_IS_GNUCC)
#
#set_property(TARGET XrdCtaOfs PROPERTY SOVERSION "${CTA_SOVERSION}")
#set_property(TARGET XrdCtaOfs PROPERTY VERSION "${CTA_LIBVERSION}")
#target_link_libraries (XrdCtaOfs ctacatalogue ctascheduler ctacommon ctaobjectstore cryptopp)
#set_property (TARGET XrdCtaOfs APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH})
#if (OCCI_SUPPORT)
# set_property (TARGET XrdCtaOfs APPEND PROPERTY INSTALL_RPATH ${ORACLE-INSTANTCLIENT_RPATH})
#endif (OCCI_SUPPORT)
#
#install (TARGETS XrdCtaOfs DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
#
####################################################################################################
install(TARGETS XrdSsiCta DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
install(FILES cta-frontend-xrootd.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cta)
install(FILES cta-frontend.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cta)
......
/*
* 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 "xroot_plugins/CmdLineTool.hpp"
#include "common/exception/CommandLineNotParsed.hpp"
#include <unistd.h>
namespace cta {
namespace xroot_plugins {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
CmdLineTool::CmdLineTool(
std::istream &inStream,
std::ostream &outStream,
std::ostream &errStream) noexcept:
m_in(inStream),
m_out(outStream),
m_err(errStream) {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
CmdLineTool::~CmdLineTool() noexcept {
}
//------------------------------------------------------------------------------
// getUsername
//------------------------------------------------------------------------------
std::string CmdLineTool::getUsername() {
char buf[256];
if(getlogin_r(buf, sizeof(buf))) {
return "UNKNOWN";
} else {
return buf;
}
}
//------------------------------------------------------------------------------
// getHostname
//------------------------------------------------------------------------------
std::string CmdLineTool::getHostname() {
char buf[256];
if(gethostname(buf, sizeof(buf))) {
return "UNKNOWN";
} else {
buf[sizeof(buf) - 1] = '\0';
return buf;
}
}
//------------------------------------------------------------------------------
// main
//------------------------------------------------------------------------------
int CmdLineTool::main(const int argc, char *const *const argv) {
bool cmdLineNotParsed = false;
std::string errorMessage;
try {
return exceptionThrowingMain(argc, argv);
} catch(exception::CommandLineNotParsed &ue) {
errorMessage = ue.getMessage().str();
cmdLineNotParsed = true;
} catch(exception::Exception &ex) {
errorMessage = ex.getMessage().str();
} catch(std::exception &se) {
errorMessage = se.what();
} catch(...) {
errorMessage = "An unknown exception was thrown";
}
// Reaching this point means the command has failed, an exception was throw
// and errorMessage has been set accordingly
m_err << "Aborting: " << errorMessage << std::endl;
if(cmdLineNotParsed) {
m_err << std::endl;
printUsage(m_err);
}
return 1;
}
} // namespace xroot_plugins
} // namespace cta
/*
* 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 <istream>
#include <ostream>
namespace cta {
namespace xroot_plugins {
/**
* Abstract class implementing common code and data structures for a
* command-line tool.
*/
class CmdLineTool {
public:
/**
* Constructor.
*
* @param inStream Standard input stream.
* @param outStream Standard output stream.
* @param errStream Standard error stream.
*/
CmdLineTool(std::istream &inStream, std::ostream &outStream, std::ostream &errStream) noexcept;
/**
* Pure-virtual destructor to guarantee this class is abstract.
*/
virtual ~CmdLineTool() noexcept = 0;
/**
* The object's implementation of main() that should be called from the main()
* of the program.
*
* @param argc The number of command-line arguments including the program name.
* @param argv The command-line arguments.
* @return The exit value of the program.
*/
int main(const int argc, char *const *const argv);
protected:
/**
* An exception throwing version of main().
*
* @param argc The number of command-line arguments including the program name.
* @param argv The command-line arguments.
* @return The exit value of the program.
*/
virtual int exceptionThrowingMain(const int argc, char *const *const argv) = 0;
/**
* Prints the usage message of the command-line tool.
*
* @param os The output stream to which the usage message is to be printed.
*/
virtual void printUsage(std::ostream &os) = 0;
/**
* Standard input stream.
*/
std::istream &m_in;
/**
* Standard output stream.
*/
std::ostream &m_out;
/**
* Standard error stream.
*/
std::ostream &m_err;
/**
* Returns the name of the user running the command-line tool.
*
* @return The name of the user running the command-line tool.
*/
static std::string getUsername();
/**
* Returns the name of the host on which the command-line tool is running.
*
* @return The name of the host on which the command-line tool is running.
*/
static std::string getHostname();
}; // class CmdLineTool
} // namespace xroot_plugins
} // namespace cta
/*
* 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 "xroot_plugins/ListArchiveFilesCmd.hpp"
#include <iomanip>
#include <sstream>
#include <stdint.h>
namespace cta {
namespace xrootPlugins {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
ListArchiveFilesCmd::ListArchiveFilesCmd(
XrdOucErrInfo &xrdSfsFileError,
const bool displayHeader,
catalogue::ArchiveFileItor archiveFileItor):
m_xrdSfsFileError(xrdSfsFileError),
m_displayHeader(displayHeader),
m_archiveFileItor(std::move(archiveFileItor)) {
}
//------------------------------------------------------------------------------
// read
//------------------------------------------------------------------------------
XrdSfsXferSize ListArchiveFilesCmd::read(XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize size) {
try {
return exceptionThrowingRead(offset, buffer, size);
} catch(exception::Exception &ex) {
std::ostringstream errMsg;
errMsg << __FUNCTION__ << " failed: " << ex.getMessage().str();
m_xrdSfsFileError.setErrInfo(ECANCELED, errMsg.str().c_str());
return SFS_ERROR;
} catch(std::exception &se) {
std::ostringstream errMsg;
errMsg << __FUNCTION__ << " failed: " << se.what();
m_xrdSfsFileError.setErrInfo(ECANCELED, errMsg.str().c_str());
return SFS_ERROR;
} catch(...) {
std::ostringstream errMsg;
errMsg << __FUNCTION__ << " failed: Caught an unknown exception";
m_xrdSfsFileError.setErrInfo(ECANCELED, errMsg.str().c_str());
return SFS_ERROR;
}
}
//------------------------------------------------------------------------------
// exceptionThrowingRead
//------------------------------------------------------------------------------
XrdSfsXferSize ListArchiveFilesCmd::exceptionThrowingRead(XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize size) {
if(State::LISTED_LAST_ARCHIVE_FILE == m_state) {
return SFS_OK;
}
if(State::WAITING_FOR_FIRST_READ == m_state) {
m_state = State::LISTING_ARCHIVE_FILES;
// The first character of the reply stream is the return code
m_readBuffer << "0";
if(m_displayHeader) {
m_readBuffer <<
"\x1b[31;1m" << // Change the colour of the output text to red
std::setfill(' ') << std::setw(7) << std::right << "id" << " " <<
std::setfill(' ') << std::setw(7) << std::right << "copy no" << " " <<
std::setfill(' ') << std::setw(7) << std::right << "vid" << " " <<
std::setfill(' ') << std::setw(7) << std::right << "fseq" << " " <<
std::setfill(' ') << std::setw(8) << std::right << "block id" << " " <<
std::setfill(' ') << std::setw(8) << std::right << "instance" << " " <<
std::setfill(' ') << std::setw(7) << std::right << "disk id" << " " <<
std::setfill(' ') << std::setw(12) << std::right << "size" << " " <<
std::setfill(' ') << std::setw(13) << std::right << "checksum type" << " " <<
std::setfill(' ') << std::setw(14) << std::right << "checksum value" << " " <<
std::setfill(' ') << std::setw(13) << std::right << "storage class" << " " <<
std::setfill(' ') << std::setw(8) << std::right << "owner" << " " <<
std::setfill(' ') << std::setw(8) << std::right << "group" << " " <<
std::setfill(' ') << std::setw(13) << std::right << "creation time" << " " <<
"path" <<
"\x1b[0m\n"; // Return the colour of the output text
}
}
if(offset != m_expectedFileOffset) {
std::ostringstream errMsg;
errMsg << "Unexpected read offset: expected=" << m_expectedFileOffset << " actual=" << offset;
m_xrdSfsFileError.setErrInfo(ESPIPE, errMsg.str().c_str());
return SFS_ERROR;
}
XrdSfsXferSize offSetIntoReadBuffer = offset - m_fileOffsetOfReadBuffer;
if(0 > offSetIntoReadBuffer) {
std::ostringstream errMsg;
errMsg << "offSetIntoReadBuffer must be positive: actual=" << offSetIntoReadBuffer;
m_xrdSfsFileError.setErrInfo(ESPIPE, errMsg.str().c_str());
return SFS_ERROR;
}
XrdSfsXferSize nbBytesToBeReadFromBuffer = (XrdSfsXferSize)m_readBuffer.str().size() - offSetIntoReadBuffer;
if(0 > nbBytesToBeReadFromBuffer) {
std::ostringstream errMsg;
errMsg << "nbBytesToBeReadFromBuffer must be positive: actual=" << nbBytesToBeReadFromBuffer;
m_xrdSfsFileError.setErrInfo(ESPIPE, errMsg.str().c_str());
return SFS_ERROR;
}
if(nbBytesToBeReadFromBuffer == 0) {
refreshReadBuffer();
if (m_readBuffer.str().empty()) {
m_state = State::LISTED_LAST_ARCHIVE_FILE;
return SFS_OK;
}
m_fileOffsetOfReadBuffer = offset;
offSetIntoReadBuffer = 0;
nbBytesToBeReadFromBuffer = m_readBuffer.str().size();
}
const XrdSfsXferSize actualNbBytesToRead = nbBytesToBeReadFromBuffer >= size ? size : nbBytesToBeReadFromBuffer;
if(0 > actualNbBytesToRead) {
std::ostringstream errMsg;
errMsg << "actualNbBytesToRead must be positive: actual=" << actualNbBytesToRead;
m_xrdSfsFileError.setErrInfo(ESPIPE, errMsg.str().c_str());
return SFS_ERROR;
}
strncpy(buffer, m_readBuffer.str().c_str() + offSetIntoReadBuffer, actualNbBytesToRead);
m_expectedFileOffset += actualNbBytesToRead;
return actualNbBytesToRead;
}
//------------------------------------------------------------------------------
// refreshReadBuffer
//------------------------------------------------------------------------------
void ListArchiveFilesCmd::refreshReadBuffer() {
// Note that one archive file may have more than one tape file
const uint32_t nbArchiveFilesToFetch = 100;
uint32_t nbFetchedArchiveFiles = 0;
// Clear the read buffer
m_readBuffer.str(std::string());
while(m_archiveFileItor.hasMore() && nbArchiveFilesToFetch > nbFetchedArchiveFiles) {
const common::dataStructures::ArchiveFile archiveFile = m_archiveFileItor.next();
nbFetchedArchiveFiles++;
for(auto copyNbToTapeFile: archiveFile.tapeFiles) {
const auto copyNb = copyNbToTapeFile.first;
const common::dataStructures::TapeFile &tapeFile = copyNbToTapeFile.second;
m_readBuffer <<
std::setfill(' ') << std::setw(7) << std::right << archiveFile.archiveFileID << " " <<
std::setfill(' ') << std::setw(7) << std::right << copyNb << " " <<
std::setfill(' ') << std::setw(7) << std::right << tapeFile.vid << " " <<
std::setfill(' ') << std::setw(7) << std::right << tapeFile.fSeq << " " <<
std::setfill(' ') << std::setw(8) << std::right << tapeFile.blockId << " " <<
std::setfill(' ') << std::setw(8) << std::right << archiveFile.diskInstance << " " <<
std::setfill(' ') << std::setw(7) << std::right << archiveFile.diskFileId << " " <<
std::setfill(' ') << std::setw(12) << std::right << archiveFile.fileSize << " " <<
std::setfill(' ') << std::setw(13) << std::right << archiveFile.checksumType << " " <<
std::setfill(' ') << std::setw(14) << std::right << archiveFile.checksumValue << " " <<
std::setfill(' ') << std::setw(13) << std::right << archiveFile.storageClass << " " <<
std::setfill(' ') << std::setw(8) << std::right << archiveFile.diskFileInfo.owner << " " <<
std::setfill(' ') << std::setw(8) << std::right << archiveFile.diskFileInfo.group << " " <<
std::setfill(' ') << std::setw(13) << std::right << archiveFile.creationTime << " " <<
archiveFile.diskFileInfo.path << "\n";
}
}
}
//------------------------------------------------------------------------------
// stateToStr
//------------------------------------------------------------------------------
std::string ListArchiveFilesCmd::stateToStr(const State state) const {
switch(state) {
case WAITING_FOR_FIRST_READ:
return "WAITING_FOR_FIRST_READ";
case LISTING_ARCHIVE_FILES:
return "LISTING_ARCHIVE_FILES";
case LISTED_LAST_ARCHIVE_FILE:
return "LISTED_LAST_ARCHIVE_FILE";
default:
return "UNKNOWN";
}
}
} // namespace xrootPlugins
} // namespace cta
/*
* 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 "catalogue/Catalogue.hpp"
#include "catalogue/TapeFileSearchCriteria.hpp"
#include "common/log/Logger.hpp"
#include <XrdSfs/XrdSfsInterface.hh>
#include <sstream>
#include <string>
namespace cta {
namespace xrootPlugins {
/**
* Server-side class implementing the listing of one or more archive files.
*/
class ListArchiveFilesCmd {
public:
/**
* Constructor.
*
* @param log The object representing the API of the CTA logging system.
* @param xrdSfsFileError The error member-variable of the XrdSfsFile class.
* @param displayHeader Set to true if the user requested the header to be
* displayed.
* @param archiveFileItor Iterator over the archive files in the CTA catalogue that are to be listed.
*/
ListArchiveFilesCmd(
XrdOucErrInfo &xrdSfsFileError,
const bool displayHeader,
catalogue::ArchiveFileItor archiveFileItor);
/**
* Indirectly implements the XrdSfsFile::read() method.
*/
XrdSfsXferSize read(XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize size);
protected:
/**
* The error member-variable of the XrdSfsFile class.
*/
XrdOucErrInfo &m_xrdSfsFileError;
/**
* Set to true if the user requested the columns header to be display.
*/
bool m_displayHeader = false;
/**
* Enumeration of the possible states of the "list archive files" command.
*/
enum State {
WAITING_FOR_FIRST_READ,
LISTING_ARCHIVE_FILES,
LISTED_LAST_ARCHIVE_FILE};
/**
* Returns the string representation of the specified state.
* @param state The state.
* @return The string representation of the state.
*/
std::string stateToStr(const State state) const;
/**
* The current state of the "list archive files" command.
*/
State m_state = WAITING_FOR_FIRST_READ;
/**
* Iterator over the archive files in the CTA catalogue that are to be listed.
*/
catalogue::ArchiveFileItor m_archiveFileItor;
/**
* The buffer that sits between calls to ListArchiveFilesCmd::read() and calls
* to the CTA catalogue.
*
* The XRootD server calls XrdCtaFile::read() which in turn calls
* ListArchiveFilesCmd::read() which in turn calls the CTA catalogue. Both
* read() method are byte oriented whereas the CTA catalogue is record
* oriented. This buffer ties the byte oriented read() calls to the records
* of the CTA catalogue.
*
*/
std::ostringstream m_readBuffer;
/**
* The offset in the reply file at which the current m_readBuffer starts.
*/
XrdSfsFileOffset m_fileOffsetOfReadBuffer = 0;
/**
* The file offset expected in the next call to ListArchiveFilesCmd::read();
*/
XrdSfsFileOffset m_expectedFileOffset = 0;
/**
* Refreshes the read buffer by first clearing it and then attempting to write
* into it more records from the CTA catalogue.
*/
void refreshReadBuffer();
/**
* Indirectly implements the XrdSfsFile::read() method.
*/
XrdSfsXferSize exceptionThrowingRead(XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize size);
}; // class ListArchiveFilesCmd
} // namespace xrootPlugins
} // namespace cta
/*
* 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 <iostream>
#include "XrdSec/XrdSecEntity.hh"
#include "catalogue/TapeFileSearchCriteria.hpp"
#include "xroot_plugins/XrdCtaDir.hpp"
namespace cta { namespace xrootPlugins {
//------------------------------------------------------------------------------
// checkClient