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

Fleshed out the Job classes.

The bottom line is the Mount and Job classes shall be passed around the
tapeserverd daemon for two purposes, to carry all the information about
the file copy to be transfered and to provide the notification interface
to the scheduler on which the tapeserverd daemon needs to call methods
to indicate the ends of transfers and mounts.
parent 489bf005
No related branches found
No related tags found
No related merge requests found
......@@ -18,12 +18,6 @@
#include "scheduler/ArchiveJob.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::ArchiveJob::ArchiveJob() {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
......@@ -34,13 +28,35 @@ 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):
TapeJob(id, userRequestId, copyNb, remoteFile),
m_tapePoolName(tapePoolName) {
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
//------------------------------------------------------------------------------
cta::ArchiveMount &cta::ArchiveJob::getMount() const {
return m_mount;
}
//------------------------------------------------------------------------------
......@@ -50,16 +66,24 @@ const std::string &cta::ArchiveJob::getTapePoolName() const throw() {
return m_tapePoolName;
}
//------------------------------------------------------------------------------
// getFileSize
//------------------------------------------------------------------------------
uint64_t cta::ArchiveJob::getFileSize() const throw() {
return m_fileSize;
}
//------------------------------------------------------------------------------
// complete
//------------------------------------------------------------------------------
void cta::ArchiveJob::complete() {
void cta::ArchiveJob::complete(const uint32_t checksumOfTransfer,
const uint64_t fileSizeOfTransfer) {
}
//------------------------------------------------------------------------------
// failed
//------------------------------------------------------------------------------
void cta::ArchiveJob::failed() {
void cta::ArchiveJob::failed(const std::exception &ex) {
}
//------------------------------------------------------------------------------
......
......@@ -26,41 +26,71 @@
namespace cta {
// Forward declaration
// class ArchivePath;
class ArchiveMount;
class RemotePathAndStatus;
/**
* Class representing the transfer of a single copy of a remote file to tape.
*/
class ArchiveJob: public TapeJob {
friend class ArchiveMount;
private:
/**
* Constructor. It is private as the ArchiveJob is generated by the
* ArchiveMount.
*/
ArchiveJob();
public:
/**
* Destructor.
* The ArchiveMount class is a friend so that it can call the private
* constructor of ArchiveJob.
*/
~ArchiveJob() throw();
friend class ArchiveMount;
private:
/**
* Constructor.
* 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.
*/
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 std::string &remoteFile,
const uint64_t castorNsFileId);
public:
/**
* Destructor.
*/
~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.
......@@ -68,30 +98,63 @@ public:
* @return the name of the destination tape pool.
*/
const std::string &getTapePoolName() const throw();
/**
* Returns the size of the file to be archived in bytes.
*
* @return The size of the file to be archived in bytes.
*/
uint64_t getFileSize() 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
*
* @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.
*/
void complete();
virtual void complete(const uint32_t checksumOfTransfer,
const uint64_t fileSizeOfTransfer);
/**
* Indicates that the job failed
*
* @param ex The reason for the failure.
*/
void failed();
virtual void failed(const std::exception &ex);
/**
* Indicates that the job should be tried again (typically reaching the end
* of the tape).
*/
void retry();
virtual void retry();
private:
/**
* The mount to which the job belongs.
*/
// NOT YET DECIDED
//ArchiveMount &m_mount;
/**
* The name of the destination tape pool.
*/
std::string m_tapePoolName;
/**
* The size of the file to be archived in bytes.
*/
uint64_t m_fileSize;
}; // class ArchiveJob
} // namespace cta
......@@ -38,6 +38,13 @@ cta::MountType::Enum cta::ArchiveMount::getMountType() const throw() {
return MountType::ARCHIVE;
}
//------------------------------------------------------------------------------
// getVid
//------------------------------------------------------------------------------
std::string cta::ArchiveMount::getVid() const throw() {
return "UNKNOWN_VID_FOR_ARCHIVE_MOUNT";
}
//------------------------------------------------------------------------------
// finish
//------------------------------------------------------------------------------
......
......@@ -28,7 +28,6 @@
namespace cta {
class ArchiveMount;
/**
* The class driving a retrieve mount.
* The class only has private constructors as it is instanciated by
......@@ -55,7 +54,14 @@ namespace cta {
*
* @return The type of this tape mount.
*/
MountType::Enum getMountType() const throw();
virtual MountType::Enum getMountType() const throw();
/**
* Returns the volume identifier of the tape to be mounted.
*
* @return The volume identifier of the tape to be mounted.
*/
virtual std::string getVid() const throw();
/**
* Notifies the scheduler that the session is finished
......
......@@ -18,12 +18,6 @@
#include "scheduler/RetrieveJob.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::RetrieveJob::RetrieveJob() {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
......@@ -34,25 +28,30 @@ cta::RetrieveJob::~RetrieveJob() throw() {
// constructor
//------------------------------------------------------------------------------
cta::RetrieveJob::RetrieveJob(
// TO BE DECIDED
//RetrieveMount &mount,
const TapeCopyLocation &tapeFile,
const std::string &id,
const std::string &userRequestId,
const uint32_t copyNb,
const std::string &remoteFile):
TapeJob(id, userRequestId, copyNb, remoteFile),
const std::string &remoteFile,
const uint64_t castorNsFileId):
TapeJob(id, userRequestId, copyNb, remoteFile, castorNsFileId),
m_mount(mount),
tapeFile(tapeFile) {
}
//------------------------------------------------------------------------------
// complete
//------------------------------------------------------------------------------
void cta::RetrieveJob::complete() {
void cta::RetrieveJob::complete(const uint32_t checksumOfTransfer,
const uint64_t fileSizeOfTransfer) {
}
//------------------------------------------------------------------------------
// failed
//------------------------------------------------------------------------------
void cta::RetrieveJob::failed() {
void cta::RetrieveJob::failed(const std::exception &ex) {
}
//------------------------------------------------------------------------------
......
/*
* The CERN Tape Archive (CTA) project
* The CERN Tape Retrieve (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
......@@ -25,47 +25,86 @@
namespace cta {
class RetrieveMount;
/**
* The transfer of a single copy of a tape file to a remote file.
*/
struct RetrieveJob: public TapeJob {
public:
class RetrieveJob: public TapeJob {
/**
* Constructor.
* The RetrieveMount class is a friend so that it can call the private
* constructor of RetrieveJob.
*/
RetrieveJob();
friend class RetrieveMount;
/**
* Destructor.
*/
~RetrieveJob() throw();
private:
/**
* Constructor.
* Constructor. It is private as the ArchiveJob is generated by the
* RetrieveMount.
*
// TO BE DECIDED
* @param mount The mount to which the job belongs.
* @param tapeFile The location of the source tape file.
* @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 destination 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.
*/
RetrieveJob(
// TO BE DECIDED
// RetrieveMount &mount,
const TapeCopyLocation &tapeFile,
const std::string &id,
const std::string &userRequestId,
const uint32_t copyNb,
const std::string &remoteFile);
const std::string &remoteFile,
const uint64_t castorNsFileId);
public:
/**
* Destructor.
*/
~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
*
* @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.
*/
void complete();
virtual void complete(const uint32_t checksumOfTransfer,
const uint64_t fileSizeOfTransfer);
/**
* Indicates that the job failed
*
* @param ex The reason for the failure.
*/
void failed();
virtual void failed(const std::exception &ex);
/**
* Indicates that the job should be tried again (typically reaching the end
......@@ -73,6 +112,16 @@ public:
*/
void retry();
private:
/**
* The mount to which the job belongs.
*/
// TO BE DECIDED
//RetrieveMount &m_mount;
public:
/**
* The location of the source tape file.
*/
......
......@@ -38,6 +38,13 @@ cta::MountType::Enum cta::RetrieveMount::getMountType() const throw() {
return MountType::ARCHIVE;
}
//------------------------------------------------------------------------------
// getVid
//------------------------------------------------------------------------------
std::string cta::RetrieveMount::getVid() const throw() {
return "UNKNOWN_VID_FOR_RETRIEVE_MOUNT";
}
//------------------------------------------------------------------------------
// finish
//------------------------------------------------------------------------------
......
......@@ -28,7 +28,6 @@
namespace cta {
class RetrieveMount;
/**
* The class driving a retrieve mount.
* The class only has private constructors as it is instanciated by
......@@ -55,7 +54,14 @@ namespace cta {
*
* @return The type of this tape mount.
*/
MountType::Enum getMountType() const throw();
virtual MountType::Enum getMountType() const throw();
/**
* Returns the volume identifier of the tape to be mounted.
*
* @return The volume identifier of the tape to be mounted.
*/
virtual std::string getVid() const throw();
/**
* Notifies the scheduler that the session is finished
......
......@@ -38,11 +38,13 @@ cta::TapeJob::TapeJob(
const std::string &id,
const std::string &userRequestId,
const uint32_t copyNb,
const std::string &remoteFile):
const std::string &remoteFile,
const uint64_t castorNsFileId):
m_id(id),
m_userRequestId(userRequestId),
m_copyNb(copyNb),
m_remoteFile(remoteFile) {
m_remoteFile(remoteFile),
m_castorNsFileId(castorNsFileId) {
}
//------------------------------------------------------------------------------
......@@ -72,3 +74,10 @@ uint32_t cta::TapeJob::getCopyNb() const throw() {
const std::string &cta::TapeJob::getRemoteFile() const throw() {
return m_remoteFile;
}
//------------------------------------------------------------------------------
// getCastorNsFileId
//------------------------------------------------------------------------------
uint64_t cta::TapeJob::getCastorNsFileId() const throw() {
return m_castorNsFileId;
}
......@@ -48,12 +48,16 @@ public:
* @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 std::string &remoteFile,
const uint64_t castorNsFileId);
/**
* Returns the identifier of the tape job.
......@@ -87,16 +91,35 @@ public:
*/
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() = 0;
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() = 0;
virtual void failed(const std::exception &ex) = 0;
/**
* Indicates that the job should be tried again (typically reaching the end
* of the tape).
......@@ -126,6 +149,13 @@ private:
*/
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
......@@ -20,6 +20,8 @@
#include "scheduler/MountType.hpp"
#include <string>
namespace cta {
/**
* A placeholder class from which will derive ArchiveSession and RetriveSession.
......@@ -35,6 +37,13 @@ namespace cta {
*/
virtual MountType::Enum getMountType() const throw() = 0;
/**
* Returns the volume identifier of the tape to be mounted.
*
* @return The volume identifier of the tape to be mounted.
*/
virtual std::string getVid() const throw() = 0;
/**
* Notifies the scheduler that the session is finished
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment