Skip to content
Snippets Groups Projects
Commit 08614062 authored by Steven Murray's avatar Steven Murray
Browse files

WIP

parent fb127ebe
Branches
Tags
No related merge requests found
......@@ -17,6 +17,7 @@
*/
#include "scheduler/RetrieveToFileRequest.hpp"
#include "scheduler/TapeFileLocation.hpp"
//------------------------------------------------------------------------------
// constructor
......@@ -35,12 +36,14 @@ cta::RetrieveToFileRequest::~RetrieveToFileRequest() throw() {
//------------------------------------------------------------------------------
cta::RetrieveToFileRequest::RetrieveToFileRequest(
const std::string &archiveFile,
const std::list<cta::TapeFileLocation> &tapeCopies,
const std::string &remoteFile,
const uint64_t priority,
const SecurityIdentity &user,
const time_t creationTime):
RetrievalRequest(priority, user, creationTime),
m_archiveFile(archiveFile),
m_tapeCopies(tapeCopies),
m_remoteFile(remoteFile) {
}
......@@ -51,6 +54,14 @@ const std::string &cta::RetrieveToFileRequest::getArchiveFile() const throw() {
return m_archiveFile;
}
//------------------------------------------------------------------------------
// getTapeCopies
//------------------------------------------------------------------------------
const std::list<cta::TapeFileLocation> &cta::RetrieveToFileRequest::
getTapeCopies() const throw() {
return m_tapeCopies;
}
//------------------------------------------------------------------------------
// getRemoteFile
//------------------------------------------------------------------------------
......
......@@ -20,10 +20,14 @@
#include "scheduler/RetrievalRequest.hpp"
#include <list>
#include <string>
namespace cta {
// Forward declarations
class TapeFileLocation;
/**
* Class representing a user request to retrieve a single archived file to a
* single remote file.
......@@ -45,6 +49,7 @@ public:
* Constructor.
*
* @param archiveFile The full path of the source archive file.
* @param tapeCopies The physical location(s) of the archive file on tape.
* @param remoteFile The URL of the destination remote file.
* @param priority The priority of the request.
* @param user The identity of the user who made the request.
......@@ -53,6 +58,7 @@ public:
*/
RetrieveToFileRequest(
const std::string &archiveFile,
const std::list<TapeFileLocation> &tapeCopies,
const std::string &remoteFile,
const uint64_t priority,
const SecurityIdentity &user,
......@@ -65,6 +71,13 @@ public:
*/
const std::string &getArchiveFile() const throw();
/**
* Returns the physical location(s) of the archive file on tape.
*
* @return The physical location(s) of the archive file on tape.
*/
const std::list<TapeFileLocation> &getTapeCopies() const throw();
/**
* Returns the URL of the destination remote file.
*
......@@ -79,6 +92,11 @@ private:
*/
std::string m_archiveFile;
/**
* The physical location(s) of the archive file on tape.
*/
std::list<TapeFileLocation> m_tapeCopies;
/**
* The URL of the destination remote file.
*/
......
......@@ -449,7 +449,7 @@ void cta::Scheduler::queueArchiveToDirRequest(
/*
for(int i = 1; i <= storageClass.getNbCopies(); i++) {
cta::ArchivalRoute route = m_db.getArchivalRouteOfStorageClass(storageClassName, i);
for(auto itor = srcUrls.begin(); itor != srcUrls.end(); itor++) {
for(auto itor = remoteFiles.cbegin(); itor != remoteFiles.cend(); itor++) {
const std::string &srcFileName = *itor;
std::string dstPathname;
if(dstDir.at(dstDir.length()-1) == '/') {
......@@ -462,16 +462,16 @@ void cta::Scheduler::queueArchiveToDirRequest(
}
}
const std::list<std::string> dstFileNames = Utils::getEnclosedNames(srcUrls);
const std::list<std::string> archiveFiles = Utils::getEnclosedNames(remoteFiles);
for(auto itor = dstFileNames.begin(); itor != dstFileNames.end(); itor++) {
const std::string &dstFileName = *itor;
for(auto itor = archiveFiles.cbegin(); itor != archiveFiles.cend(); itor++) {
const std::string &archiveFile = *itor;
std::string dstPathname;
if(dstDir.at(dstDir.length()-1) == '/') {
dstPathname = dstDir+dstFileName;
dstPathname = dstDir+archiveFile;
}
else {
dstPathname = dstDir+"/"+dstFileName;
dstPathname = dstDir+"/"+archiveFile;
}
m_ns.createFile(requester, dstPathname, 0666);
}
......@@ -504,15 +504,8 @@ void cta::Scheduler::queueArchiveToFileRequest(
enclosingPath);
const StorageClass storageClass = m_db.getStorageClass(storageClassName);
assertStorageClassHasAtLeastOneCopy(storageClass);
const std::list<ArchivalRoute> routes =
m_db.getArchivalRoutes(storageClassName);
std::map<uint16_t, std::string> copyNbToPoolMap;
for(auto itor = routes.begin(); itor != routes.end(); itor++) {
const ArchivalRoute &route = *itor;
copyNbToPoolMap[route.getCopyNb()] = route.getTapePoolName();
}
const auto routes = m_db.getArchivalRoutes(storageClassName);
const auto copyNbToPoolMap = createCopyNbToPoolMap(routes);
const uint64_t priority = 0;
m_db.queue(ArchiveToFileRequest(
......@@ -524,3 +517,25 @@ void cta::Scheduler::queueArchiveToFileRequest(
m_ns.createFile(requester, archiveFile, 0666);
}
//------------------------------------------------------------------------------
// createCopyNbToPoolMap
//------------------------------------------------------------------------------
std::map<uint16_t, std::string> cta::Scheduler::createCopyNbToPoolMap(
const std::list<ArchivalRoute> &routes) const {
std::map<uint16_t, std::string> copyNbToPoolMap;
for(auto itor = routes.begin(); itor != routes.end(); itor++) {
const ArchivalRoute &route = *itor;
copyNbToPoolMap[route.getCopyNb()] = route.getTapePoolName();
}
return copyNbToPoolMap;
}
//------------------------------------------------------------------------------
// queueRetrieveRequest
//------------------------------------------------------------------------------
void cta::Scheduler::queueRetrieveRequest(
const SecurityIdentity &requester,
const std::list<std::string> &archiveFiles,
const std::string &remoteFileOrDir) {
}
......@@ -499,6 +499,25 @@ public:
const std::list<std::string> &remoteFiles,
const std::string &archiveFileOrDir);
/**
* Queues the specified request to retrieve one or more archived files.
*
* If there is more than one archived file then the destination must be a
* directory.
*
* If there is only one archived file then the destination can be either a
* file or a directory.
*
* @param requester The identity of the user requesting the retrieval.
* @param archiveFiles The full path of each source file in the archive
* namespace.
* @param remoteFileOrDir The URL of the destination remote file or directory.
*/
void queueRetrieveRequest(
const SecurityIdentity &requester,
const std::list<std::string> &archiveFiles,
const std::string &remoteFileOrDir);
private:
/**
......@@ -555,6 +574,17 @@ private:
const std::string &remoteFile,
const std::string &archiveFile);
/**
* Returns the map from tape copy number to tape pool name for the specified
* set of archival routes.
*
* @param routes The archive routes.
* @return The map from tape copy number to tape pool name for the specified
* set of archival routes.
*/
std::map<uint16_t, std::string> createCopyNbToPoolMap(
const std::list<ArchivalRoute> &routes) const;
}; // class Scheduler
} // namespace cta
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment