Commit 87d9b62e authored by Eric Cano's avatar Eric Cano
Browse files

Added missing success() implementation for retrieve jobs.

parent 67316087
......@@ -54,6 +54,24 @@ void cta::objectstore::RetrieveToFileRequest::addJob(const cta::TapeFileLocation
j->set_fseq(tapeFileLocation.fSeq);
}
bool cta::objectstore::RetrieveToFileRequest::setJobSuccessful(uint16_t copyNumber) {
checkPayloadWritable();
auto * jl = m_payload.mutable_jobs();
for (auto j=jl->begin(); j!=jl->end(); j++) {
if (j->copynb() == copyNumber) {
j->set_status(serializers::RetrieveJobStatus::RJS_Complete);
for (auto j2=jl->begin(); j2!=jl->end(); j2++) {
if (j2->status()!= serializers::RetrieveJobStatus::RJS_Complete &&
j2->status()!= serializers::RetrieveJobStatus::RJS_Failed)
return false;
}
return true;
}
}
throw NoSuchJob("In RetrieveToFileRequest::setJobSuccessful(): job not found");
}
void cta::objectstore::RetrieveToFileRequest::setArchiveFile(
const cta::ArchiveFile& archiveFile) {
checkPayloadWritable();
......
......@@ -43,6 +43,7 @@ public:
uint16_t maxRetiesWithinMount, uint16_t maxTotalRetries);
void setJobSelected(uint16_t copyNumber, const std::string & owner);
void setJobPending(uint16_t copyNumber);
bool setJobSuccessful(uint16_t copyNumber); //< returns true if this is the last job
class JobDump {
public:
uint16_t copyNb;
......
......@@ -1750,7 +1750,22 @@ OStoreDB::RetrieveJob::~RetrieveJob() {
}
void OStoreDB::RetrieveJob::succeed() {
throw NotImplemented("");
// Lock the request and set the job as successful.
objectstore::ScopedExclusiveLock rtfrl(m_rtfr);
m_rtfr.fetch();
std::string rtfrAddress = m_rtfr.getAddressIfSet();
if (m_rtfr.setJobSuccessful(m_copyNb)) {
m_rtfr.remove();
} else {
m_rtfr.commit();
}
// We no more own the job (which could be gone)
m_jobOwned = false;
// Remove ownership form the agent
objectstore::ScopedExclusiveLock al(m_agent);
m_agent.fetch();
m_agent.removeFromOwnership(rtfrAddress);
m_agent.commit();
}
......
......@@ -43,6 +43,7 @@ cta::RetrieveJob::RetrieveJob(RetrieveMount &mount,
// complete
//------------------------------------------------------------------------------
void cta::RetrieveJob::complete() {
m_dbJob->succeed();
}
//------------------------------------------------------------------------------
......
......@@ -409,8 +409,8 @@ protected:
// Check the parameter name, if it's an empty string set the value to
// "Undefined".
const std::string name = param.getName() == "" ? "Undefined" :
cleanString(param.getName(), true);
const std::string name = (param.getName() == "" ? "Undefined" :
cleanString(param.getName(), true));
// Process the parameter value
const std::string value = cleanString(param.getValue(), false);
......
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