diff --git a/objectstore/ArchiveToFileRequest.cpp b/objectstore/ArchiveToFileRequest.cpp index 658acc98df11d5665a3c9b060b77c66b538a277d..fad961799b344784d6e8d7c5b7f5fa9e13686ab8 100644 --- a/objectstore/ArchiveToFileRequest.cpp +++ b/objectstore/ArchiveToFileRequest.cpp @@ -57,23 +57,42 @@ void cta::objectstore::ArchiveToFileRequest::setArchiveFile( m_payload.set_archivefile(archiveFile); } +std::string cta::objectstore::ArchiveToFileRequest::getArchiveFile() { + checkPayloadReadable(); + return m_payload.archivefile(); +} + + void cta::objectstore::ArchiveToFileRequest::setRemoteFile( const std::string& remoteFile) { - checkHeaderReadable(); + checkPayloadWritable(); m_payload.set_remotefile(remoteFile); } +std::string cta::objectstore::ArchiveToFileRequest::getRemoteFile() { + checkPayloadReadable(); + return m_payload.remotefile(); +} + + void cta::objectstore::ArchiveToFileRequest::setPriority(uint64_t priority) { checkPayloadWritable(); m_payload.set_priority(priority); } -void cta::objectstore::ArchiveToFileRequest::setLog( +void cta::objectstore::ArchiveToFileRequest::setCreationLog( const objectstore::CreationLog& creationLog) { - checkPayloadReadable(); + checkPayloadWritable(); creationLog.serialize(*m_payload.mutable_log()); } +auto cta::objectstore::ArchiveToFileRequest::getCreationLog() -> CreationLog { + checkPayloadReadable(); + CreationLog ret; + ret.deserialize(m_payload.log()); + return ret; +} + void cta::objectstore::ArchiveToFileRequest::setArchiveToDirRequestAddress( const std::string& dirRequestAddress) { checkPayloadWritable(); @@ -94,7 +113,7 @@ auto cta::objectstore::ArchiveToFileRequest::dumpJobs() -> std::list<JobDump> { } uint64_t cta::objectstore::ArchiveToFileRequest::getSize() { - checkPayloadWritable(); + checkPayloadReadable(); return m_payload.size(); } @@ -104,4 +123,3 @@ void cta::objectstore::ArchiveToFileRequest::setSize(uint64_t size) { } - diff --git a/objectstore/ArchiveToFileRequest.hpp b/objectstore/ArchiveToFileRequest.hpp index b9d87b09ebb5ed112159b70ae5a4c361a4514931..f34b647b1226bfef359a574a4af85ff61c7a341e 100644 --- a/objectstore/ArchiveToFileRequest.hpp +++ b/objectstore/ArchiveToFileRequest.hpp @@ -41,7 +41,8 @@ public: void setRemoteFile (const std::string & remoteFile); std::string getRemoteFile(); void setPriority (uint64_t priority); - void setLog (const objectstore::CreationLog& creationLog); + void setCreationLog (const objectstore::CreationLog& creationLog); + CreationLog getCreationLog(); void setArchiveToDirRequestAddress(const std::string & dirRequestAddress); void setSize(uint64_t size); uint64_t getSize(); diff --git a/objectstore/ArchiveToFileRequestTest.cpp b/objectstore/ArchiveToFileRequestTest.cpp index 917152591333dc1164d5b3465dec2dc8db36cb5b..020ba84184b65a28472ce88a4645002ccf4701c4 100644 --- a/objectstore/ArchiveToFileRequestTest.cpp +++ b/objectstore/ArchiveToFileRequestTest.cpp @@ -20,6 +20,8 @@ #include "ArchiveToFileRequest.hpp" #include "BackendVFS.hpp" #include "Agent.hpp" +#include "CreationLog.hpp" +#include "UserIdentity.hpp" namespace unitTests { @@ -27,6 +29,7 @@ TEST(ObjectStore, ArchiveToFileRequestBasicAccess) { cta::objectstore::BackendVFS be; cta::objectstore::Agent agent(be); agent.generateName("unitTest"); + time_t now; std::string tapeAddress = agent.nextId("ArchiveToFileRequest"); { // Try to create the ArchiveToFileRequest entry @@ -35,8 +38,8 @@ TEST(ObjectStore, ArchiveToFileRequestBasicAccess) { atfr.setArchiveFile("cta://dir/file"); atfr.setRemoteFile("eos://dir2/file2"); atfr.setSize(12345678); - atfr.setLog(cta::CreationLog(cta::UserIdentity(123,456),"testHost", - time(NULL), "Comment")); + atfr.setCreationLog(cta::CreationLog(cta::UserIdentity(123,456),"testHost", + now=time(NULL), "Comment")); atfr.setPriority(12); atfr.insert(); } @@ -45,7 +48,15 @@ TEST(ObjectStore, ArchiveToFileRequestBasicAccess) { cta::objectstore::ArchiveToFileRequest atfr(tapeAddress, be); cta::objectstore::ScopedSharedLock atfrl(atfr); atfr.fetch(); - ASSERT_EQ("cta://dir/file", atfr.getARchiveFile()); + ASSERT_EQ("cta://dir/file", atfr.getArchiveFile()); + ASSERT_EQ("eos://dir2/file2", atfr.getRemoteFile()); + ASSERT_EQ(12345678, atfr.getSize()); + cta::objectstore::CreationLog log(atfr.getCreationLog()); + ASSERT_EQ(123, log.user.uid); + ASSERT_EQ(456, log.user.gid); + ASSERT_EQ("testHost", log.host); + ASSERT_EQ(now, log.time); + ASSERT_EQ("Comment", log.comment); } } diff --git a/objectstore/CMakeLists.txt b/objectstore/CMakeLists.txt index 730907f39997f9c7d12913a813b90f59fdd48ef5..36447ff61b3931e5a9e15b976d170f6e9d914285 100644 --- a/objectstore/CMakeLists.txt +++ b/objectstore/CMakeLists.txt @@ -34,6 +34,7 @@ set(ObjectStoreUnitTests RootEntryTest.cpp TapeTest.cpp GarbageCollectorTest.cpp + ArchiveToFileRequestTest.cpp ) add_library(ctaobjectstoreunittests SHARED ${ObjectStoreUnitTests}) diff --git a/scheduler/OStoreDB/OStoreDB.cpp b/scheduler/OStoreDB/OStoreDB.cpp index 989ba487e1b4551fd980232f4851c819da1898a3..1dcf24f11ea3caa66311201322717d1b0bce82b3 100644 --- a/scheduler/OStoreDB/OStoreDB.cpp +++ b/scheduler/OStoreDB/OStoreDB.cpp @@ -409,7 +409,7 @@ void OStoreDB::queue(const cta::ArchiveToFileRequest& rqst) { atfr.setArchiveFile(rqst.getArchiveFile()); atfr.setRemoteFile(rqst.getRemoteFile()); atfr.setPriority(rqst.getPriority()); - atfr.setLog(rqst.getCreationLog()); + atfr.setCreationLog(rqst.getCreationLog()); // We will need to identity tapepools is order to construct the request RootEntry re(m_objectStore); ScopedSharedLock rel(re);