Commit a857fdba authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Started restructuring the Archive/Retrieve Job

parent 6a46cb58
......@@ -9,12 +9,11 @@ set (COMMON_LIB_SRC_FILES
archiveRoutes/ArchiveRouteId.cpp
archiveNS/ArchiveDirEntry.cpp
archiveNS/ArchiveDirIterator.cpp
archiveNS/ArchiveFileInfo.cpp
archiveNS/ArchiveFile.cpp
archiveNS/ArchiveFileStatus.cpp
archiveNS/StorageClass.cpp
archiveNS/Tape.cpp
archiveNS/TapeCopyInfo.cpp
archiveNS/TapeCopyLocationAndStatus.cpp
archiveNS/TapeFileLocation.cpp
CreationLog.cpp
checksum/ByteArray.cpp
checksum/Checksum.cpp
......
......@@ -16,27 +16,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/archiveNS/TapeCopyLocationAndStatus.hpp"
#include "ArchiveFile.hpp"
namespace cta {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::TapeCopyLocationAndStatus::TapeCopyLocationAndStatus() {
ArchiveFile::ArchiveFile():
fileId(0),
size(0),
lastModificationTime(0) {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::TapeCopyLocationAndStatus::TapeCopyLocationAndStatus(
const std::string &vid,
const uint64_t fSeq,
const uint64_t blockId,
const uint64_t size,
const uint64_t fileId,
const Checksum &checksum):
vid(vid),
fSeq(fSeq),
blockId(blockId),
size(size),
fileId(fileId),
checksum(checksum) {}
ArchiveFile::ArchiveFile(const std::string & path, const std::string & nsHostName, uint64_t fileId,
uint64_t size, const Checksum & checksum, const time_t lastModificationTime):
path(path),
nsHostName(nsHostName),
fileId(fileId),
size(size),
checksum(checksum),
lastModificationTime(lastModificationTime) {}
}
......@@ -25,22 +25,55 @@ namespace cta {
/**
* A class containing the location and properties of an archive file.
*/
class ArchiveFileInfo {
class ArchiveFile {
public:
/**
* Constructor.
*/
ArchiveFileInfo();
ArchiveFile();
/**
* Constructor.
*
* @param path The location of the file at NS lookup time
* @param nsHostName The NS host name
* @param fileId The file ID (to be used in the tape copy header)
* @param size The file size
* @param checksum The file checksum
* @param lastModificationTime The last modification time of the file
*/
ArchiveFileInfo(const std::string & lastKnownPath, uint64_t fileId,
ArchiveFile(const std::string & path, const std::string & nsHostName, uint64_t fileId,
uint64_t size, const Checksum & checksum, const time_t lastModificationTime);
std::string lastKnownPath; /**< The location of the file at NS lookup time */
uint64_t fileId; /**< The file ID (to be used in the tape copy header, among other */
uint64_t size; /**< The file's size */
/**
* The location of the file at NS lookup time
*/
std::string path;
/**
* The NS host name
*/
std::string nsHostName;
/**
* The file ID (to be used in the tape copy header)
*/
uint64_t fileId;
/**
* The file size
*/
uint64_t size;
/**
* The file checksum
*/
Checksum checksum;
/**
* The last modification time of the file
*/
time_t lastModificationTime;
};
}
/*
* 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 "ArchiveFileInfo.hpp"
namespace cta {
ArchiveFileInfo::ArchiveFileInfo():
fileId(0),
size(0),
lastModificationTime(0) {
}
ArchiveFileInfo::ArchiveFileInfo(
const std::string& lastKnownPath, uint64_t fileId, uint64_t size,
const Checksum & checksum, const time_t lastModificationTime):
lastKnownPath(lastKnownPath),
fileId(fileId),
size(size),
checksum(checksum),
lastModificationTime(lastModificationTime) {}
}
/*
* 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 <string>
#include "common/archiveNS/ArchiveFileStatus.hpp"
namespace cta {
/**
* The path and status of an archive file.
*/
struct TapeCopyLocationAndStatus {
/** Constructor. */
TapeCopyLocationAndStatus();
/**
* Constructor.
*
* @param path The path of the file in the archive.
* @param status The status of the file in the archive.
*/
TapeCopyLocationAndStatus(
const std::string &vid,
const uint64_t fSeq,
const uint64_t blockId,
const uint64_t size,
const uint64_t fileId,
const Checksum &checksum);
std::string vid; /**< The tape on which the copy is located */
uint64_t fSeq; /**< The file sequence number (fSeq) for the copy on tape */
uint64_t blockId; /**< The tape block holding the first header block for the file */
uint64_t size; /**< The tape copy's size */
uint64_t fileId; /**< The file ID as recorded in the tape copy's header */
Checksum checksum;/**< The tape copy's checksum */
/**
* The hostname of the nameserver holding the file
*/
std::string nsHostName;
}; // class TapeCopyLocationAndStatus
} // namespace cta
......@@ -16,23 +16,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/archiveNS/TapeCopyInfo.hpp"
#include "common/archiveNS/TapeFileLocation.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::TapeCopyInfo::TapeCopyInfo():
cta::TapeFileLocation::TapeFileLocation():
fSeq(0),
blockId(0) {
blockId(0),
vid(""),
copyNumber(0) {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::TapeCopyInfo::TapeCopyInfo(const std::string &vid,
const uint64_t fSeq, const uint64_t blockId, uint16_t copyNumber):
vid(vid),
cta::TapeFileLocation::TapeFileLocation(const uint64_t fSeq, const uint64_t blockId, const std::string &vid, const uint8_t copyNumber):
fSeq(fSeq),
blockId(blockId),
vid(vid),
copyNumber(copyNumber) {
}
......@@ -26,38 +26,22 @@ namespace cta {
/**
* The location of a tape copy.
*/
struct TapeCopyInfo {
struct TapeFileLocation {
/**
* Constructor.
*/
TapeCopyInfo();
TapeFileLocation();
/**
* Constructor.
*
* @param vid The volume identifier of the tape.
* @param fSeq The sequence number of the file.
* @param blockId The block identifier of the file.
* @param copyNumber The copy number for this tape copy.
* @param vid The vid of the tape containing the file. TODO: to be put in the mount object in the future
* @param copyNumber The copy number of the tape file. TODO: to be put in the mount object in the future
*/
TapeCopyInfo(const std::string &vid, const uint64_t fSeq,
const uint64_t blockId, uint16_t copyNumber);
/**
* The path of the archive file.
*/
//std::string archiveFilePath;
/**
* The ID of the file
*/
//uint64_t fileId;
/**
* The volume identifier of the tape.
*/
std::string vid;
TapeFileLocation(const uint64_t fSeq, const uint64_t blockId, const std::string &vid, const uint8_t copyNumber);
/**
* The sequence number of the file.
......@@ -70,15 +54,15 @@ struct TapeCopyInfo {
uint64_t blockId;
/**
* The hostname of the nameserver holding the file
* The vid of the tape containing the file. TODO: to be put in the mount object in the future
*/
std::string nsHostName;
std::string vid;
/**
* The copy number for this tape copy
* The copy number of the tape file. TODO: to be put in the mount object in the future
*/
uint16_t copyNumber;
uint8_t copyNumber;
}; // struct TapeCopyLocation
}; // struct TapeFileLocation
} // namepsace cta
......@@ -59,9 +59,7 @@ struct RemoteFileStatus {
mode_t mode;
/**
* Returns the size of the file in bytes.
*
* @return The size of the file in bytes.
* The size of the file in bytes.
*/
uint64_t size;
......
......@@ -27,23 +27,14 @@ cta::ArchiveJob::~ArchiveJob() throw() {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::ArchiveJob::ArchiveJob() {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::ArchiveJob::ArchiveJob(
const std::string &tapePoolName,
const ArchiveFileInfo & archiveFile,
const RemotePathAndStatus &remoteFile,
const TapeCopyLocationAndStatus &tapeCopy,
const uint16_t copyNb):
tapePoolName(tapePoolName),
cta::ArchiveJob::ArchiveJob(/*ArchiveMount &mount,*/
const ArchiveFile &archiveFile,
const RemotePathAndStatus &remotePathAndStatus,
const TapeFileLocation &tapeFileLocation):
/*mount(mount),*/
archiveFile(archiveFile),
remoteFile(remoteFile),
tapeCopy(tapeCopy),
copyNumber(copyNb) {}
remotePathAndStatus(remotePathAndStatus),
tapeFileLocation(tapeFileLocation) {}
//------------------------------------------------------------------------------
// complete
......@@ -55,7 +46,7 @@ void cta::ArchiveJob::complete() {
//------------------------------------------------------------------------------
// failed
//------------------------------------------------------------------------------
void cta::ArchiveJob::failed() {
void cta::ArchiveJob::failed(const cta::exception::Exception &ex) {
throw NotImplemented("");
}
......
......@@ -18,8 +18,8 @@
#pragma once
#include "common/archiveNS/TapeCopyLocationAndStatus.hpp"
#include "common/archiveNS/ArchiveFileInfo.hpp"
#include "common/archiveNS/TapeFileLocation.hpp"
#include "common/archiveNS/ArchiveFile.hpp"
#include "common/exception/Exception.hpp"
#include "common/remoteFS/RemotePathAndStatus.hpp"
......@@ -27,10 +27,9 @@
#include <string>
namespace cta {
// Forward declaration
// class ArchivePath;
class ArchiveMount;
class RemotePathAndStatus;
// Forward declaration
class ArchiveMount;
/**
* Class representing the transfer of a single copy of a remote file to tape.
......@@ -42,33 +41,26 @@ class ArchiveJob {
* constructor of ArchiveJob.
*/
friend class ArchiveMount;
CTA_GENERATE_EXCEPTION_CLASS(NotImplemented);
protected:
/**
* Constructor. It is not protected as the ArchiveJob is generated by the
* ArchiveMount.
* Empty constructor. TODO: to be removed in the future when we put in the reference to the owning mount;
*/
ArchiveJob();
ArchiveJob() {}
/**
* Constructor. It is not protected as the ArchiveJob is generated by the
* ArchiveMount.
*
* @param tapePoolName the name of the tape pool the tape copy should be
* stored in.
* @param archiveFile informations about the file for which we are storing
* this tape copy.
* @param remoteFile location and properties of the remote file
* @param copyNb the copy number
* Constructor.
*
* @param mount the mount that generated this job
* @param archiveFile informations about the file that we are storing
* @param remotePathAndStatus location and properties of the remote file
* @param tapeFileLocation the location within the tape
*/
ArchiveJob(
const std::string &tapePoolName,
const ArchiveFileInfo & archiveFile,
const RemotePathAndStatus &remoteFile,
const TapeCopyLocationAndStatus &tapeCopy,
const uint16_t copyNb);
ArchiveJob(/*ArchiveMount &mount,*/
const ArchiveFile &archiveFile,
const RemotePathAndStatus &remotePathAndStatus,
const TapeFileLocation &tapeFileLocation);
public:
......@@ -77,31 +69,11 @@ public:
*/
virtual ~ArchiveJob() throw() = 0;
/**
* Returns the name of the destination tape pool.
*
* @return the name of the destination tape pool.
*/
const std::string &getTapePoolName() const throw();
/**
* Returns the The URL of the remote source file.
*
* @return The The URL of the remote source file.
*/
std::string getRemoteFile() const throw();
/**
* Indicates that the job was successful and updates the backend store
*
*/
virtual void complete();
/**
* Stores the reason for a failure prior to calling failed();
* @param ex the reason for failure in the form of an exception.
*/
void setFailureReason (const cta::exception::Exception &ex);
/**
* Triggers a scheduler update following the failure of the job.
......@@ -113,7 +85,7 @@ public:
* in a second thread.
*
*/
virtual void failed();
virtual void failed(const cta::exception::Exception &ex);
/**
* Indicates that the job should be tried again (typically reaching the end
......@@ -122,19 +94,28 @@ public:
virtual void retry();
public:
std::string tapePoolName;
/**< The name of the destination tape pool. */
ArchiveFileInfo archiveFile;
/**< All information related to the archive file for which we
* are recording this tape copy. */
RemotePathAndStatus remoteFile;
/**< The size of the file to be archived in bytes. */
TapeCopyLocationAndStatus tapeCopy;
uint16_t copyNumber;
/**< The copy number for this tape copy */
CTA_GENERATE_EXCEPTION_CLASS(LocationNotSet);
/**< Accessor to the tape location status */
CTA_GENERATE_EXCEPTION_CLASS(NotImplemented);
/**
* The mount that generated this job
*/
//ArchiveMount &mount;
/**
* The NS archive file information
*/
ArchiveFile archiveFile;
/**
* The remote file information
*/
RemotePathAndStatus remotePathAndStatus;
/**
* The location of the tape file
*/
TapeFileLocation tapeFileLocation;
}; // class ArchiveJob
......
......@@ -52,6 +52,20 @@ std::string cta::ArchiveMount::getDensity() const throw() {
return "UNKNOWN_DENSITY_FOR_ARCHIVE_MOUNT";
}
//------------------------------------------------------------------------------
// getPoolName
//------------------------------------------------------------------------------
std::string cta::ArchiveMount::getPoolName() const throw() {
return "UNKNOWN_POOL_FOR_ARCHIVE_MOUNT";
}
//------------------------------------------------------------------------------
// getCopyNumber
//------------------------------------------------------------------------------
int cta::ArchiveMount::getCopyNumber() const throw() {
return 1;
}
//------------------------------------------------------------------------------
// getMountTransactionId
//------------------------------------------------------------------------------
......
......@@ -102,6 +102,20 @@ namespace cta {
*/
std::unique_ptr<ArchiveJob> getNextJob();
/**
* Returns the tape pool of the tape to be mounted.
*
* @return The tape pool of the tape to be mounted.
*/
virtual std::string getPoolName() const throw();
/**
* Returns the copy number of the tape to be mounted.
*
* @return The copy number of the tape to be mounted.
*/
virtual int getCopyNumber() const throw();
/**
* Destructor.
*/
......
......@@ -37,7 +37,7 @@
#include "common/archiveNS/Tape.hpp"
#include "ArchiveToDirRequest.hpp"
#include "RetrieveToFileRequest.hpp"
#include "common/archiveNS/TapeCopyInfo.hpp"
#include "common/archiveNS/TapeFileLocation.hpp"
#include "RetrieveToDirRequest.hpp"
#include "ArchiveToTapeCopyRequest.hpp"
#include <algorithm>
......
......@@ -17,7 +17,7 @@
*/
#include "scheduler/RetrieveFromTapeCopyRequest.hpp"
#include "common/archiveNS/TapeCopyInfo.hpp"
#include "common/archiveNS/TapeFileLocation.hpp"
//------------------------------------------------------------------------------
// constructor
......@@ -37,7 +37,7 @@ cta::RetrieveFromTapeCopyRequest::~RetrieveFromTapeCopyRequest() throw() {
cta::RetrieveFromTapeCopyRequest::RetrieveFromTapeCopyRequest(
const std::string &archiveFile,
const uint64_t copyNb,
const TapeCopyInfo &tapeCopy,
const TapeFileLocation &tapeCopy,
const std::string &remoteFile,
const uint64_t priority,
const CreationLog & creationLog):
......
......@@ -19,7 +19,7 @@
#pragma once
#include "scheduler/RetrieveRequest.hpp"
#include "common/archiveNS/TapeCopyInfo.hpp"
#include "common/archiveNS/TapeFileLocation.hpp"
#include <list>
#include <string>
......@@ -57,7 +57,7 @@ struct RetrieveFromTapeCopyRequest: public RetrieveRequest {
RetrieveFromTapeCopyRequest(
const std::string &archiveFile,
const uint64_t copyNb,
const TapeCopyInfo &tapeCopy,
const TapeFileLocation &tapeCopy,
const std::string &remoteFile,
const uint64_t priority,
const CreationLog &creationLog);
......@@ -75,7 +75,7 @@ struct RetrieveFromTapeCopyRequest: public RetrieveRequest {
/**
* The location of the copy on tape.
*/
TapeCopyInfo tapeCopy;
TapeFileLocation tapeCopy;
/**
* The URL of the destination remote file.
......
......@@ -27,23 +27,16 @@ cta::RetrieveJob::~RetrieveJob() throw() {
//------------------------------------------------------------------------------
// constructor