diff --git a/common/Utils.cpp b/common/Utils.cpp index 83c0fc7a4804d297faaff6ef684b58fd4d41fc8b..0f85bbb3e89b61c4d2a01e43cd9b8957782ac3ab 100644 --- a/common/Utils.cpp +++ b/common/Utils.cpp @@ -84,18 +84,18 @@ static void assertPathContainsValidChars(const std::string &path) { //------------------------------------------------------------------------------ // assertPathDoesContainConsecutiveSlashes //------------------------------------------------------------------------------ -static void assertPathDoesContainConsecutiveSlashes(const std::string &path) { - char previousChar = '\0'; - - for(std::string::const_iterator itor = path.begin(); itor != path.end(); - itor++) { - const char ¤tChar = *itor; - if(previousChar == '/' && currentChar == '/') { - throw Exception("Path contains consecutive slashes"); - } - previousChar = currentChar; - } -} +//static void assertPathDoesContainConsecutiveSlashes(const std::string &path) { +// char previousChar = '\0'; +// +// for(std::string::const_iterator itor = path.begin(); itor != path.end(); +// itor++) { +// const char ¤tChar = *itor; +// if(previousChar == '/' && currentChar == '/') { +// throw Exception("Path contains consecutive slashes"); +// } +// previousChar = currentChar; +// } +//} //------------------------------------------------------------------------------ // assertAbsolutePathSyntax @@ -104,7 +104,7 @@ void cta::Utils::assertAbsolutePathSyntax(const std::string &path) { try { assertPathStartsWithASlash(path); assertPathContainsValidChars(path); - assertPathDoesContainConsecutiveSlashes(path); + //assertPathDoesContainConsecutiveSlashes(path); } catch(std::exception &ex) { std::ostringstream message; message << "Absolute path \"" << path << "\" contains a syntax error: " << diff --git a/nameserver/mockNS/MockNameServer.cpp b/nameserver/mockNS/MockNameServer.cpp index 1afe2f55cc1a97a41c8c57e08a04cd7a244343c2..16155c08855b77d2aee057add8391e198b2f1405 100644 --- a/nameserver/mockNS/MockNameServer.cpp +++ b/nameserver/mockNS/MockNameServer.cpp @@ -366,7 +366,7 @@ void cta::MockNameServer::createFile( const std::string fsPath = m_fsDir + path; assertFsPathDoesNotExist(fsPath); - SmartFd fd(open(fsPath.c_str(), O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, mode)); + SmartFd fd(open(fsPath.c_str(), O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0600)); if(0 > fd.get()) { const int savedErrno = errno; std::ostringstream msg; @@ -393,6 +393,9 @@ void cta::MockNameServer::createFile( std::stringstream fileIDString; fileIDString << ++m_fileIdCounter; Utils::setXattr(fsPath.c_str(), "user.CTAFileID", fileIDString.str()); + std::stringstream modeString; + modeString << std::oct << mode; + Utils::setXattr(fsPath.c_str(), "user.CTAMode", modeString.str()); } //------------------------------------------------------------------------------ diff --git a/remotens/CMakeLists.txt b/remotens/CMakeLists.txt index 4f527352d80506cd6f563252ced73f68cdd5b2e8..b527a78db39aee64e88392a93a67f0ee9fbeb374 100644 --- a/remotens/CMakeLists.txt +++ b/remotens/CMakeLists.txt @@ -16,7 +16,7 @@ target_link_libraries (ctaremotens ${XROOTD_XRDCL_LIB} ctacommon cryptopp) add_library (ctaremotensunittests SHARED MockRemoteNS.cpp - MockRemoteNSFactory.cpp + MockRemoteFullFS.cpp MockRemoteNSTest.cpp RemoteNSDispatcherTest.cpp RemoteNSFactory.cpp) diff --git a/remotens/MockRemoteNSFactory.cpp b/remotens/MockRemoteNSFactory.cpp deleted file mode 100644 index 916419930eca9a780c790a8caa8cfb8cf8829dfa..0000000000000000000000000000000000000000 --- a/remotens/MockRemoteNSFactory.cpp +++ /dev/null @@ -1,33 +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 "remotens/MockRemoteNS.hpp" -#include "remotens/MockRemoteNSFactory.hpp" - -//------------------------------------------------------------------------------ -// destructor -//------------------------------------------------------------------------------ -cta::MockRemoteNSFactory::~MockRemoteNSFactory() throw() { -} - -//------------------------------------------------------------------------------ -// create -//------------------------------------------------------------------------------ -std::unique_ptr<cta::RemoteNS> cta::MockRemoteNSFactory::create() { - return std::unique_ptr<RemoteNS>(new MockRemoteNS()); -} diff --git a/remotens/MockRemoteNSFactory.hpp b/remotens/MockRemoteNSFactory.hpp deleted file mode 100644 index c27caefaff5579a561f0d8067ee5f016cf33a8ef..0000000000000000000000000000000000000000 --- a/remotens/MockRemoteNSFactory.hpp +++ /dev/null @@ -1,45 +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 "remotens/RemoteNSFactory.hpp" - -namespace cta { - -/** - * Factory for creating mock remote namespaces. - */ -class MockRemoteNSFactory: public RemoteNSFactory { -public: - - /** - * Destructor. - */ - ~MockRemoteNSFactory() throw(); - - /** - * Returns a newly created namespace object. - * - * @return A newly created namespace object. - */ - std::unique_ptr<RemoteNS> create(); - -}; // class MockRemoteNSFactory - -} // namespace cta diff --git a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp index bc5dc8973257fd9507ad9be06081a696066c54a6..6428598f7a0054de29b8aaa6aa07e2f92a93daf6 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/DataTransferSessionTest.cpp @@ -47,6 +47,7 @@ #include "smc_struct.h" #include "nameserver/mockNS/MockNameServer.hpp" #include "remotens/MockRemoteNS.hpp" +#include "remotens/MockRemoteFullFS.hpp" #include "scheduler/DummyScheduler.hpp" #include "scheduler/OStoreDB/OStoreDBFactory.hpp" #include "scheduler/MountType.hpp" @@ -830,7 +831,7 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio // 4) Create the scheduler cta::MockNameServer ns; - cta::MockRemoteNS rns; + cta::MockRemoteFullFS rns; cta::OStoreDBWrapper<cta::objectstore::BackendVFS> db("Unittest"); cta::Scheduler scheduler(ns, db, rns); @@ -883,22 +884,21 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio mockSys.fake.m_pathToDrive["/dev/nst0"]->rewind(); // schedule the archivals - for(int fseq=1; fseq <= 10 ; fseq ++) { + for(int fseq=1; fseq <= 10 ; fseq ++) { // Create a path to a remote source file - std::ostringstream remoteFilePath; + std::ostringstream fileName; // remoteFilePath << "file:" << "/test" << fseq; - remoteFilePath << "file:" << "/test" << fseq; - remoteFilePaths.push_back(remoteFilePath.str()); + fileName << "/test" << fseq; + remoteFilePaths.push_back(fileName.str()); - // Create the entry in the remote namespace (same user id of the requester) - cta::RemotePath rpath(remoteFilePath.str()); - cta::RemoteFileStatus rstatus(requester.getUser(), 0777, 1000); - rns.createEntry(rpath, rstatus); + // Create the file to be migrated in the fake remote NS + cta::RemotePath rpath(rns.createFullURL(fileName.str())); + rns.createFile(rpath.getRaw(), 1000); // Schedule the archival of the file std::list<std::string> remoteFilePathList; - remoteFilePathList.push_back(remoteFilePath.str()); - ASSERT_NO_THROW(scheduler.queueArchiveRequest(requester, remoteFilePathList, rpath.getAfterScheme())); + remoteFilePathList.push_back(rns.createFullURL(fileName.str())); + ASSERT_NO_THROW(scheduler.queueArchiveRequest(requester, remoteFilePathList, fileName.str())); } } DriveConfig driveConfig("T10D6116", "T10KD6", "/dev/tape_T10D6116", "manual"); @@ -920,9 +920,8 @@ TEST_F(castor_tape_tapeserver_daemon_DataTransferSessionTest, DataTransferSessio temp += ""; ASSERT_EQ("V12345", sess.getVid()); for(auto i=remoteFilePaths.begin(); i!=remoteFilePaths.end(); i++) { - cta::RemotePath rpath(*i); - ASSERT_NO_THROW(ns.statFile(requester, rpath.getAfterScheme())); - std::unique_ptr<cta::ArchiveFileStatus> stat(ns.statFile(requester, rpath.getAfterScheme())); + /*ASSERT_NO_THROW*/(ns.statFile(requester, *i)); + std::unique_ptr<cta::ArchiveFileStatus> stat(ns.statFile(requester, *i)); ASSERT_NE((uint64_t)(stat.get()), NULL); ASSERT_EQ(stat->mode, 0777); ASSERT_EQ(stat->size, 1000); diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp index f411b91c12431092c08ab59ce5f732578bafb80b..2e7104cbfa4c6b28c7188def71d6681bb85ec45d 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp @@ -46,8 +46,10 @@ namespace daemon { //------------------------------------------------------------------------------ TapeWriteTask::TapeWriteTask(int blockCount, cta::ArchiveJob *archiveJob, MigrationMemoryManager& mm,castor::server::AtomicFlag& errorFlag): - m_archiveJob(archiveJob),m_memManager(mm), m_fifo(blockCount), - m_blockCount(blockCount),m_errorFlag(errorFlag) + m_archiveJob(archiveJob),m_memManager(mm), m_fifo(blockCount), + m_blockCount(blockCount),m_errorFlag(errorFlag), + m_archiveFile(m_archiveJob->archiveFile), m_nameServerTapeFile(m_archiveJob->nameServerTapeFile), + m_remotePathAndStatus(m_archiveJob->remotePathAndStatus) { //register its fifo to the memory manager as a client in order to get mem block mm.addClient(&m_fifo); @@ -56,7 +58,7 @@ namespace daemon { // fileSize //------------------------------------------------------------------------------ uint64_t TapeWriteTask::fileSize() { - return m_archiveJob->archiveFile.size; + return m_archiveFile.size; } //------------------------------------------------------------------------------ // execute @@ -317,12 +319,12 @@ namespace daemon { /1000/1000/m_taskStats.totalTime:0.0) .add("payloadTransferSpeedMBps",m_taskStats.totalTime? 1.0*m_taskStats.dataVolume/1000/1000/m_taskStats.totalTime:0.0) - .add("fileSize",m_archiveJob->archiveFile.size) - .add("NSHOST",m_archiveJob->archiveFile.nsHostName) - .add("NSFILEID",m_archiveJob->archiveFile.fileId) - .add("fSeq",m_archiveJob->nameServerTapeFile.tapeFileLocation.fSeq) - .add("lastKnownFilename",m_archiveJob->archiveFile.path) - .add("lastModificationTime",m_archiveJob->archiveFile.lastModificationTime); + .add("fileSize",m_archiveFile.size) + .add("NSHOST",m_archiveFile.nsHostName) + .add("NSFILEID",m_archiveFile.fileId) + .add("fSeq",m_nameServerTapeFile.tapeFileLocation.fSeq) + .add("lastKnownFilename",m_archiveFile.path) + .add("lastModificationTime",m_archiveFile.lastModificationTime); lc.log(level, msg); diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.hpp b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.hpp index 5352dfc05c2694e8c10b790c5cb59bb4038d2641..6669bde6684109478e6c68194c3413393bc55d6a 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.hpp @@ -173,6 +173,22 @@ private: * Stats */ TapeSessionStats m_taskStats; + + /** + * The NS archive file information + */ + cta::ArchiveFile m_archiveFile; + + /** + * The file archive result for the NS + */ + cta::NameServerTapeFile m_nameServerTapeFile; + + /** + * The remote file information + */ + cta::RemotePathAndStatus m_remotePathAndStatus; + }; }}}}