Commit 76914527 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

Trying to archive files for the first time: fixing bugs and adding missing information

parent f20b955b
......@@ -59,6 +59,13 @@ std::string cta::ArchiveMount::getPoolName() const {
return m_dbMount->mountInfo.tapePool;
}
//------------------------------------------------------------------------------
// getNbFiles
//------------------------------------------------------------------------------
uint32_t cta::ArchiveMount::getNbFiles() const {
return m_dbMount->nbFilesCurrentlyOnTape;
}
//------------------------------------------------------------------------------
// getMountTransactionId
//------------------------------------------------------------------------------
......
......@@ -101,6 +101,13 @@ namespace cta {
*/
virtual std::string getPoolName() const;
/**
* Returns the mount transaction id.
*
* @return The mount transaction id.
*/
virtual uint32_t getNbFiles() const;
/**
* Destructor.
*/
......
......@@ -1203,7 +1203,7 @@ std::unique_ptr<SchedulerDatabase::ArchiveMount>
m_agent.addToOwnership(t.getAddressIfSet());
m_agent.commit();
}
am.m_nextFseq = t.getLastFseq() + 1;
am.nbFilesCurrentlyOnTape = t.getLastFseq();
am.mountInfo.vid = t.getVid();
t.setBusy(driveName, objectstore::Tape::MountType::Archive, hostName, startTime,
m_agent.getAddressIfSet());
......@@ -1416,7 +1416,7 @@ auto OStoreDB::ArchiveMount::getNextJob() -> std::unique_ptr<SchedulerDatabase::
tp.commit();
privateRet->archiveFile = privateRet->m_atfr.getArchiveFile();
privateRet->remoteFile = privateRet->m_atfr.getRemoteFile();
privateRet->nameServerTapeFile.tapeFileLocation.fSeq = m_nextFseq++;
privateRet->nameServerTapeFile.tapeFileLocation.fSeq = ++nbFilesCurrentlyOnTape;
privateRet->nameServerTapeFile.tapeFileLocation.copyNb = privateRet->m_copyNb;
privateRet->nameServerTapeFile.tapeFileLocation.vid = mountInfo.vid;
privateRet->nameServerTapeFile.tapeFileLocation.blockId =
......
......@@ -80,7 +80,6 @@ public:
ArchiveMount(objectstore::Backend &, objectstore::Agent &);
objectstore::Backend & m_objectStore;
objectstore::Agent & m_agent;
uint64_t m_nextFseq;
public:
virtual const MountInfo & getMountInfo();
virtual std::unique_ptr<ArchiveJob> getNextJob();
......
......@@ -40,6 +40,13 @@ cta::MountType::Enum cta::RetrieveMount::getMountType() const{
return MountType::RETRIEVE;
}
//------------------------------------------------------------------------------
// getNbFiles
//------------------------------------------------------------------------------
uint32_t cta::RetrieveMount::getNbFiles() const {
return m_dbMount->nbFilesCurrentlyOnTape;
}
//------------------------------------------------------------------------------
// getVid
//------------------------------------------------------------------------------
......
......@@ -73,6 +73,13 @@ namespace cta {
* @return The mount transaction id.
*/
virtual std::string getMountTransactionId() const;
/**
* Returns the mount transaction id.
*
* @return The mount transaction id.
*/
virtual uint32_t getNbFiles() const;
/**
* Indicates that the mount was completed.
......
......@@ -172,6 +172,7 @@ public:
virtual std::unique_ptr<ArchiveJob> getNextJob() = 0;
virtual void complete(time_t completionTime) = 0;
virtual ~ArchiveMount() {}
uint32_t nbFilesCurrentlyOnTape;
};
/**
......@@ -250,6 +251,7 @@ public:
virtual std::unique_ptr<RetrieveJob> getNextJob() = 0;
virtual void complete(time_t completionTime) = 0;
virtual ~RetrieveMount() {}
uint32_t nbFilesCurrentlyOnTape;
};
class RetrieveJob {
......
......@@ -49,7 +49,14 @@ namespace cta {
*
* @return The mount transaction id.
*/
virtual std::string getMountTransactionId() const = 0;
virtual std::string getMountTransactionId() const = 0;
/**
* Returns the mount transaction id.
*
* @return The mount transaction id.
*/
virtual uint32_t getNbFiles() const = 0;
/**
* Indicates that the mount was completed.
......
......@@ -20,4 +20,5 @@ package castor.messages;
message ArchiveJobFromCTA {
required string vid = 1;
required string unitname = 2;
required uint32 nbfiles = 3;
}
......@@ -84,7 +84,7 @@ public:
* @return The number of files currently stored on the tape
*/
virtual uint32_t gotArchiveJobFromCTA(const std::string &vid,
const std::string &unitName) = 0;
const std::string &unitName, const uint32_t nbFiles) = 0;
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
......
......@@ -25,7 +25,7 @@
// gotArchiveJobFromCTA
//------------------------------------------------------------------------------
uint32_t castor::messages::TapeserverProxyDummy::gotArchiveJobFromCTA(
const std::string &vid, const std::string &unitName) {
const std::string &vid, const std::string &unitName, const uint32_t nbFiles) {
return 0;
}
......
......@@ -41,7 +41,7 @@ public:
* @return The number of files currently stored on the tape
*/
virtual uint32_t gotArchiveJobFromCTA(const std::string &vid,
const std::string &unitName);
const std::string &unitName, const uint32_t nbFiles);
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
......
......@@ -56,11 +56,11 @@ castor::messages::TapeserverProxyZmq::TapeserverProxyZmq(log::Logger &log,
// gotArchiveJobFromCTA
//------------------------------------------------------------------------------
uint32_t castor::messages::TapeserverProxyZmq::gotArchiveJobFromCTA(
const std::string &vid, const std::string &unitName) {
const std::string &vid, const std::string &unitName, const uint32_t nbFiles) {
MutexLocker lock(&m_mutex);
try {
const Frame rqst = createArchiveJobFromCTAFrame(vid, unitName);
const Frame rqst = createArchiveJobFromCTAFrame(vid, unitName, nbFiles);
sendFrame(m_serverSocket, rqst);
NbFilesOnTape reply;
......@@ -303,7 +303,7 @@ castor::messages::Frame castor::messages::TapeserverProxyZmq::
//------------------------------------------------------------------------------
castor::messages::Frame castor::messages::TapeserverProxyZmq::
createArchiveJobFromCTAFrame(const std::string &vid,
const std::string &unitName) {
const std::string &unitName, const uint32_t nbFiles) {
try {
Frame frame;
......@@ -314,6 +314,7 @@ castor::messages::Frame castor::messages::TapeserverProxyZmq::
ArchiveJobFromCTA body;
body.set_vid(vid);
body.set_unitname(unitName);
body.set_nbfiles(nbFiles);
frame.serializeProtocolBufferIntoBody(body);
return frame;
......
......@@ -57,7 +57,7 @@ public:
* @return The number of files currently stored on the tape
*/
virtual uint32_t gotArchiveJobFromCTA(const std::string &vid,
const std::string &unitName);
const std::string &unitName, const uint32_t nbFiles);
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
......@@ -219,7 +219,7 @@ private:
* @return The frame.
*/
Frame createArchiveJobFromCTAFrame(const std::string &vid,
const std::string &unitName);
const std::string &unitName, const uint32_t nbFiles);
/**
* Creates a frame containing a RetrieveJobFromCTA message.
......
......@@ -101,6 +101,7 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
return MARK_DRIVE_AS_UP;
m_volInfo.vid=tapeMount->getVid();
m_volInfo.mountType=tapeMount->getMountType();
m_volInfo.nbFiles=tapeMount->getNbFiles();
// 2b) ... and log.
// Make the DGN and TPVID parameter permanent.
log::ScopedParamContainer params(lc);
......@@ -290,8 +291,9 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
//theses 2 numbers should match. Otherwise, it means the stager went mad
if(firstFseqFromClient != nbOfFileOnTape + 1) {
lc.log(LOG_ERR, "First file to write's fseq and number of files on "
"the tape according to the VMGR dont match");
std::stringstream ss;
ss << "First file to write's fseq(" << firstFseqFromClient << ") and number of files on the tape (" << nbOfFileOnTape << " + 1) dont match";
lc.log(LOG_ERR, ss.str());
//no mount at all, drive to be kept up = return 0
return MARK_DRIVE_AS_UP;
}
......
......@@ -337,19 +337,10 @@ castor::messages::Frame castor::tape::tapeserver::daemon::TapeMessageHandler::
castor::messages::ArchiveJobFromCTA rqstBody;
rqst.parseBodyIntoProtocolBuffer(rqstBody);
CatalogueDrive &drive =
m_driveCatalogue.findDrive(rqstBody.unitname());
CatalogueDrive &drive = m_driveCatalogue.findDrive(rqstBody.unitname());
drive.getTransferSession().receivedMigrationJob(rqstBody.vid());
{
std::ostringstream msg;
msg << __FUNCTION__ << ": Not fully implemented because the number of"
" files on tape is not known because there is no vmgr in the CTA"
" project";
throw castor::exception::Exception(msg.str());
}
//messages::Frame reply = createNbFilesOnTapeFrame(tapeInfo.nbFiles);
//return reply;
messages::Frame reply = createNbFilesOnTapeFrame(rqstBody.nbfiles());
return reply;
} catch(castor::exception::Exception &ne) {
castor::exception::Exception ex;
ex.getMessage() <<
......
......@@ -96,7 +96,7 @@ TapeServerReporter::TapeServerReporter(
m_lc.log(LOG_ERR,"TapeServerReporter is running but calling a synchronous operation on it"
"Could cause a race with the underlying zmq sockets in the proxy");
}
return m_tapeserverProxy.gotArchiveJobFromCTA(m_volume.vid, m_unitName);
return m_tapeserverProxy.gotArchiveJobFromCTA(m_volume.vid, m_unitName, m_volume.nbFiles);
}
//------------------------------------------------------------------------------
//gotReadMountDetailsFromClient
......
......@@ -43,6 +43,8 @@ namespace daemon {
std::string vid;
/** The mount type: archive or retrieve */
cta::MountType::Enum mountType;
/** The number of files currently on tape*/
uint32_t nbFiles;
};
} // namespace daemon
......
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