Commit 21d9de41 authored by Eric Cano's avatar Eric Cano
Browse files

Moved cta::ArchiveFileStatus to cta::common::archiveNS::ArchiveFileStatus.

Removed archive and retrieve to directory requests.
parent 095fcb4b
......@@ -43,7 +43,7 @@ cta::common::archiveNS::ArchiveDirEntry::ArchiveDirEntry() {
cta::common::archiveNS::ArchiveDirEntry::ArchiveDirEntry(
const EntryType type,
const std::string &name,
const ArchiveFileStatus &status,
const common::archiveNS::ArchiveFileStatus &status,
const std::list<NameServerTapeFile> &tapeCopies):
type(type),
name(name),
......
......@@ -65,7 +65,7 @@ struct ArchiveDirEntry {
* @param status The status of the entry.
*/
ArchiveDirEntry(const EntryType type, const std::string &name,
const ArchiveFileStatus &status, const std::list<NameServerTapeFile> &tapeCopies);
const common::archiveNS::ArchiveFileStatus &status, const std::list<NameServerTapeFile> &tapeCopies);
/**
* The type of the directory entry.
......@@ -80,7 +80,7 @@ struct ArchiveDirEntry {
/**
* The status of the entry.
*/
ArchiveFileStatus status;
common::archiveNS::ArchiveFileStatus status;
/**
* The tape copies associated to this file.
......
......@@ -21,7 +21,7 @@
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::ArchiveFileStatus::ArchiveFileStatus():
cta::common::archiveNS::ArchiveFileStatus::ArchiveFileStatus():
fileId(0),
mode(0),
size(0) {
......@@ -30,7 +30,7 @@ cta::ArchiveFileStatus::ArchiveFileStatus():
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::ArchiveFileStatus::ArchiveFileStatus(
cta::common::archiveNS::ArchiveFileStatus::ArchiveFileStatus(
const UserIdentity &owner,
const uint64_t fileId,
const mode_t mode,
......
......@@ -24,7 +24,7 @@
#include <stdint.h>
#include <string>
namespace cta {
namespace cta { namespace common { namespace archiveNS {
/**
* The status of a file or a directory entry in the archive namespace.
......@@ -89,4 +89,4 @@ struct ArchiveFileStatus {
}; // class ArchiveFileStatus
} // namespace cta
}}} // namespace cta::common::archiveNS
......@@ -246,14 +246,14 @@ void cta::CastorNameServer::deleteDir(const SecurityIdentity &requester, const s
//------------------------------------------------------------------------------
// statFile
//------------------------------------------------------------------------------
std::unique_ptr<cta::ArchiveFileStatus> cta::CastorNameServer::statFile(
std::unique_ptr<cta::common::archiveNS::ArchiveFileStatus> cta::CastorNameServer::statFile(
const SecurityIdentity &requester, const std::string &path) const {
Utils::assertAbsolutePathSyntax(path);
struct Cns_filestatcs statbuf;
if(Cns_statcs(path.c_str(), &statbuf)) {
const int savedSerrno = serrno;
if(ENOENT == serrno) {
return std::unique_ptr<ArchiveFileStatus>();
return std::unique_ptr<common::archiveNS::ArchiveFileStatus>();
}
std::ostringstream msg;
......@@ -268,8 +268,8 @@ std::unique_ptr<cta::ArchiveFileStatus> cta::CastorNameServer::statFile(
struct Cns_fileclass cns_fileclass;
exception::Serrnum::throwOnMinusOne(Cns_queryclass(m_server.c_str(), statbuf.fileclass, NULL, &cns_fileclass), __FUNCTION__);
const std::string storageClassName(cns_fileclass.name);
return std::unique_ptr<ArchiveFileStatus>(
new ArchiveFileStatus(owner, statbuf.fileid, mode, size, checksum, storageClassName));
return std::unique_ptr<common::archiveNS::ArchiveFileStatus>(
new common::archiveNS::ArchiveFileStatus(owner, statbuf.fileid, mode, size, checksum, storageClassName));
}
//------------------------------------------------------------------------------
......@@ -335,7 +335,7 @@ cta::common::archiveNS::ArchiveDirEntry cta::CastorNameServer::getArchiveDirEntr
const UserIdentity owner(statbuf.uid, statbuf.gid);
const Checksum checksum(Checksum::CHECKSUMTYPE_ADLER32, std::string(statbuf.csumvalue));
const uint64_t size(statbuf.filesize);
ArchiveFileStatus status(owner, statbuf.fileid, statbuf.filemode, size, checksum, storageClassName);
common::archiveNS::ArchiveFileStatus status(owner, statbuf.fileid, statbuf.filemode, size, checksum, storageClassName);
const std::list<NameServerTapeFile> tapeCopies = getTapeFiles(requester, path);
return common::archiveNS::ArchiveDirEntry(entryType, name, status, tapeCopies);
......
......@@ -63,7 +63,7 @@ public:
void deleteDir(const SecurityIdentity &requester, const std::string &path);
std::unique_ptr<ArchiveFileStatus> statFile(const SecurityIdentity &requester, const std::string &path) const;
std::unique_ptr<common::archiveNS::ArchiveFileStatus> statFile(const SecurityIdentity &requester, const std::string &path) const;
common::archiveNS::ArchiveDirIterator getDirContents(const SecurityIdentity &requester, const std::string &path) const;
......
......@@ -96,7 +96,7 @@ public:
* @return The status of the file or directory or NULL if the file or
* directory does not exist.
*/
virtual std::unique_ptr<ArchiveFileStatus> statFile(
virtual std::unique_ptr<common::archiveNS::ArchiveFileStatus> statFile(
const SecurityIdentity &requester,
const std::string &path) const = 0;
......
......@@ -590,7 +590,7 @@ void cta::MockNameServer::deleteDir(const SecurityIdentity &requester,
//------------------------------------------------------------------------------
// statFile
//------------------------------------------------------------------------------
std::unique_ptr<cta::ArchiveFileStatus> cta::MockNameServer::statFile(
std::unique_ptr<cta::common::archiveNS::ArchiveFileStatus> cta::MockNameServer::statFile(
const SecurityIdentity &requester,
const std::string &path) const {
......@@ -603,7 +603,7 @@ std::unique_ptr<cta::ArchiveFileStatus> cta::MockNameServer::statFile(
if(::stat(fsPath.c_str(), &statResult)) {
const int savedErrno = errno;
if(ENOENT == savedErrno) {
return std::unique_ptr<cta::ArchiveFileStatus>();
return std::unique_ptr<cta::common::archiveNS::ArchiveFileStatus>();
}
std::ostringstream msg;
......@@ -613,8 +613,8 @@ std::unique_ptr<cta::ArchiveFileStatus> cta::MockNameServer::statFile(
}
common::archiveNS::ArchiveDirEntry entry = getArchiveDirEntry(requester, path, statResult);
return std::unique_ptr<ArchiveFileStatus>(
new ArchiveFileStatus(entry.status));
return std::unique_ptr<common::archiveNS::ArchiveFileStatus>(
new common::archiveNS::ArchiveFileStatus(entry.status));
}
//------------------------------------------------------------------------------
......@@ -734,7 +734,7 @@ cta::common::archiveNS::ArchiveDirEntry cta::MockNameServer::getArchiveDirEntry(
modeStrTr << modeStr;
mode_t mode;
modeStrTr >> std::oct >> mode;
ArchiveFileStatus status(owner, fileId, mode, size, checksum, storageClassName);
common::archiveNS::ArchiveFileStatus status(owner, fileId, mode, size, checksum, storageClassName);
return common::archiveNS::ArchiveDirEntry(entryType, name, status, tapeCopies);
}
......
......@@ -81,7 +81,7 @@ public:
void deleteDir(const SecurityIdentity &requester, const std::string &path);
std::unique_ptr<ArchiveFileStatus> statFile(const SecurityIdentity &requester, const std::string &path) const;
std::unique_ptr<common::archiveNS::ArchiveFileStatus> statFile(const SecurityIdentity &requester, const std::string &path) const;
common::archiveNS::ArchiveDirIterator getDirContents(const SecurityIdentity &requester, const std::string &path) const;
......
/*
* 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 "scheduler/ArchiveToDirRequest.hpp"
#include "scheduler/ArchiveToFileRequest.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::ArchiveToDirRequest::ArchiveToDirRequest() {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::ArchiveToDirRequest::~ArchiveToDirRequest() throw() {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::ArchiveToDirRequest::ArchiveToDirRequest(
const std::string &archiveDir,
const std::list<ArchiveToFileRequest> &archiveToFileRequests,
const uint64_t priority,
const CreationLog & creationLog):
UserArchiveRequest(priority, creationLog),
m_archiveDir(archiveDir),
m_archiveToFileRequests(archiveToFileRequests) {
}
//------------------------------------------------------------------------------
// getArchiveToFileRequests
//------------------------------------------------------------------------------
const std::list<cta::ArchiveToFileRequest> &cta::ArchiveToDirRequest::
getArchiveToFileRequests() const throw() {
return m_archiveToFileRequests;
}
//------------------------------------------------------------------------------
// getArchiveToFileRequests
//------------------------------------------------------------------------------
std::list<cta::ArchiveToFileRequest> &cta::ArchiveToDirRequest::
getArchiveToFileRequests() throw() {
return m_archiveToFileRequests;
}
/*
* 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 "scheduler/UserArchiveRequest.hpp"
#include <list>
#include <string>
namespace cta {
// Forward declarations
class ArchiveToFileRequest;
/**
* Class representing a user request to archive one or more remote files to an
* archive directory.
*/
class ArchiveToDirRequest: public UserArchiveRequest {
public:
/**
* Constructor.
*/
ArchiveToDirRequest();
/**
* Destructor.
*/
~ArchiveToDirRequest() throw();
/**
* Constructor.
*
* @param archiveDir The full path of the destination archive directory.
* @param archiveToFileRequests The list of the individual archive to file
* requests that make up this archive to directory request.
* @param priority The priority of the request.
* @param user The identity of the user who made the request.
* @param creationTime Optionally the absolute time at which the user request
* was created. If no value is given then the current time is used.
*/
ArchiveToDirRequest(
const std::string &archiveDir,
const std::list<ArchiveToFileRequest> &archiveToFileRequests,
const uint64_t priority,
const CreationLog & creationLog);
/**
* Returns the full path of the destination archive directory.
*
* @return The full path of the destination archive directory.
*/
const std::string &getArchiveDir() const throw();
/**
* Returns the list of the individual archive to individual file requests
* that make up this archive to directory request.
*
* @return The list of the individual archive to file requests that make up
* this archive to directory request.
*/
const std::list<ArchiveToFileRequest> &getArchiveToFileRequests() const
throw();
/**
* Returns the list of the individual archive to file requests that make up
* this archive to directory request.
*
* @return The list of the individual archive to file requests that make up
* this archive to directory request.
*/
std::list<ArchiveToFileRequest> &getArchiveToFileRequests() throw();
private:
/**
* The full path of the destination archive directory.
*/
std::string m_archiveDir;
/**
* The list of the individual archive to file requests that make up this
* archive to directory request.
*/
std::list<ArchiveToFileRequest> m_archiveToFileRequests;
}; // class ArchiveToDirRequest
} // namespace cta
......@@ -8,7 +8,6 @@ set (CTA_SCHEDULER_SRC_FILES
ArchiveJob.cpp
ArchiveMount.cpp
UserArchiveRequest.cpp
ArchiveToDirRequest.cpp
ArchiveToFileRequest.cpp
ArchiveToTapeCopyRequest.cpp
TapeMount.cpp
......@@ -22,7 +21,6 @@ set (CTA_SCHEDULER_SRC_FILES
RetrieveJob.cpp
RetrieveMount.cpp
UserRetrieveRequest.cpp
RetrieveToDirRequest.cpp
RetrieveToFileRequest.cpp
Scheduler.cpp
SchedulerDatabase.cpp
......
......@@ -30,14 +30,12 @@
#include "nameserver/NameServer.hpp"
#include "remotens/RemoteNS.hpp"
#include "scheduler/ArchiveMount.hpp"
#include "scheduler/ArchiveToDirRequest.hpp"
#include "scheduler/ArchiveToFileRequest.hpp"
#include "scheduler/ArchiveToTapeCopyRequest.hpp"
#include "scheduler/DummyScheduler.hpp"
#include "scheduler/LogicalLibrary.hpp"
#include "scheduler/RetrieveRequestDump.hpp"
#include "scheduler/RetrieveMount.hpp"
#include "scheduler/RetrieveToDirRequest.hpp"
#include "scheduler/RetrieveToFileRequest.hpp"
#include "scheduler/Scheduler.hpp"
#include "scheduler/SchedulerDatabase.hpp"
......@@ -384,10 +382,10 @@ cta::common::archiveNS::ArchiveDirIterator cta::DummyScheduler::getDirContents(
//------------------------------------------------------------------------------
// statArchiveFile
//------------------------------------------------------------------------------
std::unique_ptr<cta::ArchiveFileStatus> cta::DummyScheduler::statArchiveFile(
std::unique_ptr<cta::common::archiveNS::ArchiveFileStatus> cta::DummyScheduler::statArchiveFile(
const SecurityIdentity &requester,
const std::string &path) const {
return std::unique_ptr<cta::ArchiveFileStatus>();
return std::unique_ptr<cta::common::archiveNS::ArchiveFileStatus>();
}
//------------------------------------------------------------------------------
......
......@@ -504,7 +504,7 @@ public:
* @return The status of the file or directory or NULL the the file or
* directory does not exist.
*/
std::unique_ptr<ArchiveFileStatus> statArchiveFile(
std::unique_ptr<common::archiveNS::ArchiveFileStatus> statArchiveFile(
const SecurityIdentity &requester,
const std::string &path) const;
......
......@@ -35,10 +35,8 @@
#include "common/archiveNS/StorageClass.hpp"
#include "common/TapePool.hpp"
#include "common/archiveNS/Tape.hpp"
#include "ArchiveToDirRequest.hpp"
#include "RetrieveToFileRequest.hpp"
#include "common/archiveNS/TapeFileLocation.hpp"
#include "RetrieveToDirRequest.hpp"
#include "ArchiveToTapeCopyRequest.hpp"
#include "common/archiveNS/ArchiveFile.hpp"
#include <algorithm>
......@@ -729,13 +727,6 @@ std::unique_ptr<cta::SchedulerDatabase::ArchiveToFileRequestCreation>
return ret;
}
void OStoreDB::queue(const ArchiveToDirRequest& rqst) {
auto & archiveToFileRequests = rqst.getArchiveToFileRequests();
for(auto req=archiveToFileRequests.begin(); req!=archiveToFileRequests.end(); req++) {
queue(*req);
}
}
void OStoreDB::deleteArchiveRequest(const SecurityIdentity& requester,
const std::string& archiveFile) {
// First of, find the archive request form all the tape pools.
......@@ -1066,13 +1057,6 @@ void OStoreDB::queue(const cta::RetrieveToFileRequest& rqst) {
}
}
void OStoreDB::queue(const RetrieveToDirRequest& rqst) {
auto & retrieveToFileRequests = rqst.getRetrieveToFileRequests();
for(auto req=retrieveToFileRequests.begin(); req!=retrieveToFileRequests.end(); req++) {
queue(*req);
}
}
std::list<RetrieveRequestDump> OStoreDB::getRetrieveRequests(const std::string& vid) const {
throw exception::Exception("Not Implemented");
}
......
......@@ -259,8 +259,6 @@ public:
virtual std::unique_ptr<cta::SchedulerDatabase::ArchiveToFileRequestCreation>
queue(const ArchiveToFileRequest& rqst);
virtual void queue(const ArchiveToDirRequest& rqst);
CTA_GENERATE_EXCEPTION_CLASS(NoSuchArchiveRequest);
CTA_GENERATE_EXCEPTION_CLASS(ArchiveRequestAlreadyDeleted);
virtual void deleteArchiveRequest(const SecurityIdentity& requester, const std::string& archiveFile);
......@@ -291,8 +289,6 @@ public:
CTA_GENERATE_EXCEPTION_CLASS(TapeCopyNumberOutOfRange);
virtual void queue(const RetrieveToFileRequest& rqst_);
virtual void queue(const RetrieveToDirRequest& rqst);
virtual std::list<RetrieveRequestDump> getRetrieveRequests(const std::string& vid) const;
virtual std::map<Tape, std::list<RetrieveRequestDump> > getRetrieveRequests() const;
......
......@@ -195,17 +195,9 @@ public:
return m_OStoreDB.queue(rqst);
}
virtual void queue(const ArchiveToDirRequest& rqst) {
m_OStoreDB.queue(rqst);
}
virtual void queue(const RetrieveToFileRequest& rqst) {
m_OStoreDB.queue(rqst);
}
virtual void queue(const RetrieveToDirRequest& rqst) {
m_OStoreDB.queue(rqst);
}
virtual std::list<cta::DriveState> getDriveStates() const {
return m_OStoreDB.getDriveStates();
......
/*
* 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 "scheduler/RetrieveToDirRequest.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::RetrieveToDirRequest::RetrieveToDirRequest() {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::RetrieveToDirRequest::~RetrieveToDirRequest() throw() {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::RetrieveToDirRequest::RetrieveToDirRequest(
const std::string &remoteDir,
const uint64_t priority,
const CreationLog & creationLog):
UserRetrieveRequest(priority, creationLog),
m_remoteDir(remoteDir) {
}
//------------------------------------------------------------------------------
// getRemoteDir
//------------------------------------------------------------------------------
const std::string &cta::RetrieveToDirRequest::getRemoteDir() const throw() {
return m_remoteDir;
}
//------------------------------------------------------------------------------
// getRetrieveToFileRequests
//------------------------------------------------------------------------------
const std::list<cta::RetrieveToFileRequest> &cta::RetrieveToDirRequest::
getRetrieveToFileRequests() const throw() {
return m_retrieveToFileRequests;
}
//------------------------------------------------------------------------------
// getRetrieveToFileRequests
//------------------------------------------------------------------------------
std::list<cta::RetrieveToFileRequest> &cta::RetrieveToDirRequest::
getRetrieveToFileRequests() throw() {
return m_retrieveToFileRequests;
}
/*
* 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 "scheduler/UserRetrieveRequest.hpp"
#include "scheduler/RetrieveToFileRequest.hpp"
#include <list>
#include <string>
namespace cta {
/**
* Class representing a user request to retrieve one or more archived files to a
* remote directory.
*/
class RetrieveToDirRequest: public UserRetrieveRequest {
public:
/**
* Constructor.
*/
RetrieveToDirRequest();
/**
* Destructor.
*/
~RetrieveToDirRequest() throw();
/**
* Constructor.
*
* @param remoteDir The URL of the destination remote directory.
* @param priority The priority of the request.
* @param user The identity of the user who made the request.
* @param creationTime Optionally the absolute time at which the user request
* was created. If no value is given then the current time is used.
*/
RetrieveToDirRequest(
const std::string &remoteDir,
const uint64_t priority,
const CreationLog & creationLog);
/**
* Returns the URL of the destination remote directory.
*
* @return The URL of the destination remote directory.
*/
const std::string &getRemoteDir() const throw();
/**
* Returns the list of the individual retrieve to file requests that make up
* this retrieve to directory request.
*
* @return the list of the individual retrieve to file requests that make up
* this retrieve to directory request.
*/
const std::list<RetrieveToFileRequest> &getRetrieveToFileRequests() const
throw();
/**