Commit 5000de33 authored by Eric Cano's avatar Eric Cano
Browse files

Partial creation of the mount interface for the tape server.

parent 910a94f8
......@@ -29,13 +29,15 @@ namespace cta {
* Class representing the transfer of a single copy of a remote file to tape.
*/
class ArchiveJob: public TapeJob {
public:
friend class ArchiveMount;
private:
/**
* Constructor.
* Constructor. It is private as the ArchiveJob is generated by the
* ArchiveMount.
*/
ArchiveJob();
public:
/**
* Destructor.
*/
......@@ -63,7 +65,22 @@ public:
* @return the name of the destination tape pool.
*/
const std::string &getTapePoolName() const throw();
/**
* Indicates that the job was successful
*/
void complete();
/**
* Indicates that the job failed
*/
void failed();
/**
* Indicates that the job should be tried again (typically reaching the end
* of the tape).
*/
void retry();
private:
/**
......
/*
* 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 "TapeMount.hpp"
#include <memory>
namespace cta {
class ArchiveMount;
/**
* The class driving a retrieve mount.
* The class only has private constructors as it is instanciated by
* the Scheduler class.
*/
class ArchiveMount: public TapeMount {
private:
public:
/**
* Notifies the scheduler that the session is finished
*/
virtual void finish();
/**
* Generator
*/
std::unique_ptr<ArchiveMount> getNextJob();
virtual ~ArchiveMount();
private:
};
}
......@@ -197,6 +197,13 @@ cta::MockSchedulerDatabase::~MockSchedulerDatabase() throw() {
sqlite3_close(m_dbHandle);
}
std::unique_ptr<cta::SchedulerDatabase::TapeMount>
cta::MockSchedulerDatabase::getNextMount(const std::string& logicalLibrary,
const std::string& driveName) {
throw NotImplemented("");
}
//------------------------------------------------------------------------------
// queue
//------------------------------------------------------------------------------
......
......@@ -20,6 +20,7 @@
#include "scheduler/SchedulerDatabase.hpp"
#include "scheduler/SecurityIdentity.hpp"
#include "common/exception/Exception.hpp"
#include <sqlite3.h>
......@@ -41,6 +42,21 @@ public:
*/
~MockSchedulerDatabase() throw();
CTA_GENERATE_EXCEPTION_CLASS(NotImplemented);
/**
* Starts a session, and updates the relevant information in the DB.
* The returned object will be the scheduler's interface for the tape server
* throughout the session.
* @param logicalLibrary name of the logical library, allowing selection
* of reachable tapes for this drive
* @param driveName name of the drive, allowing enforcement of dedication
* policies for tapes and drives.
* @return smart pointer to a TapeSession. It can be an ArchiveMount,
* a RetrieveMount or nullptr.
*/
virtual std::unique_ptr<SchedulerDatabase::TapeMount> getNextMount(const std::string &logicalLibrary,
const std::string &driveName);
/*
* Subclass allowing the tracking and automated cleanup of a
* ArchiveToFile requests on the SchdulerDB. Those 2 operations (creation+close
......
......@@ -60,8 +60,14 @@ void OStoreDB::setAgent(objectstore::Agent& agent) {
void OStoreDB::assertAgentSet() {
if (!m_agent)
throw AgentNotSet("In OStoreDB::assertAgentSet: Agent pointer not set");
}
std::unique_ptr<SchedulerDatabase::TapeMount>
OStoreDB::getNextMount(const std::string& logicalLibrary, const std::string& driveName) {
throw NotImplemented("");
}
void OStoreDB::createAdminHost(const SecurityIdentity& requester,
const std::string& hostName, const std::string& comment) {
RootEntry re(m_objectStore);
......
......@@ -40,6 +40,11 @@ public:
private:
void assertAgentSet();
public:
CTA_GENERATE_EXCEPTION_CLASS(NotImplemented);
/* === Session handling =================================================== */
virtual std::unique_ptr<SchedulerDatabase::TapeMount> getNextMount(const std::string &logicalLibrary,
const std::string &driveName);
/* === Admin host handling ================================================ */
virtual void createAdminHost(const SecurityIdentity& requester,
......
......@@ -183,6 +183,12 @@ public:
virtual std::list<RetrieveFromTapeCopyRequest> getRetrieveRequests(const std::string& vid) const {
return m_OStoreDB.getRetrieveRequests(vid);
}
virtual std::unique_ptr<TapeMount> getNextMount(const std::string& logicalLibrary, const std::string& driveName) {
return m_OStoreDB.getNextMount(logicalLibrary, driveName);
}
virtual StorageClass getStorageClass(const std::string& name) const {
return m_OStoreDB.getStorageClass(name);
......
/*
* 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 <memory>
namespace cta {
class RetrieveMount;
/**
* The class driving a retrieve mount.
* The class only has private constructors as it is instanciated by
* the Scheduler class.
*/
class RetrieveMount {
private:
public:
/**
* Notifies the scheduler that the session is finished
*/
virtual void finish();
/**
* Generator
*/
std::unique_ptr<RetrieveMount> getNextJob();
virtual ~RetrieveMount();
private:
};
}
\ No newline at end of file
......@@ -38,6 +38,7 @@
#include "scheduler/StorageClass.hpp"
#include "scheduler/Tape.hpp"
#include "scheduler/TapePool.hpp"
#include "scheduler/TapeMount.hpp"
#include <iostream>
#include <sstream>
......@@ -741,55 +742,67 @@ void cta::Scheduler::queueRetrieveRequest(
//------------------------------------------------------------------------------
// getNextMount
//------------------------------------------------------------------------------
cta::MountRequest *cta::Scheduler::getNextMount(
const std::string &logicalLibraryName) {
return NULL;
}
//------------------------------------------------------------------------------
// finishedMount
//------------------------------------------------------------------------------
void cta::Scheduler::finishedMount(const std::string &mountId) {
}
//------------------------------------------------------------------------------
// getNextArchive
//------------------------------------------------------------------------------
cta::ArchiveJob *cta::Scheduler::getNextArchive(
const std::string &mountId) {
return NULL;
}
//------------------------------------------------------------------------------
// archiveSuccessful
//------------------------------------------------------------------------------
void cta::Scheduler::archiveSuccessful(const std::string &transferId) {
}
//------------------------------------------------------------------------------
// archiveFailed
//------------------------------------------------------------------------------
void cta::Scheduler::archiveFailed(const std::string &transferId,
const TapeJobFailure failureType, const std::string &errorMessage) {
}
//------------------------------------------------------------------------------
// getNextRetrieve
//------------------------------------------------------------------------------
cta::RetrieveJob *cta::Scheduler::getNextRetrieve(
const std::string &mountId) {
return NULL;
}
//------------------------------------------------------------------------------
// retrieveSucceeded
//------------------------------------------------------------------------------
void cta::Scheduler::retrieveSucceeded(const std::string &transferId) {
}
//------------------------------------------------------------------------------
// retrieveFailed
//------------------------------------------------------------------------------
void cta::Scheduler::retrieveFailed(const std::string &transferId,
const TapeJobFailure failureType, const std::string &errorMessage) {
std::unique_ptr<cta::TapeMount> cta::Scheduler::getNextMount(
const std::string &logicalLibraryName, const std::string & driveName) {
// First try to get the next mount from the database.
std::unique_ptr<SchedulerDatabase::TapeMount>
mount(m_db.getNextMount(logicalLibraryName, driveName));
if (!mount.get()) {
return std::unique_ptr<cta::TapeMount>(NULL);
} else if (dynamic_cast<SchedulerDatabase::ArchiveMount *>(mount.get())) {
throw NotImplemented("Archive");
} else if (dynamic_cast<SchedulerDatabase::RetriveMount *>(mount.get())) {
throw NotImplemented("Retrive");
} else {
throw NotImplemented("Unknown type");
}
throw NotImplemented("");
}
//
////------------------------------------------------------------------------------
//// finishedMount
////------------------------------------------------------------------------------
//void cta::Scheduler::finishedMount(const std::string &mountId) {
//}
//
////------------------------------------------------------------------------------
//// getNextArchive
////------------------------------------------------------------------------------
//cta::ArchiveJob *cta::Scheduler::getNextArchive(
// const std::string &mountId) {
// return NULL;
//}
//
////------------------------------------------------------------------------------
//// archiveSuccessful
////------------------------------------------------------------------------------
//void cta::Scheduler::archiveSuccessful(const std::string &transferId) {
//}
//
////------------------------------------------------------------------------------
//// archiveFailed
////------------------------------------------------------------------------------
//void cta::Scheduler::archiveFailed(const std::string &transferId,
// const TapeJobFailure failureType, const std::string &errorMessage) {
//}
//
////------------------------------------------------------------------------------
//// getNextRetrieve
////------------------------------------------------------------------------------
//cta::RetrieveJob *cta::Scheduler::getNextRetrieve(
// const std::string &mountId) {
// return NULL;
//}
//
////------------------------------------------------------------------------------
//// retrieveSucceeded
////------------------------------------------------------------------------------
//void cta::Scheduler::retrieveSucceeded(const std::string &transferId) {
//}
//
////------------------------------------------------------------------------------
//// retrieveFailed
////------------------------------------------------------------------------------
//void cta::Scheduler::retrieveFailed(const std::string &transferId,
// const TapeJobFailure failureType, const std::string &errorMessage) {
//}
......@@ -19,6 +19,7 @@
#pragma once
#include "scheduler/SchedulerDatabase.hpp"
#include "common/exception/Exception.hpp"
#include <list>
#include <map>
......@@ -31,7 +32,6 @@ namespace cta {
// Forward declarations for opaque references.
class AdminHost;
class AdminUser;
class ArchiveJob;
class ArchiveFileStatus;
class ArchiveRoute;
class ArchiveToDirRequest;
......@@ -39,11 +39,9 @@ class ArchiveToFileRequest;
class ArchiveToTapeCopyRequest;
class ArchiveDirIterator;
class LogicalLibrary;
class MountRequest;
class NameServer;
class RemoteNS;
class RemotePathAndStatus;
class RetrieveJob;
class RetrieveFromTapeCopyRequest;
class RetrieveToDirRequest;
class RetrieveToFileRequest;
......@@ -51,6 +49,7 @@ class SchedulerDatabase;
class SecurityIdentity;
class StorageClass;
class Tape;
class TapeMount;
class TapePool;
class UserIdentity;
......@@ -631,78 +630,81 @@ public:
const SecurityIdentity &requester,
const std::list<std::string> &archiveFiles,
const std::string &remoteFileOrDir);
CTA_GENERATE_EXCEPTION_CLASS(NotImplemented);
/**
* Returns the next tape mount for the specified logical liubrary.
* Returns the next tape mount for the specified logical library.
* All the functions of the mount will handled via the mount object
* itself. This is the entry point to the tape server's interface
*
* @param logicalLibraryName The name of the logical library.
* @return The next tape mount or NULL if there is currently no work to bei
* done.
*/
MountRequest *getNextMount(const std::string &logicalLibraryName);
/**
* Notifies the scheduler that the specified tape mount is over.
*
* @param mountId The identifier of the tape mount.
*/
void finishedMount(const std::string &mountId);
/**
* Returns the next archive job to be carried out for the specified tape
* mount or NULL if there is no more work to be done.
*
* @param mountId The identifier of the tape mount.
* @return The next tape job to be carried out for the specified tape
* mount or NULL if there is no more work to be done.
*/
ArchiveJob *getNextArchive(const std::string &mountId);
/**
* Notifies the scheduler that the specified tape job has been completed
* successfully.
*
* @param transferId The identifier of the tape job.
*/
void archiveSuccessful(const std::string &transferId);
/**
* Notifies the scheduler that the specified tape job has failed.
*
* @param transferId The identifier of the tape job.
* @param failureType The type of failure.
* @param errorMessage Human readable description of the failure.
*/
void archiveFailed(const std::string &transferId,
const TapeJobFailure failureType, const std::string &errorMessage);
/**
* Returns the next tape job to be carried out for the specified tape
* mount or NULL if there is no more work to be done.
*
* @param mountId The identifier of the tape mount.
* @return The next tape job to be carried out for the specified tape
* mount or NULL if there is no more work to be done.
*/
RetrieveJob *getNextRetrieve(const std::string &mountId);
/**
* Notifies the scheduler that the specified tape job has been completed
* successfully.
*
* @param transferId The identifier of the tape job.
*/
void retrieveSucceeded(const std::string &transferId);
/**
* Notifies the scheduler that the specified tape job has failed.
*
* @param transferId The identifier of the tape job.
* @param failureType The type of failure.
* @param errorMessage Human readable description of the failure.
*/
void retrieveFailed(const std::string &transferId,
const TapeJobFailure failureType, const std::string &errorMessage);
* @param driveName The drive's name.
* @return The next tape mount or NULL if there is currently no work to do.
*/
std::unique_ptr<TapeMount> getNextMount(const std::string &logicalLibraryName,
const std::string & driveName);
// class ArchiveMount:public TapeMount {
// public:
// class ArchiveJob
// std::unique_ptr<ArchiveJob> ArchiveJob
// };
// /**
// * Returns the next archive job to be carried out for the specified tape
// * mount or NULL if there is no more work to be done.
// *
// * @param mountId The identifier of the tape mount.
// * @return The next tape job to be carried out for the specified tape
// * mount or NULL if there is no more work to be done.
// */
// ArchiveJob *getNextArchive(const std::string &mountId);
//
// /**
// * Notifies the scheduler that the specified tape job has been completed
// * successfully.
// *
// * @param transferId The identifier of the tape job.
// */
// void archiveSuccessful(const std::string &transferId);
//
// /**
// * Notifies the scheduler that the specified tape job has failed.
// *
// * @param transferId The identifier of the tape job.
// * @param failureType The type of failure.
// * @param errorMessage Human readable description of the failure.
// */
// void archiveFailed(const std::string &transferId,
// const TapeJobFailure failureType, const std::string &errorMessage);
//
// /**
// * Returns the next tape job to be carried out for the specified tape
// * mount or NULL if there is no more work to be done.
// *
// * @param mountId The identifier of the tape mount.
// * @return The next tape job to be carried out for the specified tape
// * mount or NULL if there is no more work to be done.
// */
// RetrieveJob *getNextRetrieve(const std::string &mountId);
//
// /**
// * Notifies the scheduler that the specified tape job has been completed
// * successfully.
// *
// * @param transferId The identifier of the tape job.
// */
// void retrieveSucceeded(const std::string &transferId);
//
// /**
// * Notifies the scheduler that the specified tape job has failed.
// *
// * @param transferId The identifier of the tape job.
// * @param failureType The type of failure.
// * @param errorMessage Human readable description of the failure.
// */
// void retrieveFailed(const std::string &transferId,
// const TapeJobFailure failureType, const std::string &errorMessage);
private:
......
......@@ -64,16 +64,23 @@ public:
/**
* An umbrella class from which ArchiveSession and RetrieveSession will
* inherit. Just allows RTTI.
* Mounts, and jobs from the DB will be subclasses of the SchedulerDB
*/
class TapeSession {};
class TapeMount {public: virtual ~TapeMount(){}};
/**
* Starts a session, and updates the relevant information in the DB.
* The returned object will be the tape server's interface throughout
* the session.
* @return pointer to a TapeSession
*/
std::unique_ptr<TapeSession> startTapeSession();
* The returned object will be the scheduler's interface for the tape server
* throughout the session.
* @param logicalLibrary name of the logical library, allowing selection
* of reachable tapes for this drive
* @param driveName name of the drive, allowing enforcement of dedication
* policies for tapes and drives.
* @return smart pointer to a TapeSession. It can be an ArchiveMount,
* a RetrieveMount or nullptr.
*/
virtual std::unique_ptr<TapeMount> getNextMount(const std::string &logicalLibrary,
const std::string &driveName) = 0;
/*============ Archive management: user side ==============================*/
......@@ -163,21 +170,22 @@ public:
/*============ Archive management: tape server side =======================*/
class ArchiveSession: public TapeSession {
class ArchiveMount: public TapeMount {
friend class SchedulerDatabase;
private:
ArchiveSession();
ArchiveMount();
public:
};
class FileArchive {
friend class ArchiveSession;
class ArchiveJob {
friend class ArchiveMount;
public:
cta::RemotePathAndStatus remoteFile;
cta::ArchiveFileStatus archiveFile;
/* TODO */
};
/*============ Retrieve management: user side ============================*/
/**
* Queues the specified request.
*
......@@ -222,7 +230,26 @@ public:
virtual void deleteRetrieveRequest(
const SecurityIdentity &requester,
const std::string &remoteFile) = 0;
/*============ Retrieve management: tape server side ======================*/
class RetriveMount: public TapeMount {
friend class SchedulerDatabase;
private:
RetriveMount();
public:
};
class RetrieveJob {
friend class RetriveMount;
public:
cta::RemotePathAndStatus remoteFile;
cta::ArchiveFileStatus archiveFile;
/* TODO */
};
/*============ Admin user/host management ================================*/
/**
* Creates the specified administrator.
*
......@@ -289,6 +316,8 @@ public:
*/