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

Created shared structures for representing tape copies.

Moved mock scheduler DB in a separate directory to reduce the number of files per directory.
parent 7cf734fb
......@@ -17,6 +17,7 @@ set (COMMON_LIB_SRC_FILES
RemotePathAndStatus.cpp
SmartFd.cpp
strerror_r_wrapper.cpp
TapeCopyLocationAndStatus.cpp
Timer.cpp
threading/ChildProcess.cpp
threading/Mutex.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 "common/TapeCopyLocationAndStatus.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta::TapeCopyLocationAndStatus::TapeCopyLocationAndStatus() {
}
//------------------------------------------------------------------------------
// 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) {}
/*
* 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/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 */
}; // class RemotePathAndStatus
} // namespace cta
......@@ -24,6 +24,9 @@
#include <string>
namespace cta {
// Forward declaration
// class ArchivePath;
class RemotePathAndStatus;
/**
* Class representing the transfer of a single copy of a remote file to tape.
......
/*
* 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/ArchiveMount.hpp"
namespace cta {
ArchiveMount::ArchiveMount(std::unique_ptr<cta::SchedulerDatabase::TapeMount>& mount) {
// Check that the pointer is of the proper type
if (!dynamic_cast<cta::SchedulerDatabase::ArchiveMount *>(mount.get())) {
throw WrongMountType("In ArchiveMount::ArchiveMount(): could not cast mount to SchedulerDatabase::ArchiveMount");
}
m_dbMount.reset(dynamic_cast<cta::SchedulerDatabase::ArchiveMount *>(mount.release()));
}
void ArchiveMount::finish() {
throw NotImplemented ("");
}
ArchiveMount::~ArchiveMount() {
}
}
\ No newline at end of file
......@@ -19,6 +19,8 @@
#pragma once
#include "TapeMount.hpp"
#include "SchedulerDatabase.hpp"
#include "common/exception/Exception.hpp"
#include <memory>
namespace cta {
......@@ -30,21 +32,26 @@ namespace cta {
* the Scheduler class.
*/
class ArchiveMount: public TapeMount {
friend class Scheduler;
private:
ArchiveMount(std::unique_ptr<cta::SchedulerDatabase::TapeMount> &mount);
public:
CTA_GENERATE_EXCEPTION_CLASS(WrongMountType);
CTA_GENERATE_EXCEPTION_CLASS(NotImplemented);
/**
* Notifies the scheduler that the session is finished
*/
virtual void finish();
/**
* Generator
* Job factory
*/
std::unique_ptr<ArchiveMount> getNextJob();
virtual ~ArchiveMount();
private:
std::unique_ptr<cta::SchedulerDatabase::ArchiveMount> m_dbMount;
};
}
......@@ -8,6 +8,7 @@ set (CTA_SCHEDULER_SRC_FILES
AdminHost.cpp
AdminUser.cpp
ArchiveJob.cpp
ArchiveMount.cpp
ArchiveRoute.cpp
ArchiveRouteId.cpp
ArchiveRequest.cpp
......@@ -20,8 +21,8 @@ set (CTA_SCHEDULER_SRC_FILES
DriveQuota.cpp
TapeJob.cpp
LogicalLibrary.cpp
MockSchedulerDatabase.cpp
MockSchedulerDatabaseFactory.cpp
MockDB/MockSchedulerDatabase.cpp
MockDB/MockSchedulerDatabaseFactory.cpp
MountCriteria.cpp
RetrieveJob.cpp
RetrieveFromTapeCopyRequest.cpp
......@@ -50,8 +51,8 @@ add_library (ctascheduler SHARED
target_link_libraries (ctascheduler ${SQLITE3_LIBRARY_RELEASE})
add_library (ctaschedulertest SHARED
MockSchedulerDatabase.cpp
MockSchedulerDatabaseFactory.cpp
MockDB/MockSchedulerDatabase.cpp
MockDB/MockSchedulerDatabaseFactory.cpp
SchedulerDatabaseFactory.cpp
SchedulerDatabaseTest.cpp
SchedulerTest.cpp
......
......@@ -27,7 +27,7 @@
#include "scheduler/ArchiveToTapeCopyRequest.hpp"
#include "scheduler/ArchiveRoute.hpp"
#include "scheduler/LogicalLibrary.hpp"
#include "scheduler/MockSchedulerDatabase.hpp"
#include "scheduler/MockDB/MockSchedulerDatabase.hpp"
#include "scheduler/RetrieveFromTapeCopyRequest.hpp"
#include "scheduler/RetrieveToFileRequest.hpp"
#include "scheduler/SecurityIdentity.hpp"
......
......@@ -24,6 +24,7 @@
#include "remotens/RemoteNS.hpp"
#include "scheduler/AdminHost.hpp"
#include "scheduler/AdminUser.hpp"
#include "scheduler/ArchiveMount.hpp"
#include "scheduler/ArchiveRoute.hpp"
#include "scheduler/ArchiveToDirRequest.hpp"
#include "scheduler/ArchiveToFileRequest.hpp"
......@@ -750,6 +751,9 @@ std::unique_ptr<cta::TapeMount> cta::Scheduler::getNextMount(
if (!mount.get()) {
return std::unique_ptr<cta::TapeMount>(NULL);
} else if (dynamic_cast<SchedulerDatabase::ArchiveMount *>(mount.get())) {
// Create out own ArchiveMount structure, which immediately takes
// ownership of the mount.
std::unique_ptr<ArchiveMount> internalRet(new ArchiveMount(mount));
throw NotImplemented("Archive");
} else if (dynamic_cast<SchedulerDatabase::RetriveMount *>(mount.get())) {
throw NotImplemented("Retrive");
......
......@@ -172,9 +172,8 @@ public:
class ArchiveMount: public TapeMount {
friend class SchedulerDatabase;
private:
ArchiveMount();
public:
virtual ~ArchiveMount() {};
};
class ArchiveJob {
......
......@@ -20,8 +20,8 @@
#include "scheduler/AdminHost.hpp"
#include "scheduler/AdminUser.hpp"
#include "scheduler/ArchiveRoute.hpp"
#include "scheduler/MockSchedulerDatabase.hpp"
#include "scheduler/MockSchedulerDatabaseFactory.hpp"
#include "scheduler/MockDB/MockSchedulerDatabase.hpp"
#include "scheduler/MockDB/MockSchedulerDatabaseFactory.hpp"
#include "scheduler/SchedulerDatabase.hpp"
#include "scheduler/SchedulerDatabaseFactory.hpp"
#include "scheduler/SecurityIdentity.hpp"
......
......@@ -25,7 +25,7 @@
#include "scheduler/ArchiveToFileRequest.hpp"
#include "scheduler/ArchiveToTapeCopyRequest.hpp"
#include "scheduler/LogicalLibrary.hpp"
#include "scheduler/MockSchedulerDatabaseFactory.hpp"
#include "scheduler/MockDB/MockSchedulerDatabaseFactory.hpp"
#include "scheduler/MountRequest.hpp"
#include "scheduler/Scheduler.hpp"
#include "scheduler/SchedulerDatabase.hpp"
......
......@@ -25,7 +25,7 @@
#include "scheduler/ArchiveRoute.hpp"
#include "scheduler/ArchiveToTapeCopyRequest.hpp"
#include "scheduler/LogicalLibrary.hpp"
#include "scheduler/MockSchedulerDatabase.hpp"
#include "scheduler/MockDB/MockSchedulerDatabase.hpp"
#include "scheduler/RetrieveFromTapeCopyRequest.hpp"
#include "scheduler/StorageClass.hpp"
#include "scheduler/SchedulerDatabase.hpp"
......
......@@ -27,7 +27,7 @@
#include "scheduler/ArchiveToTapeCopyRequest.hpp"
#include "scheduler/LogicalLibrary.hpp"
#include "scheduler/OStoreDB/OStoreDB.hpp"
#include "scheduler/MockSchedulerDatabase.hpp"
#include "scheduler/MockDB/MockSchedulerDatabase.hpp"
#include "scheduler/RetrieveFromTapeCopyRequest.hpp"
#include "scheduler/StorageClass.hpp"
#include "scheduler/SchedulerDatabase.hpp"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment