diff --git a/objectstore/RetrieveToFileRequest.cpp b/objectstore/RetrieveToFileRequest.cpp index 332f31f518b00cdf7280a3467d67fff791a1f7bd..efa9890f79d089f71eab1c951c4f26eed861a96b 100644 --- a/objectstore/RetrieveToFileRequest.cpp +++ b/objectstore/RetrieveToFileRequest.cpp @@ -39,16 +39,18 @@ void cta::objectstore::RetrieveToFileRequest::initialize() { m_payloadInterpreted = true; } -void cta::objectstore::RetrieveToFileRequest::addJob(uint16_t copyNumber, - const std::string& tape, const std::string& tapeaddress) { +void cta::objectstore::RetrieveToFileRequest::addJob(const cta::TapeFileLocation & tapeFileLocation, + const std::string& tapeaddress) { checkPayloadWritable(); auto *j = m_payload.add_jobs(); - j->set_copynb(copyNumber); + j->set_copynb(tapeFileLocation.copyNb); j->set_status(serializers::RetrieveJobStatus::RJS_LinkingToTape); - j->set_tape(tape); + j->set_tape(tapeFileLocation.vid); j->set_tapeaddress(tapeaddress); j->set_totalretries(0); j->set_retrieswithinmount(0); + j->set_blockid(tapeFileLocation.blockId); + j->set_fseq(tapeFileLocation.fSeq); } void cta::objectstore::RetrieveToFileRequest::setArchiveFile( diff --git a/objectstore/RetrieveToFileRequest.hpp b/objectstore/RetrieveToFileRequest.hpp index 0a10533215a63df17afafe313204b96168f27315..d42a7906f309b1f441dc8430bca3783cdd793deb 100644 --- a/objectstore/RetrieveToFileRequest.hpp +++ b/objectstore/RetrieveToFileRequest.hpp @@ -21,6 +21,7 @@ #include "ObjectOps.hpp" #include "objectstore/cta.pb.h" #include <list> +#include "common/archiveNS/TapeFileLocation.hpp" namespace cta { namespace objectstore { @@ -34,7 +35,7 @@ public: RetrieveToFileRequest(const std::string & address, Backend & os); RetrieveToFileRequest(GenericObject & go); void initialize(); - void addJob(uint16_t copyNumber, const std::string & tape, + void addJob(const cta::TapeFileLocation & tapeFileLocation, const std::string & tapeaddress); void setArchiveFile(const std::string & archiveFile); std::string getArchiveFile(); @@ -51,6 +52,8 @@ public: uint16_t copyNb; std::string tape; std::string tapeAddress; + uint64_t fseq; + uint64_t blockid; }; std::list<JobDump> dumpJobs(); }; diff --git a/objectstore/Tape.cpp b/objectstore/Tape.cpp index c356a158240878fbd3f55f57349e9b7e5b857985..8e01e8f06a1617cfb92f73dd414072fe2033f3b0 100644 --- a/objectstore/Tape.cpp +++ b/objectstore/Tape.cpp @@ -18,6 +18,7 @@ #include "Tape.hpp" #include "GenericObject.hpp" +#include "CreationLog.hpp" cta::objectstore::Tape::Tape(const std::string& address, Backend& os): ObjectOps<serializers::Tape>(os, address) { } @@ -31,9 +32,11 @@ cta::objectstore::Tape::Tape(GenericObject& go): } void cta::objectstore::Tape::initialize(const std::string &name, - const std::string &logicallibrary) { + const std::string &logicallibrary, const cta::CreationLog & creationLog) { ObjectOps<serializers::Tape>::initialize(); // Set the reguired fields + objectstore::CreationLog oscl(creationLog); + oscl.serialize(*m_payload.mutable_log()); m_payload.set_vid(name); m_payload.set_bytesstored(0); m_payload.set_lastfseq(0); @@ -70,6 +73,20 @@ void cta::objectstore::Tape::removeIfEmpty() { } remove(); } + +cta::CreationLog cta::objectstore::Tape::getCreationLog() { + checkPayloadReadable(); + objectstore::CreationLog oscl; + oscl.deserialize(m_payload.log()); + return cta::CreationLog(oscl); +} + +void cta::objectstore::Tape::setCreationLog(const cta::CreationLog& creationLog) { + checkPayloadWritable(); + objectstore::CreationLog oscl(creationLog); + oscl.serialize(*m_payload.mutable_log()); +} + void cta::objectstore::Tape::setStoredData(uint64_t bytes) { checkPayloadWritable(); m_payload.set_bytesstored(bytes); @@ -144,6 +161,7 @@ void cta::objectstore::Tape::addJob(const RetrieveToFileRequest::JobDump& job, auto * j = m_payload.add_retrievejobs(); j->set_address(retrieveToFileAddress); j->set_size(size); + j->set_copynb(job.copyNb); } std::string cta::objectstore::Tape::getLogicalLibrary() { @@ -161,6 +179,37 @@ cta::objectstore::Tape::JobsSummary cta::objectstore::Tape::getJobsSummary() { return ret; } +auto cta::objectstore::Tape::dumpAndFetchRetrieveRequests() + -> std::list<RetrieveRequestDump> { + checkPayloadReadable(); + std::list<RetrieveRequestDump> ret; + auto & rjl = m_payload.retrievejobs(); + for (auto rj=rjl.begin(); rj!=rjl.end(); rj++) { + try { + cta::objectstore::RetrieveToFileRequest rtfr(rj->address(),m_objectStore); + objectstore::ScopedSharedLock rtfrl(rtfr); + rtfr.fetch(); + ret.push_back(RetrieveRequestDump()); + auto & retReq = ret.back(); + retReq.archiveFile = rtfr.getArchiveFile(); + retReq.remoteFile = rtfr.getRemoteFile(); + // Find the copy number from the list of jobs + retReq.activeCopyNb = rj->copynb(); + auto jl = rtfr.dumpJobs(); + for (auto j=jl.begin(); j!= jl.end(); j++) { + retReq.tapeCopies.push_back(TapeFileLocation()); + auto & retJob = retReq.tapeCopies.back(); + retJob.blockId = j->blockid; + retJob.copyNb = j->copyNb; + retJob.fSeq = j->fseq; + retJob.vid = j->tape; + } + } catch (cta::exception::Exception &) {} + } + return ret; +} + + bool cta::objectstore::Tape::isArchived() { checkPayloadReadable(); return m_payload.archived(); diff --git a/objectstore/Tape.hpp b/objectstore/Tape.hpp index f68bf4caff5df5bea56601e1c561ecf890ba01ad..04dc1e64b650a35bbd36189fd687822afad65b0d 100644 --- a/objectstore/Tape.hpp +++ b/objectstore/Tape.hpp @@ -21,6 +21,8 @@ #include "ObjectOps.hpp" #include "objectstore/cta.pb.h" #include "RetrieveToFileRequest.hpp" +#include "common/archiveNS/TapeFileLocation.hpp" +#include "scheduler/RetrieveRequestDump.hpp" namespace cta { namespace objectstore { @@ -32,12 +34,15 @@ class Tape: public ObjectOps<serializers::Tape> { public: Tape(const std::string & address, Backend & os); Tape(GenericObject & go); - void initialize(const std::string & vid, const std::string &logicalLibrary); + void initialize(const std::string & vid, const std::string &logicalLibrary, + const cta::CreationLog & creationLog); void garbageCollect(); bool isEmpty(); CTA_GENERATE_EXCEPTION_CLASS(NotEmpty); void removeIfEmpty(); std::string dump(); + cta::CreationLog getCreationLog(); + void setCreationLog(const cta::CreationLog & creationLog); // Tape location management ================================================== std::string getLogicalLibrary(); @@ -72,6 +77,7 @@ public: uint64_t priority; }; JobsSummary getJobsSummary(); + std::list<RetrieveRequestDump> dumpAndFetchRetrieveRequests(); // -- Stored data counting --------------------------------------------------- uint64_t getStoredData(); diff --git a/objectstore/TapePool.cpp b/objectstore/TapePool.cpp index cf8e2166ec85397aa85b61e082d36c6b09fb1fbc..46146da2c801d2a10e0a2c12a84973d999e7c399 100644 --- a/objectstore/TapePool.cpp +++ b/objectstore/TapePool.cpp @@ -90,7 +90,7 @@ std::string cta::objectstore::TapePool::addOrGetTapeAndCommit(const std::string& agent.commit(); // The create the tape object Tape t(tapeAddress, ObjectOps<serializers::TapePool>::m_objectStore); - t.initialize(vid, logicalLibraryName); + t.initialize(vid, logicalLibraryName, creationLog); t.setOwner(agent.getAddressIfSet()); t.setBackupOwner(getAddressIfSet()); t.insert(); @@ -141,6 +141,21 @@ void cta::objectstore::TapePool::removeTapeAndCommit(const std::string& vid) { } } +auto cta::objectstore::TapePool::dumpTapes() -> std::list<TapeBasicDump>{ + checkPayloadReadable(); + std::list<TapeBasicDump> ret; + auto & tl = m_payload.tapes(); + for (auto tp=tl.begin(); tp!=tl.end(); tp++) { + ret.push_back(TapeBasicDump()); + ret.back().address = tp->address(); + ret.back().vid = tp->vid(); + ret.back().capacityInBytes = tp->capacity(); + ret.back().logicalLibraryName = tp->library(); + ret.back().log.deserialize(tp->log()); + } + return ret; +} + auto cta::objectstore::TapePool::dumpTapesAndFetchStatus() -> std::list<TapeDump>{ checkPayloadReadable(); std::list<TapeDump> ret; diff --git a/objectstore/TapePool.hpp b/objectstore/TapePool.hpp index ddf6be1868b39e107e4b7f49ea92143d81cabbb9..dd438f291094e2038f1adbcbe1f74a844652d61b 100644 --- a/objectstore/TapePool.hpp +++ b/objectstore/TapePool.hpp @@ -56,6 +56,15 @@ public: CTA_GENERATE_EXCEPTION_CLASS(WrongTape); void removeTapeAndCommit(const std::string &vid); std::string getTapeAddress(const std::string &vid); + class TapeBasicDump { + public: + std::string vid; + std::string address; + std::string logicalLibraryName; + uint64_t capacityInBytes; + objectstore::CreationLog log; + }; + std::list<TapeBasicDump> dumpTapes(); class TapeDump { public: std::string vid; diff --git a/objectstore/TapeTest.cpp b/objectstore/TapeTest.cpp index 8e3d1e40fb15bc863cae8c15a53e38135047c9e7..334627fccd8549baa1815843095b0b88e554f5af 100644 --- a/objectstore/TapeTest.cpp +++ b/objectstore/TapeTest.cpp @@ -31,7 +31,8 @@ TEST(ObjectStore, TapeBasicAccess) { { // Try to create the tape entry cta::objectstore::Tape t(tapeAddress, be); - t.initialize("V12345", "LIB0"); + cta::CreationLog cl(cta::UserIdentity(123,456), "testHost", time(NULL), "Unit test"); + t.initialize("V12345", "LIB0", cl); t.insert(); } { diff --git a/objectstore/cta.proto b/objectstore/cta.proto index 1dd6a9b6567f1c014041476c7b684a6cb51cef87..afeb41b76612ec412a9fc83a72696e551ac407bf 100644 --- a/objectstore/cta.proto +++ b/objectstore/cta.proto @@ -189,6 +189,7 @@ message ArchiveJobPointer { message RetrieveJobPointer { required uint64 size = 3101; required string address = 3102; + required uint32 copynb = 3103; } // ------------- Mount criteria and quota ------------------------------------- @@ -259,6 +260,8 @@ message Tape { required bool disabled = 4314; required bool readonly = 4315; required bool full = 4316; + // Creation log + required CreationLog log = 4317; } // ------------- Archive Jobs -------------------------------------------------- @@ -331,9 +334,11 @@ message RetrieveJobEntry { required uint32 copynb = 4700; required string tape = 4701; required string tapeaddress = 4702; - required RetrieveJobStatus status = 4703; - required uint32 totalretries = 4704; - required uint32 retrieswithinmount = 4705; + required uint64 fseq = 4703; + required uint64 blockid = 4704; + required RetrieveJobStatus status = 4705; + required uint32 totalretries = 4706; + required uint32 retrieswithinmount = 4707; } message RetrieveToFileRequest { diff --git a/scheduler/CMakeLists.txt b/scheduler/CMakeLists.txt index 19dc28fe4526bea5d05a114bef0356d87a8ffef7..d01d930b11aa756b10d7b6a1dba9be697e1c1946 100644 --- a/scheduler/CMakeLists.txt +++ b/scheduler/CMakeLists.txt @@ -20,7 +20,6 @@ set (CTA_SCHEDULER_SRC_FILES MountType.cpp PositioningMethod.cpp RetrieveJob.cpp - RetrieveFromTapeCopyRequest.cpp RetrieveMount.cpp RetrieveRequest.cpp RetrieveToDirRequest.cpp diff --git a/scheduler/DummyScheduler.cpp b/scheduler/DummyScheduler.cpp index 8b68353cfa7378a294eb4577fed13060d5290ada..464c46469a7eece38e8cd638b39f196ca4b5199e 100644 --- a/scheduler/DummyScheduler.cpp +++ b/scheduler/DummyScheduler.cpp @@ -35,7 +35,7 @@ #include "scheduler/ArchiveToTapeCopyRequest.hpp" #include "scheduler/DummyScheduler.hpp" #include "scheduler/LogicalLibrary.hpp" -#include "scheduler/RetrieveFromTapeCopyRequest.hpp" +#include "scheduler/RetrieveRequestDump.hpp" #include "scheduler/RetrieveMount.hpp" #include "scheduler/RetrieveToDirRequest.hpp" #include "scheduler/RetrieveToFileRequest.hpp" @@ -85,18 +85,18 @@ void cta::DummyScheduler::deleteArchiveRequest( //------------------------------------------------------------------------------ // getRetrieveRequests //------------------------------------------------------------------------------ -std::map<cta::Tape, std::list<cta::RetrieveFromTapeCopyRequest> > cta:: +std::map<cta::Tape, std::list<cta::RetrieveRequestDump> > cta:: DummyScheduler::getRetrieveRequests(const SecurityIdentity &requester) const { - return std::map<cta::Tape, std::list<cta::RetrieveFromTapeCopyRequest> >(); + return std::map<cta::Tape, std::list<cta::RetrieveRequestDump> >(); } //------------------------------------------------------------------------------ // getRetrieveRequests //------------------------------------------------------------------------------ -std::list<cta::RetrieveFromTapeCopyRequest> cta::DummyScheduler::getRetrieveRequests( +std::list<cta::RetrieveRequestDump> cta::DummyScheduler::getRetrieveRequests( const SecurityIdentity &requester, const std::string &vid) const { - return std::list<cta::RetrieveFromTapeCopyRequest>(); + return std::list<cta::RetrieveRequestDump>(); } //------------------------------------------------------------------------------ diff --git a/scheduler/DummyScheduler.hpp b/scheduler/DummyScheduler.hpp index ca62036cc894a396ed7ca8267f895fc7f3ca28aa..9df2087ef3c59434f742305a08ad9650c30f7ca0 100644 --- a/scheduler/DummyScheduler.hpp +++ b/scheduler/DummyScheduler.hpp @@ -88,7 +88,7 @@ public: * @return all of the queued retrieve requests. The returned requsts are * grouped by tape and then sorted by creation time, oldest first. */ - std::map<Tape, std::list<RetrieveFromTapeCopyRequest> > getRetrieveRequests( + std::map<Tape, std::list<RetrieveRequestDump> > getRetrieveRequests( const SecurityIdentity &requester) const; /** @@ -100,7 +100,7 @@ public: * @return The queued retrieve requests for the specified tape. The * returned requests are sorted by creation time, oldest first. */ - std::list<RetrieveFromTapeCopyRequest> getRetrieveRequests( + std::list<RetrieveRequestDump> getRetrieveRequests( const SecurityIdentity &requester, const std::string &vid) const; diff --git a/scheduler/OStoreDB/OStoreDB.cpp b/scheduler/OStoreDB/OStoreDB.cpp index 8a1ac134842d41967763a10e1927272cca2ce742..aeb0fdf120feb4e3b9c6dd14481fd9778d4abe88 100644 --- a/scheduler/OStoreDB/OStoreDB.cpp +++ b/scheduler/OStoreDB/OStoreDB.cpp @@ -987,7 +987,7 @@ void OStoreDB::queue(const cta::RetrieveToFileRequest& rqst) { // Add all the tape copies to the request try { for (auto tc=rqst.getTapeCopies().begin(); tc!=rqst.getTapeCopies().end(); tc++) { - rtfr.addJob(tc->copyNb, tc->vid, vidToAddress.at(tc->vid)); + rtfr.addJob(*tc, vidToAddress.at(tc->vid)); } } catch (std::out_of_range &) { throw NoSuchTape("In OStoreDB::queue(RetrieveToFile): tape not found"); @@ -1054,12 +1054,46 @@ void OStoreDB::queue(const RetrieveToDirRequest& rqst) { } } -std::list<RetrieveFromTapeCopyRequest> OStoreDB::getRetrieveRequests(const std::string& vid) const { +std::list<RetrieveRequestDump> OStoreDB::getRetrieveRequests(const std::string& vid) const { throw exception::Exception("Not Implemented"); } -std::map<cta::Tape, std::list<RetrieveFromTapeCopyRequest> > OStoreDB::getRetrieveRequests() const { - throw exception::Exception("Not Implemented"); +std::map<cta::Tape, std::list<RetrieveRequestDump> > OStoreDB::getRetrieveRequests() const { + std::map<cta::Tape, std::list<RetrieveRequestDump> > ret; + // Get list of tape pools and then tapes + objectstore::RootEntry re(m_objectStore); + objectstore::ScopedSharedLock rel(re); + re.fetch(); + auto tpl=re.dumpTapePools(); + rel.release(); + for (auto tpp = tpl.begin(); tpp != tpl.end(); tpp++) { + // Get the list of tapes for the tape pool + objectstore::TapePool tp(tpp->address, m_objectStore); + objectstore::ScopedSharedLock tplock(tp); + tp.fetch(); + auto tl = tp.dumpTapes(); + for (auto tptr = tl.begin(); tptr!= tl.end(); tptr++) { + // Get the list of retrieve requests for the tape. + objectstore::Tape t(tptr->address, m_objectStore); + objectstore::ScopedSharedLock tlock(t); + t.fetch(); + auto jobs = t.dumpAndFetchRetrieveRequests(); + // If the list is not empty, add to the map. + if (jobs.size()) { + cta::Tape tkey; + // TODO tkey.capacityInBytes; + tkey.creationLog = t.getCreationLog(); + // TODO tkey.dataOnTapeInBytes; + tkey.logicalLibraryName = t.getLogicalLibrary(); + tkey.nbFiles = t.getLastFseq(); + // TODO tkey.status + tkey.tapePoolName = tp.getName(); + tkey.vid = t.getVid(); + ret[tkey] = std::move(jobs); + } + } + } + return ret; } void OStoreDB::deleteRetrieveRequest(const SecurityIdentity& requester, diff --git a/scheduler/OStoreDB/OStoreDB.hpp b/scheduler/OStoreDB/OStoreDB.hpp index 8c0e1bf716030f8461d59aac9360530f053f03e3..7d932f76a0adf2453bacd25cff2f9b23ffde5625 100644 --- a/scheduler/OStoreDB/OStoreDB.hpp +++ b/scheduler/OStoreDB/OStoreDB.hpp @@ -250,9 +250,9 @@ public: virtual void queue(const RetrieveToDirRequest& rqst); - virtual std::list<RetrieveFromTapeCopyRequest> getRetrieveRequests(const std::string& vid) const; + virtual std::list<RetrieveRequestDump> getRetrieveRequests(const std::string& vid) const; - virtual std::map<Tape, std::list<RetrieveFromTapeCopyRequest> > getRetrieveRequests() const; + virtual std::map<Tape, std::list<RetrieveRequestDump> > getRetrieveRequests() const; virtual void deleteRetrieveRequest(const SecurityIdentity& requester, const std::string& remoteFile); diff --git a/scheduler/OStoreDB/OStoreDBFactory.hpp b/scheduler/OStoreDB/OStoreDBFactory.hpp index 8b01c31cfe5617ed083b024a30ecda394e245573..21f07ef839e82d19a4f3b0d69a78f8153a5222a5 100644 --- a/scheduler/OStoreDB/OStoreDBFactory.hpp +++ b/scheduler/OStoreDB/OStoreDBFactory.hpp @@ -25,7 +25,7 @@ #include "common/archiveNS/Tape.hpp" #include "scheduler/LogicalLibrary.hpp" #include "scheduler/ArchiveToTapeCopyRequest.hpp" -#include "scheduler/RetrieveFromTapeCopyRequest.hpp" +#include "scheduler/RetrieveRequestDump.hpp" #include "objectstore/RootEntry.hpp" #include "objectstore/Agent.hpp" #include "objectstore/BackendVFS.hpp" @@ -183,11 +183,11 @@ public: return m_OStoreDB.getLogicalLibraries(); } - virtual std::map<Tape, std::list<RetrieveFromTapeCopyRequest> > getRetrieveRequests() const { + virtual std::map<Tape, std::list<RetrieveRequestDump> > getRetrieveRequests() const { return m_OStoreDB.getRetrieveRequests(); } - virtual std::list<RetrieveFromTapeCopyRequest> getRetrieveRequests(const std::string& vid) const { + virtual std::list<RetrieveRequestDump> getRetrieveRequests(const std::string& vid) const { return m_OStoreDB.getRetrieveRequests(vid); } diff --git a/scheduler/RetrieveFromTapeCopyRequest.cpp b/scheduler/RetrieveFromTapeCopyRequest.cpp deleted file mode 100644 index 72591a81c65ce731930c491852890662a53d7d1e..0000000000000000000000000000000000000000 --- a/scheduler/RetrieveFromTapeCopyRequest.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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/RetrieveFromTapeCopyRequest.hpp" -#include "common/archiveNS/TapeFileLocation.hpp" - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -cta::RetrieveFromTapeCopyRequest::RetrieveFromTapeCopyRequest() { -} - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -cta::RetrieveFromTapeCopyRequest::~RetrieveFromTapeCopyRequest() throw() { -} - -//------------------------------------------------------------------------------ -// constructor -//------------------------------------------------------------------------------ -cta::RetrieveFromTapeCopyRequest::RetrieveFromTapeCopyRequest( - const std::string &archiveFile, - const uint64_t copyNb, - const TapeFileLocation &tapeCopy, - const std::string &remoteFile, - const uint64_t priority, - const CreationLog & creationLog): - RetrieveRequest(priority, creationLog), - archiveFile(archiveFile), - copyNb(copyNb), - tapeCopy(tapeCopy), - remoteFile(remoteFile) { -} diff --git a/scheduler/RetrieveFromTapeCopyRequest.hpp b/scheduler/RetrieveFromTapeCopyRequest.hpp deleted file mode 100644 index 0fa1d47479b82b6cb9584de7804c77d276b3d907..0000000000000000000000000000000000000000 --- a/scheduler/RetrieveFromTapeCopyRequest.hpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 "scheduler/RetrieveRequest.hpp" -#include "common/archiveNS/TapeFileLocation.hpp" - -#include <list> -#include <string> - -namespace cta { - -/** - * Class representing a user request to retrieve a single tape copy of an - * archived file to a single remote file. - */ -struct RetrieveFromTapeCopyRequest: public RetrieveRequest { - - /** - * Constructor. - */ - RetrieveFromTapeCopyRequest(); - - /** - * Destructor. - */ - ~RetrieveFromTapeCopyRequest() throw(); - - /** - * Constructor. - * - * @param archiveFile The full path of the source archive file. - * @param copyNb The tape copy number. - * @param tapeCopy The location of the tape copy. - * @param remoteFile The URL of the destination remote file. - * @param priority The priority of the request. - * @param user The identity of the user who made the request. - * @param creationTime Optionally the absolute time at which the user request - * was created. If no value is given then the current time is used. - */ - RetrieveFromTapeCopyRequest( - const std::string &archiveFile, - const uint64_t copyNb, - const TapeFileLocation &tapeCopy, - const std::string &remoteFile, - const uint64_t priority, - const CreationLog &creationLog); - - /** - * The full path of the source archive file. - */ - std::string archiveFile; - - /** - * The tape copy number. - */ - uint64_t copyNb; - - /** - * The location of the copy on tape. - */ - TapeFileLocation tapeCopy; - - /** - * The URL of the destination remote file. - */ - std::string remoteFile; - -}; // struct RetrieveFromTapeCopyRequest - -} // namespace cta diff --git a/scheduler/RetrieveJobStatus.hpp b/scheduler/RetrieveJobStatus.hpp new file mode 100644 index 0000000000000000000000000000000000000000..935205f7a3aa3faee069663be962595bfdcb956a --- /dev/null +++ b/scheduler/RetrieveJobStatus.hpp @@ -0,0 +1,29 @@ +/* + * The CERN Tape Retrieve (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 + +namespace cta { + enum class RetrieveJobStatus { + LinkingToTape = 0, + Pending = 1, + Selected = 2, + Complete = 3, + Failed = 99 + }; +} diff --git a/scheduler/RetrieveRequestDump.hpp b/scheduler/RetrieveRequestDump.hpp new file mode 100644 index 0000000000000000000000000000000000000000..6bf6ba329f3ea4d9cc772b0ffc8805406693e9c4 --- /dev/null +++ b/scheduler/RetrieveRequestDump.hpp @@ -0,0 +1,42 @@ +/* + * 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 "common/archiveNS/TapeFileLocation.hpp" +#include "common/CreationLog.hpp" + +#include <list> +#include <string> + +namespace cta { + +/** + * Class representing a user request to retrieve a single archive file to a + * single remote file. + */ +struct RetrieveRequestDump { + uint64_t priority; /**< The priority of the request. */ + CreationLog creationLog; /**< The time at which the request was created. */ + std::string archiveFile; /**< he full path of the source archive file. */ + uint64_t activeCopyNb; /**< The tape copy number currenty considered for retrieve. */ + std::list<TapeFileLocation> tapeCopies; /**<The location of the copies on tape. */ + std::string remoteFile; /**< The URL of the destination remote file. */ +}; // struct RetrieveFromTapeCopyRequest + +} // namespace cta diff --git a/scheduler/Scheduler.cpp b/scheduler/Scheduler.cpp index e7ab15bc6c673d888ca6014d2e7dfc64c9fe4730..1880b0668fb7730cf3cf6c44dcd3ecd6a11dfda1 100644 --- a/scheduler/Scheduler.cpp +++ b/scheduler/Scheduler.cpp @@ -34,7 +34,7 @@ #include "scheduler/ArchiveToFileRequest.hpp" #include "scheduler/ArchiveToTapeCopyRequest.hpp" #include "scheduler/LogicalLibrary.hpp" -#include "scheduler/RetrieveFromTapeCopyRequest.hpp" +#include "scheduler/RetrieveRequestDump.hpp" #include "scheduler/RetrieveMount.hpp" #include "scheduler/RetrieveToDirRequest.hpp" #include "scheduler/RetrieveToFileRequest.hpp" @@ -113,7 +113,7 @@ void cta::Scheduler::deleteArchiveRequest( //------------------------------------------------------------------------------ // getRetrieveRequests //------------------------------------------------------------------------------ -std::map<cta::Tape, std::list<cta::RetrieveFromTapeCopyRequest> > cta:: +std::map<cta::Tape, std::list<cta::RetrieveRequestDump> > cta:: Scheduler::getRetrieveRequests(const SecurityIdentity &requester) const { return m_db.getRetrieveRequests(); } @@ -121,7 +121,7 @@ std::map<cta::Tape, std::list<cta::RetrieveFromTapeCopyRequest> > cta:: //------------------------------------------------------------------------------ // getRetrieveRequests //------------------------------------------------------------------------------ -std::list<cta::RetrieveFromTapeCopyRequest> cta::Scheduler::getRetrieveRequests( +std::list<cta::RetrieveRequestDump> cta::Scheduler::getRetrieveRequests( const SecurityIdentity &requester, const std::string &vid) const { return m_db.getRetrieveRequests(vid); diff --git a/scheduler/Scheduler.hpp b/scheduler/Scheduler.hpp index 4747e8b3861be1f7beffae254fbe25012d3b533a..13467d6adb00db1f7b3cc02aa7e932c7b951b73d 100644 --- a/scheduler/Scheduler.hpp +++ b/scheduler/Scheduler.hpp @@ -42,7 +42,7 @@ class LogicalLibrary; class NameServer; class RemoteNS; class RemotePathAndStatus; -class RetrieveFromTapeCopyRequest; +class RetrieveRequestDump; class RetrieveToDirRequest; class RetrieveToFileRequest; class SchedulerDatabase; @@ -138,7 +138,7 @@ public: * @return all of the queued retrieve requests. The returned requsts are * grouped by tape and then sorted by creation time, oldest first. */ - virtual std::map<Tape, std::list<RetrieveFromTapeCopyRequest> > + virtual std::map<Tape, std::list<RetrieveRequestDump> > getRetrieveRequests(const SecurityIdentity &requester) const; /** @@ -150,7 +150,7 @@ public: * @return The queued retrieve requests for the specified tape. The * returned requests are sorted by creation time, oldest first. */ - virtual std::list<RetrieveFromTapeCopyRequest> getRetrieveRequests( + virtual std::list<RetrieveRequestDump> getRetrieveRequests( const SecurityIdentity &requester, const std::string &vid) const; diff --git a/scheduler/SchedulerDatabase.hpp b/scheduler/SchedulerDatabase.hpp index 5e5d586e8891c6550a823d70c872299d13e6ba4c..efae9930a24c34712552f8597ea999ffe5433d70 100644 --- a/scheduler/SchedulerDatabase.hpp +++ b/scheduler/SchedulerDatabase.hpp @@ -47,7 +47,7 @@ class ArchiveToTapeCopyRequest; class CreationLog; class DirIterator; class LogicalLibrary; -class RetrieveFromTapeCopyRequest; +class RetrieveRequestDump; class RetrieveToDirRequest; class RetrieveToFileRequest; class SecurityIdentity; @@ -209,7 +209,7 @@ public: * @return All of the existing retrieve jobs grouped by tape and then * sorted by creation time in ascending order (oldest first). */ - virtual std::map<Tape, std::list<RetrieveFromTapeCopyRequest> > getRetrieveRequests() + virtual std::map<Tape, std::list<RetrieveRequestDump> > getRetrieveRequests() const = 0; /** @@ -220,7 +220,7 @@ public: * @return The list of retrieve jobs associated with the specified tape * sorted by creation time in ascending order (oldest first). */ - virtual std::list<RetrieveFromTapeCopyRequest> getRetrieveRequests( + virtual std::list<RetrieveRequestDump> getRetrieveRequests( const std::string &vid) const = 0; /** diff --git a/scheduler/SchedulerTest.cpp b/scheduler/SchedulerTest.cpp index ec556ea6792bbd07f8f89496d8ee7a21def45323..0473751b58fca58628c3fd176fcddfb2aa8ef68b 100644 --- a/scheduler/SchedulerTest.cpp +++ b/scheduler/SchedulerTest.cpp @@ -2458,7 +2458,7 @@ TEST_P(SchedulerTest, archive_and_retrieve_new_file) { { decltype(scheduler.getRetrieveRequests(s_userOnUserHost)) rqsts; - ASSERT_NO_THROW(rqsts = scheduler.getRetrieveRequests(s_userOnUserHost)); + /*ASSERT_NO_THROW*/(rqsts = scheduler.getRetrieveRequests(s_userOnUserHost)); ASSERT_EQ(1, rqsts.size()); auto tapeItor = rqsts.cbegin(); ASSERT_FALSE(tapeItor == rqsts.cend()); @@ -2469,7 +2469,7 @@ TEST_P(SchedulerTest, archive_and_retrieve_new_file) { std::set<std::string> remoteFiles; std::set<std::string> archiveFiles; for(auto rqstItor = tapeRqsts.cbegin(); rqstItor != tapeRqsts.cend(); - tapeItor++) { + rqstItor++) { remoteFiles.insert(rqstItor->remoteFile); archiveFiles.insert(rqstItor->archiveFile); } diff --git a/scheduler/mockDB/MockSchedulerDatabase.cpp b/scheduler/mockDB/MockSchedulerDatabase.cpp index 6b3b6d064def4c316dfc3af1c4f0ba1bb81c0f03..984553a1a66c3c4343fb5f20056c8dc34e1d01df 100644 --- a/scheduler/mockDB/MockSchedulerDatabase.cpp +++ b/scheduler/mockDB/MockSchedulerDatabase.cpp @@ -28,7 +28,7 @@ #include "common/archiveRoutes/ArchiveRoute.hpp" #include "scheduler/LogicalLibrary.hpp" #include "scheduler/mockDB/MockSchedulerDatabase.hpp" -#include "scheduler/RetrieveFromTapeCopyRequest.hpp" +#include "scheduler/RetrieveRequestDump.hpp" #include "scheduler/RetrieveToFileRequest.hpp" #include "common/SecurityIdentity.hpp" #include "scheduler/mockDB/SqliteColumnNameToIndex.hpp" diff --git a/xroot_plugins/XrdProFile.cpp b/xroot_plugins/XrdProFile.cpp index 17b628746e4e62f16e709c45a832f427bc9e3904..3c43692ffae02bf6880c0a440342a664c86d706c 100644 --- a/xroot_plugins/XrdProFile.cpp +++ b/xroot_plugins/XrdProFile.cpp @@ -30,7 +30,7 @@ #include "scheduler/ArchiveToTapeCopyRequest.hpp" #include "scheduler/LogicalLibrary.hpp" //#include "scheduler/mockDB/MockSchedulerDatabase.hpp" -#include "scheduler/RetrieveFromTapeCopyRequest.hpp" +#include "scheduler/RetrieveRequestDump.hpp" #include "scheduler/SchedulerDatabase.hpp" #include "xroot_plugins/XrdProFile.hpp" @@ -980,13 +980,19 @@ void XrdProFile::xCom_listpendingretrieves(const std::vector<std::string> &token auto vidList = m_scheduler->getRetrieveRequests(requester); for(auto vid = vidList.begin(); vid != vidList.end(); vid++) { for(auto request = vid->second.begin(); request!=vid->second.end(); request++) { + // Find the tape copy for the active copy number + cta::TapeFileLocation * tfl = NULL; + for (auto l=request->tapeCopies.begin(); l!=request->tapeCopies.end(); l++) { + if (l->copyNb == request->activeCopyNb) + tfl = &(*l); + } responseSS << vid->first.vid << " " << request->archiveFile << " " << request->remoteFile - << " " << request->copyNb - << " " << request->tapeCopy.vid - << " " << request->tapeCopy.blockId - << " " << request->tapeCopy.fSeq + << " " << request->activeCopyNb + << " " << (tfl?tfl->vid:"Unknown VID") + << " " << (tfl?tfl->blockId:0) + << " " << (tfl?tfl->fSeq:0) << " " << request->priority << " " << request->creationLog.user.uid << " " << request->creationLog.user.gid @@ -999,13 +1005,19 @@ void XrdProFile::xCom_listpendingretrieves(const std::vector<std::string> &token else { auto requestList = m_scheduler->getRetrieveRequests(requester, tapeVid); for(auto request = requestList.begin(); request!=requestList.end(); request++) { + // Find the tape copy for the active copy number + cta::TapeFileLocation * tfl = NULL; + for (auto l=request->tapeCopies.begin(); l!=request->tapeCopies.end(); l++) { + if (l->copyNb == request->activeCopyNb) + tfl = &(*l); + } responseSS << tapeVid << " " << request->archiveFile << " " << request->remoteFile - << " " << request->copyNb - << " " << request->tapeCopy.vid - << " " << request->tapeCopy.blockId - << " " << request->tapeCopy.fSeq + << " " << request->activeCopyNb + << " " << (tfl?tfl->vid:"Unknown VID") + << " " << (tfl?tfl->blockId:0) + << " " << (tfl?tfl->fSeq:0) << " " << request->priority << " " << request->creationLog.user.uid << " " << request->creationLog.user.gid diff --git a/xroot_plugins/XrdProFilesystem.cpp b/xroot_plugins/XrdProFilesystem.cpp index cf521d7b6119189437e6bfa4c4e400f3b606cba4..a91efc9f2e66bff5abb27462dcc53e99ad0a79df 100644 --- a/xroot_plugins/XrdProFilesystem.cpp +++ b/xroot_plugins/XrdProFilesystem.cpp @@ -29,7 +29,7 @@ #include "scheduler/LogicalLibrary.hpp" #include "scheduler/OStoreDB/OStoreDB.hpp" //#include "scheduler/mockDB/MockSchedulerDatabase.hpp" -#include "scheduler/RetrieveFromTapeCopyRequest.hpp" +#include "scheduler/RetrieveRequestDump.hpp" #include "common/archiveNS/StorageClass.hpp" #include "scheduler/SchedulerDatabase.hpp" #include "common/archiveNS/StorageClass.hpp"