Skip to content
Snippets Groups Projects
Commit ee6c61df authored by Michael Davis's avatar Michael Davis
Browse files

[os-generic-queues] Implements Retrieve referenceAndSwitchOwnershipIfNecessary()

parent d3c25dc5
No related branches found
No related tags found
No related merge requests found
......@@ -205,10 +205,12 @@ public:
}
}
/** Reference objects in the container if needed and then switch their ownership (if needed). Objects
* are expected to be owned by agent, and not listed in the container but situations might vary.
* This function is typically used by the garbage collector. We do noe take care of dereferencing
* the object from the caller.
/**
* Reference objects in the container if needed and then switch their ownership (if needed).
*
* Objects are expected to be owned by an agent and not listed in the container, but situations
* might vary. This function is typically used by the garbage collector. We do not take care of
* dereferencing the object from the caller.
*/
void referenceAndSwitchOwnershipIfNecessary(const typename ContainerTraits<C>::ContainerIdentifier & contId,
typename ContainerTraits<C>::ContainerAddress & previousOwnerAddress,
......
......@@ -177,7 +177,15 @@ TEST(ObjectStore, RetrieveQueueAlgorithms) {
ContainerAlgorithms<RetrieveQueue> retrieveAlgos(be, agentRef);
try {
ASSERT_EQ(requests.size(), 10);
#if 1
auto a1 = agentRef.getAgentAddress();
auto a2 = agentRef.getAgentAddress();
retrieveAlgos.referenceAndSwitchOwnershipIfNecessary("VID", a1, a2, requests, lc);
#else
retrieveAlgos.referenceAndSwitchOwnership("VID", requests, lc);
#endif
// Now get the requests back
ContainerTraits<RetrieveQueue>::PopCriteria popCriteria;
popCriteria.bytes = std::numeric_limits<decltype(popCriteria.bytes)>::max();
......
......@@ -149,23 +149,16 @@ addReferencesAndCommit(Container &cont, InsertedElement::list &elemMemCont, Agen
}
template<>
void ContainerTraits<RetrieveQueue>::addReferencesIfNecessaryAndCommit(Container& cont,
InsertedElement::list& elemMemCont, AgentReference& agentRef, log::LogContext& lc)
void ContainerTraits<RetrieveQueue>::
addReferencesIfNecessaryAndCommit(Container& cont, InsertedElement::list& elemMemCont,
AgentReference& agentRef, log::LogContext& lc)
{
throw std::runtime_error("ContainerTraits<RetrieveQueue>::addReferencesIfNecessaryAndCommit(): Not implemented");
#if 0
std::list<ArchiveQueue::JobToAdd> jobsToAdd;
for (auto & e: elemMemCont) {
ElementDescriptor jd;
jd.copyNb = e.copyNb;
jd.tapePool = cont.getTapePool();
jd.owner = cont.getAddressIfSet();
ArchiveRequest & ar = *e.archiveRequest;
jobsToAdd.push_back({jd, ar.getAddressIfSet(), e.archiveFile.archiveFileID, e.archiveFile.fileSize,
e.mountPolicy, time(nullptr)});
std::list<RetrieveQueue::JobToAdd> jobsToAdd;
for (auto &e : elemMemCont) {
RetrieveRequest &rr = *e.retrieveRequest;
jobsToAdd.push_back({e.copyNb, e.fSeq, rr.getAddressIfSet(), e.filesize, e.policy, ::time(nullptr)});
}
cont.addJobsIfNecessaryAndCommit(jobsToAdd, agentRef, lc);
#endif
}
template<>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment