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

Merge remote branch 'origin/master'

parents b6d38593 3ffb3b2b
No related branches found
No related tags found
No related merge requests found
cmake_minimum_required (VERSION 2.6)
set (CTA_REMOTENS_SRC_FILES
EosNS.cpp
MockRemoteNS.cpp
RemoteNS.cpp
RemoteNSDispatcher.cpp)
......@@ -8,6 +9,11 @@ set (CTA_REMOTENS_SRC_FILES
add_library (ctaremotens SHARED
${CTA_REMOTENS_SRC_FILES})
find_package (xrootd REQUIRED)
include_directories (${XROOTD_INCLUDE_DIR} ${XROOTD_PRIVATE_INCLUDE_DIR} ${CMAKE_SOURCE_DIR})
target_link_libraries (ctaremotens ${XROOTD_XRDCL_LIB} ctacommon cryptopp)
add_library (ctaremotenstest SHARED
MockRemoteNS.cpp
MockRemoteNSFactory.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 <map>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "common/exception/Exception.hpp"
#include "common/RemotePath.hpp"
#include "common/Utils.hpp"
#include "remotens/EosNS.hpp"
#include <cryptopp/base64.h>
#include <cryptopp/osrng.h>
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::EosNS::EosNS(const std::string &XrootServerURL): m_fs(XrdCl::URL(XrootServerURL)) {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::EosNS::~EosNS() throw() {
}
//------------------------------------------------------------------------------
// statFile
//------------------------------------------------------------------------------
std::unique_ptr<cta::RemoteFileStatus> cta::EosNS::statFile(const RemotePath &path) {
XrdCl::StatInfo *stat_res = NULL;
XrdCl::XRootDStatus s = m_fs.Stat(path.getAfterScheme(), stat_res, 0);
if(!s.IsOK()) {
delete stat_res;
return std::unique_ptr<RemoteFileStatus>();
}
UserIdentity owner(0,0);
cta::RemoteFileStatus *rfs = new cta::RemoteFileStatus(owner, stat_res->GetFlags(), stat_res->GetSize());
delete stat_res;
return std::unique_ptr<RemoteFileStatus>(rfs);
}
//------------------------------------------------------------------------------
// rename
//------------------------------------------------------------------------------
void cta::EosNS::rename(const RemotePath &remoteFile, const RemotePath &newRemoteFile) {
}
//------------------------------------------------------------------------------
// getFilename
//------------------------------------------------------------------------------
std::string cta::EosNS::getFilename(const RemotePath &remoteFile) const {
const std::string afterScheme = remoteFile.getAfterScheme();
const std::string afterSchemeTrimmed = Utils::trimSlashes(afterScheme);
return Utils::getEnclosedName(afterSchemeTrimmed);
}
//------------------------------------------------------------------------------
// createEntry
//------------------------------------------------------------------------------
void cta::EosNS::createEntry(const RemotePath &path, const RemoteFileStatus &status) {
}
//------------------------------------------------------------------------------
// sendCommand
//------------------------------------------------------------------------------
int cta::EosNS::sendCommand(const std::string &cmd) const {
std::string cmdPath = "root://localhost:1094//";
return 0;
}
\ 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 "common/RemoteFileStatus.hpp"
#include "remotens/RemoteNS.hpp"
#include "XrdCl/XrdClFileSystem.hh"
#include <map>
namespace cta {
/**
* A mock proxy class for the namespace of a remote storage system.
*/
class EosNS: public RemoteNS {
public:
/**
* Destructor.
*/
~EosNS() throw();
/**
* Constructor.
*/
EosNS(const std::string &XrootServerURL = "localhost:1094");
/**
* Returns the status of the specified file or directory within the remote
* storage system or NULL if the fil eor directory does not exist.
*
* @param path The absolute path of the file or directory.
* @return The status of the file or directory or NULL if the file or
* directory does not exist.
*/
std::unique_ptr<RemoteFileStatus> statFile(const RemotePath &path);
/**
* Renames the specified remote file to the specified new name.
*
* @param remoteFile The current path.
* @param newRemoteFile The new path.
*/
void rename(const RemotePath &remoteFile, const RemotePath &newRemoteFile);
/**
* Parses the specified remote file and returns the file name.
*
* @param path The absolute path of the file.
* @return The file name.
*/
std::string getFilename(const RemotePath &remoteFile) const;
/**
* Adds a directory or file to the remote NS with the desired status
*
* @param status The desired status of the entry to be created
* @param path The absolute path of the file or directory
*/
void createEntry(const RemotePath &path, const RemoteFileStatus &status);
private:
/**
* The xroot server of EOS
*/
XrdCl::FileSystem m_fs;
/**
* Sends the command and waits for the reply
*
* @param argc The number of command-line arguments.
* @param argv The command-line arguments.
* @return the return code
*/
int sendCommand(const std::string &cmd) const;
}; // class EosNS
} // namespace cta
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment