diff --git a/xroot_clients/CMakeLists.txt b/xroot_clients/CMakeLists.txt index 8707dd707e9917d07846244597f1eb6db705145f..c6f7107ee7295d25fe437f82aff77dc929ae3d82 100644 --- a/xroot_clients/CMakeLists.txt +++ b/xroot_clients/CMakeLists.txt @@ -6,3 +6,6 @@ include_directories (${XROOTD_INCLUDE_DIR} ${XROOTD_PRIVATE_INCLUDE_DIR} ${CMAKE add_executable (CTA_cmd CTACmdMain.cpp CTACmd.cpp) target_link_libraries (CTA_cmd ${XROOTD_XRDCL_LIB}) + +add_executable (CTA_copycmd CTACopyCmdMain.cpp CTACopyCmd.cpp) +target_link_libraries (CTA_copycmd ${XROOTD_XRDCL_LIB}) diff --git a/xroot_clients/CTACopyCmd.cpp b/xroot_clients/CTACopyCmd.cpp new file mode 100644 index 0000000000000000000000000000000000000000..33a07fe5aeb288ef5a9ba25280841629a96a2ae2 --- /dev/null +++ b/xroot_clients/CTACopyCmd.cpp @@ -0,0 +1,88 @@ +#include "CTACopyCmd.hpp" + +#include "XrdCl/XrdClFileSystem.hh" +#include "XrdCl/XrdClCopyProcess.hh" +#include "XrdOuc/XrdOucString.hh" + +#include <getopt.h> +#include <iostream> +#include <string.h> + +//------------------------------------------------------------------------------ +// constructor +//------------------------------------------------------------------------------ +CTACopyCmd::CTACopyCmd() throw(): m_programName("CTA_copycmd") { +} + +//------------------------------------------------------------------------------ +// usage +//------------------------------------------------------------------------------ +void CTACopyCmd::usage(std::ostream &os) const throw() { + os << + "Usage:\n" + "\t" << m_programName << " ls <directory_name>\n"; +} + +//------------------------------------------------------------------------------ +// main +//------------------------------------------------------------------------------ +int CTACopyCmd::main(const int argc, char **argv) throw() { +// if(argc < 2) { +// usage(std::cerr); +// return 1; +// } + int rc = 1; + + // Execute the command + try { + rc = executeCommand(argc, argv); + } catch(std::exception &ex) { + std::cerr << std::endl << "Failed to execute the archive command:\n\n" << ex.what() << std::endl; + return 1; + } + + return rc; +} + +//------------------------------------------------------------------------------ +// executeCommand +//------------------------------------------------------------------------------ +int CTACopyCmd::executeCommand(const int argc, char **argv) { + XrdCl::PropertyList properties; + properties.Set("source", "/afs/cern.ch/user/d/dkruse/vmgrlisttape.txt2"); + properties.Set("target", "/afs/cern.ch/user/d/dkruse/vmgrlisttape.txt3"); + XrdCl::PropertyList results; + XrdCl::CopyProcess copyProcess; + + XrdCl::XRootDStatus status = copyProcess.AddJob(properties, &results); + if(status.IsOK()) + { + std::cout << "Job added" << std::endl; + } + else + { + std::cout << "Job adding error" << std::endl; + } + + status = copyProcess.Prepare(); + if(status.IsOK()) + { + std::cout << "Job prepared" << std::endl; + } + else + { + std::cout << "Job preparing error" << std::endl; + } + + XrdCl::CopyProgressHandler copyProgressHandler; + status = copyProcess.Run(©ProgressHandler); + if(status.IsOK()) + { + std::cout << "Copy OK" << std::endl; + } + else + { + std::cout << "Copy error" << std::endl; + } + return 0; +} diff --git a/xroot_clients/CTACopyCmd.hpp b/xroot_clients/CTACopyCmd.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d67ca836b258e961c3a3f4c27429264358a040cd --- /dev/null +++ b/xroot_clients/CTACopyCmd.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include <exception> +#include <istream> +#include <ostream> +#include <string> + +/** + * Class implementing the business logic of the archive command-line tool. + */ +class CTACopyCmd { +public: + /** + * Constructor. + */ + CTACopyCmd() throw(); + + /** + * The entry function of the command. + * + * @param argc The number of command-line arguments. + * @param argv The command-line arguments. + */ + int main(const int argc, char **argv) throw(); + +protected: + + /** + * The name of the program. + */ + const std::string m_programName; + + /** + * Writes the command-line usage message of to the specified output stream. + * + * @param os Output stream to be written to. + */ + void usage(std::ostream &os) const throw(); + + /** + * Sends the archive request and waits for the reply + * + * @param argc The number of command-line arguments. + * @param argv The command-line arguments. + * @return the return code + */ + int executeCommand(const int argc, char **argv) ; + +}; // class CTACopyCmd diff --git a/xroot_clients/CTACopyCmdMain.cpp b/xroot_clients/CTACopyCmdMain.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4650bdc44656d0b23d1d4aef008f633aaaac0f1a --- /dev/null +++ b/xroot_clients/CTACopyCmdMain.cpp @@ -0,0 +1,11 @@ +#include "CTACopyCmd.hpp" + +//------------------------------------------------------------------------------ +// main +//------------------------------------------------------------------------------ +int main(int argc, char **argv) { + + CTACopyCmd command; + + return command.main(argc, argv); +} diff --git a/xroot_plugins/CMakeLists.txt b/xroot_plugins/CMakeLists.txt index c68aefd0003dec650b499938fa7d8a8c1aa68085..5c32f90cdd9e5835d3b09f10c9c6d1813e705eca 100644 --- a/xroot_plugins/CMakeLists.txt +++ b/xroot_plugins/CMakeLists.txt @@ -4,5 +4,5 @@ list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) find_package (xrootd REQUIRED) include_directories (${XROOTD_INCLUDE_DIR} ${XROOTD_PRIVATE_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}) -add_library (XrdProFst MODULE XrdProFilesystem.cpp ParsedRequest.cpp) +add_library (XrdProFst MODULE XrdProFilesystem.cpp XrdProFile.cpp ParsedRequest.cpp) target_link_libraries (XrdProFst ctaclient) \ No newline at end of file diff --git a/xroot_plugins/XrdProFile.cpp b/xroot_plugins/XrdProFile.cpp new file mode 100644 index 0000000000000000000000000000000000000000..744ed012ba3e6e8ee4e2e9b684ad30675e1711ad --- /dev/null +++ b/xroot_plugins/XrdProFile.cpp @@ -0,0 +1,150 @@ +#include "XrdProFile.hpp" + +//------------------------------------------------------------------------------ +// open +//------------------------------------------------------------------------------ +int XrdProFile::open(const char *fileName, XrdSfsFileOpenMode openMode, mode_t createMode, const XrdSecEntity *client, const char *opaque){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return SFS_ERROR; +} + +//------------------------------------------------------------------------------ +// close +//------------------------------------------------------------------------------ +int XrdProFile::close(){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return SFS_ERROR; +} + +//------------------------------------------------------------------------------ +// fctl +//------------------------------------------------------------------------------ +int XrdProFile::fctl(const int cmd, const char *args, XrdOucErrInfo &eInfo){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return SFS_ERROR; +} + +//------------------------------------------------------------------------------ +// FName +//------------------------------------------------------------------------------ +const char* XrdProFile::FName(){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return NULL; +} + +//------------------------------------------------------------------------------ +// getMmap +//------------------------------------------------------------------------------ +int XrdProFile::getMmap(void **Addr, off_t &Size){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return SFS_ERROR; +} + +//------------------------------------------------------------------------------ +// read +//------------------------------------------------------------------------------ +XrdSfsXferSize XrdProFile::read(XrdSfsFileOffset offset, XrdSfsXferSize size){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return 0; +} + +//------------------------------------------------------------------------------ +// read +//------------------------------------------------------------------------------ +XrdSfsXferSize XrdProFile::read(XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize size){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return 0; +} + +//------------------------------------------------------------------------------ +// read +//------------------------------------------------------------------------------ +XrdSfsXferSize XrdProFile::read(XrdSfsAio *aioparm){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return 0; +} + +//------------------------------------------------------------------------------ +// write +//------------------------------------------------------------------------------ +XrdSfsXferSize XrdProFile::write(XrdSfsFileOffset offset, const char *buffer, XrdSfsXferSize size){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return 0; +} + +//------------------------------------------------------------------------------ +// write +//------------------------------------------------------------------------------ +int XrdProFile::write(XrdSfsAio *aioparm){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return SFS_ERROR; +} + +//------------------------------------------------------------------------------ +// stat +//------------------------------------------------------------------------------ +int XrdProFile::stat(struct stat *buf){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return SFS_ERROR; +} + +//------------------------------------------------------------------------------ +// sync +//------------------------------------------------------------------------------ +int XrdProFile::sync(){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return SFS_ERROR; +} + +//------------------------------------------------------------------------------ +// sync +//------------------------------------------------------------------------------ +int XrdProFile::sync(XrdSfsAio *aiop){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return SFS_ERROR; +} + +//------------------------------------------------------------------------------ +// truncate +//------------------------------------------------------------------------------ +int XrdProFile::truncate(XrdSfsFileOffset fsize){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return SFS_ERROR; +} + +//------------------------------------------------------------------------------ +// getCXinfo +//------------------------------------------------------------------------------ +int XrdProFile::getCXinfo(char cxtype[4], int &cxrsz){ + + error.setErrInfo(ENOTSUP, "Not supported."); + return SFS_ERROR; +} + +//------------------------------------------------------------------------------ +// Constructor +//------------------------------------------------------------------------------ +XrdProFile::XrdProFile(const char *user, int MonID): error(user, MonID){ + +} + +//------------------------------------------------------------------------------ +// Destructor +//------------------------------------------------------------------------------ +XrdProFile::~XrdProFile(){ + +} \ No newline at end of file diff --git a/xroot_plugins/XrdProFile.hpp b/xroot_plugins/XrdProFile.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0f2122f376c924c547c3dd6e762c02f49a6c24f6 --- /dev/null +++ b/xroot_plugins/XrdProFile.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "XrdSfs/XrdSfsInterface.hh" + +class XrdProFile : public XrdSfsFile { +public: + XrdOucErrInfo error; + virtual int open(const char *fileName, XrdSfsFileOpenMode openMode, mode_t createMode, const XrdSecEntity *client = 0, const char *opaque = 0); + virtual int close(); + virtual int fctl(const int cmd, const char *args, XrdOucErrInfo &eInfo); + virtual const char *FName(); + virtual int getMmap(void **Addr, off_t &Size); + virtual XrdSfsXferSize read(XrdSfsFileOffset offset, XrdSfsXferSize size); + virtual XrdSfsXferSize read(XrdSfsFileOffset offset, char *buffer, XrdSfsXferSize size); + virtual XrdSfsXferSize read(XrdSfsAio *aioparm); + virtual XrdSfsXferSize write(XrdSfsFileOffset offset, const char *buffer, XrdSfsXferSize size); + virtual int write(XrdSfsAio *aioparm); + virtual int stat(struct stat *buf); + virtual int sync(); + virtual int sync(XrdSfsAio *aiop); + virtual int truncate(XrdSfsFileOffset fsize); + virtual int getCXinfo(char cxtype[4], int &cxrsz); + XrdProFile(const char *user=0, int MonID=0); + ~XrdProFile(); +protected: + +}; \ No newline at end of file