Commit 10fc760a authored by Steven Murray's avatar Steven Murray
Browse files

Archival and retrieval jobs are now for individual files

parent f50bd2c5
#include "ArchivalJob.hpp"
//------------------------------------------------------------------------------
// JobStateToStr
//------------------------------------------------------------------------------
const char *cta::ArchivalJob::JobStateToStr(const JobState enumValue) throw() {
switch(enumValue) {
case JOBSTATE_NONE : return "NONE";
case JOBSTATE_PENDING: return "PENDING";
case JOBSTATE_SUCCESS: return "SUCCESS";
case JOBSTATE_ERROR : return "ERROR";
default : return "UNKNOWN";
}
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::ArchivalJob::ArchivalJob():
m_state(JOBSTATE_NONE),
m_totalNbFileTransfers(0),
m_nbFailedFileTransfers(0),
m_state(ArchivalJobState::NONE),
m_creationTime(time(NULL)) {
}
......@@ -27,46 +12,50 @@ cta::ArchivalJob::ArchivalJob():
// constructor
//------------------------------------------------------------------------------
cta::ArchivalJob::ArchivalJob(
const std::string &id,
const JobState state,
const uint32_t totalNbFileTransfers,
const UserIdentity &creator,
const std::string &comment):
m_id(id),
const ArchivalJobState::Enum state,
const std::string &srcUrl,
const std::string &dstPath,
const UserIdentity &creator):
m_state(state),
m_totalNbFileTransfers(totalNbFileTransfers),
m_nbFailedFileTransfers(0),
m_srcUrl(srcUrl),
m_dstPath(dstPath),
m_creationTime(time(NULL)),
m_creator(creator),
m_comment(comment) {
m_creator(creator) {
}
//------------------------------------------------------------------------------
// getId
// setState
//------------------------------------------------------------------------------
const std::string &cta::ArchivalJob::getId() const throw() {
return m_id;
void cta::ArchivalJob::setState(const ArchivalJobState::Enum state) {
m_state = state;
}
//------------------------------------------------------------------------------
// getState
//------------------------------------------------------------------------------
cta::ArchivalJob::JobState cta::ArchivalJob::getState() const throw() {
cta::ArchivalJobState::Enum cta::ArchivalJob::getState() const throw() {
return m_state;
}
}
//------------------------------------------------------------------------------
// getStateStr
//------------------------------------------------------------------------------
const char *cta::ArchivalJob::getStateStr() const throw() {
return ArchivalJobState::toStr(m_state);
}
//------------------------------------------------------------------------------
// getTotalNbFileTransfers
// getSrcUrl
//------------------------------------------------------------------------------
uint32_t cta::ArchivalJob::getTotalNbFileTransfers() const throw() {
return m_totalNbFileTransfers;
const std::string &cta::ArchivalJob::getSrcUrl() const throw() {
return m_srcUrl;
}
//------------------------------------------------------------------------------
// getNbFailedFileTransfers
// getDstPath
//------------------------------------------------------------------------------
uint32_t cta::ArchivalJob::getNbFailedFileTransfers() const throw() {
return m_nbFailedFileTransfers;
const std::string &cta::ArchivalJob::getDstPath() const throw() {
return m_dstPath;
}
//------------------------------------------------------------------------------
......@@ -79,14 +68,6 @@ time_t cta::ArchivalJob::getCreationTime() const throw() {
//------------------------------------------------------------------------------
// getCreator
//------------------------------------------------------------------------------
const cta::UserIdentity &cta::ArchivalJob::getCreator()
const throw() {
const cta::UserIdentity &cta::ArchivalJob::getCreator() const throw() {
return m_creator;
}
//------------------------------------------------------------------------------
// getComment
//------------------------------------------------------------------------------
const std::string &cta::ArchivalJob::getComment() const throw() {
return m_comment;
}
#pragma once
#include "ArchivalJobState.hpp"
#include "UserIdentity.hpp"
#include <stdint.h>
#include <string>
#include <time.h>
namespace cta {
/**
* Class representing an archival job.
* Class representing the job of archiving a file to tape.
*/
class ArchivalJob {
public:
/**
* Enumeration of the possible states of an archival job.
*/
enum JobState {
JOBSTATE_NONE,
JOBSTATE_PENDING,
JOBSTATE_SUCCESS,
JOBSTATE_ERROR};
/**
* Thread safe method that returns the string representation of the
* enumeration value.
*
* @param enumValue The enumeration value.
* @return The string representation.
*/
static const char *JobStateToStr(const JobState enumValue) throw();
/**
* Constructor.
*/
......@@ -39,106 +22,94 @@ public:
/**
* Constructor.
*
* @param id The identification string of the archival job.
* @param state The state of the archival job.
* @param totalNbFileTransfers The total number of file transfers
* represented by the archival job.
* @param creator The identity of the user that created the archival job.
* @param comment The comment describing the archival job.
* @param srcUrl The URL of the source file.
* @param dstPath The full path of the destination file within the archive.
* @param creator The identity of the user that created the job.
*/
ArchivalJob(
const std::string &id,
const JobState state,
const uint32_t totalNbFileTransfers,
const UserIdentity &creator,
const std::string &comment);
const ArchivalJobState::Enum state,
const std::string &srcUrl,
const std::string &dstPath,
const UserIdentity &creator);
/**
* Returns the identification string of the archival job.
* Sets the state of the archival job.
*
* @return The identification string of the archival job.
* @param state The new state of the archival job.
*/
const std::string &getId() const throw();
void setState(const ArchivalJobState::Enum state);
/**
* Returns the state of the archival job.
*
* @return The state of the archival job.
*/
JobState getState() const throw();
ArchivalJobState::Enum getState() const throw();
/**
* Returns the total number of file transfers represented by the archival job.
* Thread safe method that returns the string representation of the state of
* the archival job.
*
* @return The total number of file transfers represented by the archival job.
* @return The string representation of the state of the archival job.
*/
uint32_t getTotalNbFileTransfers() const throw();
const char *getStateStr() const throw();
/**
* Returns the number of failed file transfers.
* Returns the URL of the source file.
*
* @return The number of failed file transfers.
* @return The URL of the source file.
*/
uint32_t getNbFailedFileTransfers() const throw();
const std::string &getSrcUrl() const throw();
/**
* Returns the time when the archival job was created.
* Returns the full path of the destination file within the archive.
*
* @return The time when the archival job was created.
* @return The full path of the destination file within the archive.
*/
time_t getCreationTime() const throw();
const std::string &getDstPath() const throw();
/**
* Returns the identity of the user that created the archival job.
* Returns the time when the job was created.
*
* @return The identity of the user that created the archival job.
* @return The time when the job was created.
*/
const UserIdentity &getCreator() const throw();
time_t getCreationTime() const throw();
/**
* Returns the comment describing the archival job.
* Returns the identity of the user that created the job.
*
* @return The comment describing the archival job.
* @return The identity of the user that created the job.
*/
const std::string &getComment() const throw();
const UserIdentity &getCreator() const throw();
private:
/**
* The identification string of the archival job.
*/
std::string m_id;
/**
* The state of the archival job.
*/
JobState m_state;
ArchivalJobState::Enum m_state;
/**
* The total number of file transfers repesented by this archival job.
* The URL of the source file.
*/
uint32_t m_totalNbFileTransfers;
std::string m_srcUrl;
/**
* The number of failed file transfers.
* The full path of the destination file within the archive.
*/
uint32_t m_nbFailedFileTransfers;
std::string m_dstPath;
/**
* The time when the archival job was created.
* The time when the job was created.
*/
time_t m_creationTime;
/**
* The identity of the user that created the archival job.
* The identity of the user that created the job.
*/
UserIdentity m_creator;
/**
* Comment describing the archival job.
*/
std::string m_comment;
}; // class ArchivalJob
}; // class FileArchival
} // namespace cta
#include "ArchivalJob.hpp"
//------------------------------------------------------------------------------
// toStr
//------------------------------------------------------------------------------
const char *cta::ArchivalJobState::toStr(const Enum enumValue) throw() {
switch(enumValue) {
case NONE : return "NONE";
case PENDING: return "PENDING";
case SUCCESS: return "SUCCESS";
case ERROR : return "ERROR";
default : return "UNKNOWN";
}
}
#pragma once
namespace cta {
/**
* The possible states of an archival job.
*/
class ArchivalJobState {
public:
/**
* Enumeration of the possible states of an archival job.
*/
enum Enum {
NONE,
PENDING,
SUCCESS,
ERROR};
/**
* Thread safe method that returns the string representation of the
* enumeration value.
*
* @param enumValue The enumeration value.
* @return The string representation.
*/
static const char *toStr(const Enum enumValue) throw();
}; // class ArchivalJobState
} // namespace cta
......@@ -4,12 +4,11 @@ set (MIDDLE_TIER_LIB_SRC_FILES
AdminHost.cpp
AdminUser.cpp
ArchivalJob.cpp
ArchivalJobState.cpp
DirectoryEntry.cpp
DirectoryIterator.cpp
Exception.cpp
FileArchivalJob.cpp
FileAttribute.cpp
FileRetrievalJob.cpp
FileSystemDirectoryEntry.cpp
FileSystemNode.cpp
FileSystemStorageClass.cpp
......@@ -29,6 +28,8 @@ set (MIDDLE_TIER_LIB_SRC_FILES
MockMigrationRouteTable.cpp
MockTapeTable.cpp
MockTapePoolTable.cpp
RetrievalJob.cpp
RetrievalJobState.cpp
SecurityIdentity.cpp
StorageClass.cpp
Tape.cpp
......
#include "FileArchivalJob.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::FileArchivalJob::FileArchivalJob():
m_creationTime(time(NULL)) {
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::FileArchivalJob::FileArchivalJob(
const std::string &srcUrl,
const std::string &dstPath,
const UserIdentity &creator):
m_srcUrl(srcUrl),
m_dstPath(dstPath),
m_creationTime(time(NULL)),
m_creator(creator) {
}
//------------------------------------------------------------------------------
// getSrcUrl
//------------------------------------------------------------------------------
const std::string &cta::FileArchivalJob::getSrcUrl() const throw() {
return m_srcUrl;
}
//------------------------------------------------------------------------------
// getDstPath
//------------------------------------------------------------------------------
const std::string &cta::FileArchivalJob::getDstPath() const throw() {
return m_dstPath;
}
//------------------------------------------------------------------------------
// getCreationTime
//------------------------------------------------------------------------------
time_t cta::FileArchivalJob::getCreationTime() const throw() {
return m_creationTime;
}
//------------------------------------------------------------------------------
// getCreator
//------------------------------------------------------------------------------
const cta::UserIdentity &cta::FileArchivalJob::getCreator() const throw() {
return m_creator;
}
#pragma once
#include "UserIdentity.hpp"
#include <string>
#include <time.h>
namespace cta {
/**
* Class representing the job of archiving a file to tape.
*/
class FileArchivalJob {
public:
/**
* Constructor.
*/
FileArchivalJob();
/**
* Constructor.
*
* @param srcUrl The URL of the source file.
* @param dstPath The full path of the destination file within the archive.
* @param creator The identity of the user that created the job.
*/
FileArchivalJob(
const std::string &srcUrl,
const std::string &dstPath,
const UserIdentity &creator);
/**
* Returns the URL of the source file.
*
* @return The URL of the source file.
*/
const std::string &getSrcUrl() const throw();
/**
* Returns the full path of the destination file within the archive.
*
* @return The full path of the destination file within the archive.
*/
const std::string &getDstPath() const throw();
/**
* Returns the time when the job was created.
*
* @return The time when the job was created.
*/
time_t getCreationTime() const throw();
/**
* Returns the identity of the user that created the job.
*
* @return The identity of the user that created the job.
*/
const UserIdentity &getCreator() const throw();
private:
/**
* The URL of the source file.
*/
std::string m_srcUrl;
/**
* The full path of the destination file within the archive.
*/
std::string m_dstPath;
/**
* The time when the job was created.
*/
time_t m_creationTime;
/**
* The identity of the user that created the job.
*/
UserIdentity m_creator;
}; // class FileArchival
} // namespace cta
......@@ -2,16 +2,17 @@
#include "ArchivalJob.hpp"
#include "DirectoryIterator.hpp"
#include "FileArchivalJob.hpp"
#include "FileRetrievalJob.hpp"
#include "LogicalLibrary.hpp"
#include "MigrationRoute.hpp"
#include "RetrievalJob.hpp"
#include "SecurityIdentity.hpp"
#include "StorageClass.hpp"
#include "Tape.hpp"
#include "TapePool.hpp"
#include "UserIdentity.hpp"
#include <list>
#include <map>
#include <stdint.h>
#include <string>
......@@ -116,36 +117,35 @@ public:
* @param requester The identity of the user requesting the archival.
* @param srcUrls List of one or more source files.
* @param dst Destination file or directory within the archive namespace.
* @return The string identifier of the archival job.
*/
virtual std::string archive(
virtual void archive(
const SecurityIdentity &requester,
const std::list<std::string> &srcUrls,
const std::string &dst) = 0;
/**
* Gets the list of archival jobs associated with the specified tape pool.
* Returns all of the existing archival jobs grouped by tape pool and then
* sorted by creation time in ascending order (oldest first).
*
* @param requester The identity of the user requesting the list.
* @param tapePoolName The name of the tape pool.
* @return The list of jobs sorted by creation time in ascending order
* (oldest first).
* @return All of the existing archival jobs grouped by tape pool and then
* sorted by creation time in ascending order (oldest first).
*/
virtual std::list<ArchivalJob> getArchivalJobs(
const SecurityIdentity &requester,
const std::string &tapePoolName) = 0;
virtual std::map<TapePool, std::list<ArchivalJob> > getArchivalJobs(
const SecurityIdentity &requester) = 0;
/**
* Returns the individual file archival jobs associated with the specified
* archive job.
* Returns the list of archival jobs associated with the specified tape pool
* sorted by creation time in ascending order (oldest first).
*
* @param requester The identity of the user requesting the list.
* @param archiveJobId The string identifer of the archive job.
* @return The individual file archival jobs.
* @param tapePoolName The name of the tape pool.
* @return The list of archival jobs associated with the specified tape pool
* sorted by creation time in ascending order (oldest first).
*/
virtual std::list<FileArchivalJob> getFileArchivalJobs(
virtual std::list<ArchivalJob> getArchivalJobs(
const SecurityIdentity &requester,
const std::string &archiveJobId) = 0;
const std::string &tapePoolName) = 0;
/**
* Creates a retrieval job to asynchronously retrieve the specified archived
......@@ -160,24 +160,35 @@ public:
* @param requester The identity of the user requesting the retrieval.
* @param srcPaths The list of one of more archived files.
* @param dstUrl The URL of the destination file or directory.
* @return The string identifier of the retrieval job.
*/
virtual std::string retrieve(
virtual void retrieve(
const SecurityIdentity &requester,
const std::list<std::string> &srcPaths,
const std::string &dstUrl) = 0;
/**
* Gets the individual file retrieval jobs associated with the specified
* retrieval job.
* Returns all of the existing retrieval jobs grouped by tape and then
* sorted by creation time in ascending order (oldest first).
*
* @param requester The identity of the user requesting the list.
* @return All of the existing retrieval jobs grouped by tape and then
* sorted by creation time in ascending order (oldest first).
*/
virtual std::map<Tape, std::list<RetrievalJob> > getRetrievalJobs(
const SecurityIdentity &requester) = 0;
/**
* Returns the list of retrieval jobs associated with the specified tape
* sorted by creation time in ascending order (oldest first).
*
* @param requester The identity of the user requesting the list.
* @param retrievalJobId The string identifer of the retrieval job.
* @return The list of individual file retrieval jobs.
* @param vid The volume identifier of the tape.
* @return The list of retrieval jobs associated with the specified tape
* sorted by creation time in ascending order (oldest first).
*/
virtual std::list<FileRetrievalJob> getFileRetrievalJobs(
virtual std::list<RetrievalJob> getRetrievalJobs(
const SecurityIdentity &requester,
const std::string &vretrievalJobId) = 0;
const std::string &vid) = 0;
}; // class MiddleTierUser
......
......@@ -205,7 +205,7 @@ std::string cta::MockMiddleTierUser::getDirectoryStorageClass(
//------------------------------------------------------------------------------
// archive