Commit ff752927 authored by Eric Cano's avatar Eric Cano
Browse files

Remove the common TapeJob class as there is little to share between the...

Remove the common TapeJob class as there is little to share between the ArchiveJob and the RetriveJob.
Their similarities are more in concept than implmentation.
Added an ArchiveFileInfo class to hold the location an properties of the archive file we are working on.
Add an ArchiveFileInfo member to the ArchiveJob.
parent 567b5d18
......@@ -9,6 +9,7 @@ set (COMMON_LIB_SRC_FILES
archiveRoutes/ArchiveRouteId.cpp
archiveNS/ArchiveDirEntry.cpp
archiveNS/ArchiveDirIterator.cpp
archiveNS/ArchiveFileInfo.cpp
archiveNS/ArchiveFileStatus.cpp
archiveNS/StorageClass.cpp
archiveNS/Tape.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 "ArchiveFileInfo.hpp"
namespace cta {
ArchiveFileInfo::ArchiveFileInfo(
const std::string& lastKnownPath, uint64_t fileId, uint64_t size,
const Checksum & checksum):
lastKnownPath(lastKnownPath),
fileId(fileId),
size(size),
checksum(checksum) {}
}
\ 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 <string>
#include "common/checksum/Checksum.hpp"
namespace cta {
/**
* A class containing the location and properties of an archive file.
*/
class ArchiveFileInfo {
public:
ArchiveFileInfo(const std::string & lastKnownPath, uint64_t fileId,
uint64_t size, const Checksum & checksum);
const std::string lastKnownPath; /**< The location of the file at NS lookup time */
const uint64_t fileId; /**< The file ID (to be used in the tape copy header, among other */
const uint64_t size; /**< The file's size */
const Checksum checksum;
};
}
\ No newline at end of file
......@@ -28,67 +28,32 @@ cta::ArchiveJob::~ArchiveJob() throw() {
// constructor
//------------------------------------------------------------------------------
cta::ArchiveJob::ArchiveJob(
// NOT YET DECIDED
//ArchiveMount &mount,
const std::string &tapePoolName,
const uint64_t fileSize,
const std::string &id,
const std::string &userRequestId,
const uint32_t copyNb,
const std::string &remoteFile,
const uint64_t castorNsFileId):
TapeJob(id, userRequestId, copyNb, remoteFile, castorNsFileId),
// NOT YET DECIDED
// m_mount(mount),
m_tapePoolName(tapePoolName),
m_fileSize(fileSize) {
}
//------------------------------------------------------------------------------
// getMount
//------------------------------------------------------------------------------
// NOT YET DECIDED
//cta::ArchiveMount &cta::ArchiveJob::getMount() {
// return m_mount;
//}
//------------------------------------------------------------------------------
// getMount
//------------------------------------------------------------------------------
// NOT YET DECIDED
//cta::ArchiveMount &cta::ArchiveJob::getMount() const {
// return m_mount;
//}
//------------------------------------------------------------------------------
// getTapePoolName
//------------------------------------------------------------------------------
const std::string &cta::ArchiveJob::getTapePoolName() const throw() {
return m_tapePoolName;
}
//------------------------------------------------------------------------------
// getFileSize
//------------------------------------------------------------------------------
uint64_t cta::ArchiveJob::getFileSize() const throw() {
return m_fileSize;
}
const ArchiveFileInfo & archiveFile,
const RemotePathAndStatus &remoteFile,
const uint16_t copyNb):
tapePoolName(tapePoolName),
archiveFile(archiveFile),
remoteFile(remoteFile),
copyNumber(copyNb) {}
//------------------------------------------------------------------------------
// complete
//------------------------------------------------------------------------------
void cta::ArchiveJob::complete(const uint32_t checksumOfTransfer,
const uint64_t fileSizeOfTransfer) {
void cta::ArchiveJob::complete() {
throw NotImplemented("");
}
//------------------------------------------------------------------------------
// failed
//------------------------------------------------------------------------------
void cta::ArchiveJob::failed(const std::exception &ex) {
void cta::ArchiveJob::failed() {
throw NotImplemented("");
}
//------------------------------------------------------------------------------
// retry
//------------------------------------------------------------------------------
void cta::ArchiveJob::retry() {
throw NotImplemented("");
}
......@@ -18,7 +18,10 @@
#pragma once
#include "scheduler/TapeJob.hpp"
#include "common/archiveNS/TapeCopyLocationAndStatus.hpp"
#include "common/archiveNS/ArchiveFileInfo.hpp"
#include "common/exception/Exception.hpp"
#include "common/remoteFS/RemotePathAndStatus.hpp"
#include <stdint.h>
#include <string>
......@@ -32,13 +35,14 @@ namespace cta {
/**
* Class representing the transfer of a single copy of a remote file to tape.
*/
class ArchiveJob: public TapeJob {
class ArchiveJob {
/**
* The ArchiveMount class is a friend so that it can call the private
* constructor of ArchiveJob.
*/
friend class ArchiveMount;
CTA_GENERATE_EXCEPTION_CLASS(NotImplemented);
private:
......@@ -46,28 +50,18 @@ private:
* Constructor. It is private as the ArchiveJob is generated by the
* ArchiveMount.
*
// NOT YET DECIDED
* @param archiveMount The mount to which the job belongs.
* @param tapePoolName The name of the destination tape pool.
* @param fileSize The size of the file to be archived in bytes.
* @param id The identifier of the tape job.
* @param userRequestId The identifier of the associated user request.
* @param copyNb The copy number.
* @param remoteFile The URL of the remote source file.
* @param castorNsFileId The CASTOR name server identifier of the file in the
* archive namespace that depending on the direction of the data transfer may
* be either the source or the destination of the tape job.
* @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
*/
ArchiveJob(
// NOT YET DECIDED
// ArchiveMount &archiveMount,
const std::string &tapePoolName,
const uint64_t fileSize,
const std::string &id,
const std::string &userRequestId,
const uint32_t copyNb,
const std::string &remoteFile,
const uint64_t castorNsFileId);
const std::string &tapePoolName,
const ArchiveFileInfo & archiveFile,
const RemotePathAndStatus &remoteFile,
const uint16_t copyNb);
public:
......@@ -76,22 +70,6 @@ public:
*/
~ArchiveJob() throw();
/**
* Returns the mount to which this job belongs.
*
* @return the mount to which this job belongs.
*/
// TO BE DECIDED
//ArchiveMount &getMount() const;
/**
* Returns the mount to which this job belongs.
*
* @return the mount to which this job belongs.
*/
// NO YET DECIDED
//ArchiveMount &getMount();
/**
* Returns the name of the destination tape pool.
*
......@@ -114,46 +92,55 @@ public:
std::string getRemoteFile() const throw();
/**
* Indicates that the job was successful
*
* @param checksumOfTransfer The adler-32 checksum of the file as calculated
* during the execution of the job.
* @param fileSizeOfTransfer The size of the file as calculated during the
* execution of the job.
* Stores the location of the archives tape copy prior to calling complete()
* @param tapeCopyLocation all the information about the tape copy after
* writing
*/
virtual void complete(const uint32_t checksumOfTransfer,
const uint64_t fileSizeOfTransfer);
void setCopyLocationAndStatus (const TapeCopyLocationAndStatus & tapeCopyLocation);
/**
* Indicates that the job failed
* Indicates that the job was successful and updates the backend store
*
* @param ex The reason for the failure.
*/
virtual void failed(const std::exception &ex);
virtual void complete();
/**
* Indicates that the job should be tried again (typically reaching the end
* of the tape).
* Stores the reason for a failure prior to calling failed();
* @param ex the reason for failure in the form of an exception.
*/
virtual void retry();
private:
void setFailureReason (const cta::exception::Exception &ex);
/**
* The mount to which the job belongs.
* Triggers a scheduler update following the failure of the job.
* The reason for the failure should have been set beforehand by calling
* setFailureReason(), but failure to do it is non-fatal (a standard error
* reason will be used)
* This 2 step approach allows the reason to be recorded fast in the
* tape writing thread, and the slow(er) update of the DB to be executed
* in a second thread.
*
*/
// NOT YET DECIDED
//ArchiveMount &m_mount;
virtual void failed();
/**
* The name of the destination tape pool.
* Indicates that the job should be tried again (typically reaching the end
* of the tape).
*/
std::string m_tapePoolName;
virtual void retry();
/**
* The size of the file to be archived in bytes.
*/
uint64_t m_fileSize;
public:
const std::string tapePoolName;
/**< The name of the destination tape pool. */
const ArchiveFileInfo archiveFile;
/**< All information related to the archive file for which we
* are recording this tape copy. */
const RemotePathAndStatus remoteFile;
/**< The size of the file to be archived in bytes. */
const uint16_t copyNumber;
/**< The copy number for this tape copy */
CTA_GENERATE_EXCEPTION_CLASS(LocationNotSet);
const TapeCopyLocationAndStatus & getTapeCopyLocationAndStatus();
/**< Accessor to the tape location status */
}; // class ArchiveJob
......
......@@ -11,7 +11,6 @@ set (CTA_SCHEDULER_SRC_FILES
ArchiveToDirRequest.cpp
ArchiveToFileRequest.cpp
ArchiveToTapeCopyRequest.cpp
TapeJob.cpp
TapeMount.cpp
LogicalLibrary.cpp
mockDB/MockSchedulerDatabase.cpp
......
......@@ -36,9 +36,6 @@ cta::RetrieveJob::RetrieveJob(
const uint32_t copyNb,
const std::string &remoteFile,
const uint64_t castorNsFileId):
TapeJob(id, userRequestId, copyNb, remoteFile, castorNsFileId),
// TO BE DECIDED
//m_mount(mount),
tapeCopyLocation(tapeCopyLocation) {
}
......
......@@ -18,7 +18,6 @@
#pragma once
#include "scheduler/TapeJob.hpp"
#include "common/archiveNS/TapeCopyInfo.hpp"
#include "common/remoteFS/RemotePath.hpp"
......@@ -31,7 +30,7 @@ class RetrieveMount;
/**
* The transfer of a single copy of a tape file to a remote file.
*/
class RetrieveJob: public TapeJob {
class RetrieveJob {
/**
* The RetrieveMount class is a friend so that it can call the private
* constructor of RetrieveJob.
......@@ -72,23 +71,6 @@ public:
*/
~RetrieveJob() throw();
/**
* Returns the mount to which this job belongs.
*
* @return the mount to which this job belongs.
*/
// TO BE DECIDED
//RetrieveMount &getMount() const;
/**
* Returns the mount to which this job belongs.
*
* @return the mount to which this job belongs.
*/
// TO BE DECIDED
//RetrieveMount &getMount();
/**
* Indicates that the job was successful
*
......
/*
* 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/TapeJob.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::TapeJob::TapeJob():
m_copyNb(0) {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
cta::TapeJob::~TapeJob() throw() {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::TapeJob::TapeJob(
const std::string &id,
const std::string &userRequestId,
const uint32_t copyNb,
const std::string &remoteFile,
const uint64_t castorNsFileId):
m_id(id),
m_userRequestId(userRequestId),
m_copyNb(copyNb),
m_remoteFile(remoteFile),
m_castorNsFileId(castorNsFileId) {
}
//------------------------------------------------------------------------------
// getId
//------------------------------------------------------------------------------
const std::string &cta::TapeJob::getId() const throw() {
return m_id;
}
//------------------------------------------------------------------------------
// getUserRequestId
//------------------------------------------------------------------------------
const std::string &cta::TapeJob::getUserRequestId() const throw() {
return m_userRequestId;
}
//------------------------------------------------------------------------------
// getCopyNb
//------------------------------------------------------------------------------
uint32_t cta::TapeJob::getCopyNb() const throw() {
return m_copyNb;
}
//------------------------------------------------------------------------------
// getRemoteFile
//------------------------------------------------------------------------------
const std::string &cta::TapeJob::getRemoteFile() const throw() {
return m_remoteFile;
}
//------------------------------------------------------------------------------
// getCastorNsFileId
//------------------------------------------------------------------------------
uint64_t cta::TapeJob::getCastorNsFileId() const throw() {
return m_castorNsFileId;
}
/*
* 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 <stdint.h>
#include <string>
namespace cta {
/**
* Abstract class representing the transfer of a single copy of file.
*/
class TapeJob {
public:
/**
* Constructor.
*/
TapeJob();
/**
* Destructor.
*/
virtual ~TapeJob() throw() = 0;
/**
* Constructor.
*
* @param id The identifier of the tape job.
* @param userRequestId The identifier of the associated user request.
* @param copyNb The copy number.
* @param remoteFile The URL of the remote file that depending on the
* direction of the data transfer may be either the source or the
* destination of the tape job.
* @param castorNsFileId The CASTOR name server identifier of the file in the
* archive namespace that depending on the direction of the data transfer may
* be either the source or the destination of the tape job.
*/
TapeJob(
const std::string &id,
const std::string &userRequestId,
const uint32_t copyNb,
const std::string &remoteFile,
const uint64_t castorNsFileId);
/**
* Returns the identifier of the tape job.
*
* @return The identifier of the tape job.
*/
const std::string &getId() const throw();
/**
* Returns the identifier of the associated user request.
*
* @return The identifier of the associated user request.
*/
const std::string &getUserRequestId() const throw();
/**
* Returns the copy number.
*
* @return The copy number.
*/
uint32_t getCopyNb() const throw();
/**
* Returns the URL of the remote file that depending on the direction of the
* data transfer may be either the source or the destination of the file
* transfer.
*
* @return The URL of the remote file that depending on the direction of the
* data transfer may be either the source or the destination of the file
* transfer.
*/
const std::string &getRemoteFile() const throw();
/**
* Returns The CASTOR name server identifier of the file in the archive
* namespace that depending on the direction of the data transfer may be
* either the source or the destination of the tape job.
*
* @return The CASTOR name server identifier of the file in the archive
* namespace that depending on the direction of the data transfer may be
* either the source or the destination of the tape job.
*/
uint64_t getCastorNsFileId() const throw();
/**
* Indicates that the job was successful
*
* @param checksumOfTransfer The adler-32 checksum of the file as calculated
* during the execution of the job.
* @param fileSizeOfTransfer The size of the file as calculated during the
* execution of the job.
*/
virtual void complete(const uint32_t checksumOfTransfer,
const uint64_t fileSizeOfTransfer) = 0;
/**
* Indicates that the job failed
*
* @param ex The reason for the failure.
*/
virtual void failed(const std::exception &ex) = 0;
/**
* Indicates that the job should be tried again (typically reaching the end
* of the tape).
*/
virtual void retry() = 0;
private:
/**
* The identifier of the tape job.
*/
std::string m_id;
/**
* The identifier of the associated user request.
*/
std::string m_userRequestId;
/**
* The copy number.
*/
uint32_t m_copyNb;
/**
* The URL of the remote file that depending on the direction of the data
* transfer may be either the source or the destination of the tape job.
*/
std::string m_remoteFile;
/**
* The CASTOR name server identifier of the file in the archive
* namespace that depending on the direction of the data transfer may be
* either the source or the destination of the tape job.
*/
uint64_t m_castorNsFileId;
}; // class TapeJob
} // namespace cta