Commit 390ccab7 authored by Eric Cano's avatar Eric Cano
Browse files

Split the Agent class into AgentReference and Agent.

Agent becomes a usual class, like any other in the object store.
Object name generation (agent's and others) is now handled in the separate AgentReference.
The previous situation created race conditions.
parent 643d26b3
...@@ -24,16 +24,10 @@ ...@@ -24,16 +24,10 @@
#include "ProtocolBuffersAlgorithms.hpp" #include "ProtocolBuffersAlgorithms.hpp"
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <iomanip>
#include <sys/syscall.h>
#include <ctime> #include <ctime>
#include <cxxabi.h> #include <cxxabi.h>
#include <unistd.h>
#include <json-c/json.h> #include <json-c/json.h>
cta::objectstore::Agent::Agent(Backend & os):
ObjectOps<serializers::Agent, serializers::Agent_t>(os), m_nextId(0) {}
cta::objectstore::Agent::Agent(GenericObject& go): cta::objectstore::Agent::Agent(GenericObject& go):
ObjectOps<serializers::Agent, serializers::Agent_t>(go.objectStore()) { ObjectOps<serializers::Agent, serializers::Agent_t>(go.objectStore()) {
// Here we transplant the generic object into the new object // Here we transplant the generic object into the new object
...@@ -53,28 +47,6 @@ void cta::objectstore::Agent::initialize() { ...@@ -53,28 +47,6 @@ void cta::objectstore::Agent::initialize() {
m_payloadInterpreted = true; m_payloadInterpreted = true;
} }
void cta::objectstore::Agent::generateName(const std::string & typeName) {
std::stringstream aid;
// Get time
time_t now = time(0);
struct tm localNow;
localtime_r(&now, &localNow);
// Get hostname
char host[200];
cta::exception::Errnum::throwOnMinusOne(gethostname(host, sizeof(host)),
"In AgentId::AgentId: failed to gethostname");
// gettid is a safe system call (never fails)
aid << typeName << "-" << host << "-" << syscall(SYS_gettid) << "-"
<< 1900 + localNow.tm_year
<< std::setfill('0') << std::setw(2)
<< 1 + localNow.tm_mon
<< std::setw(2) << localNow.tm_mday << "-"
<< std::setw(2) << localNow.tm_hour << ":"
<< std::setw(2) << localNow.tm_min << ":"
<< std::setw(2) << localNow.tm_sec;
setAddress(aid.str());
}
void cta::objectstore::Agent::insertAndRegisterSelf() { void cta::objectstore::Agent::insertAndRegisterSelf() {
// We suppose initialize was already called, and that the agent name // We suppose initialize was already called, and that the agent name
// is set. // is set.
...@@ -149,12 +121,6 @@ bool cta::objectstore::Agent::isEmpty() { ...@@ -149,12 +121,6 @@ bool cta::objectstore::Agent::isEmpty() {
m_creationDone = true; m_creationDone = true;
}*/ }*/
std::string cta::objectstore::Agent::nextId(const std::string & childType) {
std::stringstream id;
id << childType << "-" << getAddressIfSet() << "-" << m_nextId++;
return id.str();
}
void cta::objectstore::Agent::addToOwnership(std::string name) { void cta::objectstore::Agent::addToOwnership(std::string name) {
checkPayloadWritable(); checkPayloadWritable();
std::string * owned = m_payload.mutable_ownedobjects()->Add(); std::string * owned = m_payload.mutable_ownedobjects()->Add();
......
...@@ -40,17 +40,12 @@ class GenericObject; ...@@ -40,17 +40,12 @@ class GenericObject;
class Agent: public ObjectOps<serializers::Agent, serializers::Agent_t> { class Agent: public ObjectOps<serializers::Agent, serializers::Agent_t> {
public: public:
CTA_GENERATE_EXCEPTION_CLASS(AgentStillOwnsObjects); CTA_GENERATE_EXCEPTION_CLASS(AgentStillOwnsObjects);
Agent(Backend & os);
Agent(GenericObject & go); Agent(GenericObject & go);
Agent(const std::string & name, Backend & os); Agent(const std::string & name, Backend & os);
void initialize(); void initialize();
void generateName(const std::string & typeName);
std::string nextId(const std::string & childType);
void insertAndRegisterSelf(); void insertAndRegisterSelf();
void removeAndUnregisterSelf(); void removeAndUnregisterSelf();
......
...@@ -25,18 +25,18 @@ namespace cta { namespace objectstore { ...@@ -25,18 +25,18 @@ namespace cta { namespace objectstore {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Constructor // Constructor
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
BackendPopulator::BackendPopulator(cta::objectstore::Backend & be): m_backend(be), m_agent(m_backend) { BackendPopulator::BackendPopulator(cta::objectstore::Backend & be): m_backend(be), m_agentReference("OStoreDBFactory") {
cta::objectstore::RootEntry re(m_backend); cta::objectstore::RootEntry re(m_backend);
cta::objectstore::ScopedExclusiveLock rel(re); cta::objectstore::ScopedExclusiveLock rel(re);
re.fetch(); re.fetch();
m_agent.generateName("OStoreDBFactory"); Agent agent(m_agentReference.getAgentAddress(), m_backend);
m_agent.initialize(); agent.initialize();
cta::objectstore::EntryLogSerDeser cl("user0", "systemhost", time(NULL)); cta::objectstore::EntryLogSerDeser cl("user0", "systemhost", time(NULL));
re.addOrGetAgentRegisterPointerAndCommit(m_agent,cl); re.addOrGetAgentRegisterPointerAndCommit(m_agentReference, cl);
rel.release(); rel.release();
m_agent.insertAndRegisterSelf(); agent.insertAndRegisterSelf();
rel.lock(re); rel.lock(re);
re.addOrGetDriveRegisterPointerAndCommit(m_agent, cl); re.addOrGetDriveRegisterPointerAndCommit(m_agentReference, cl);
rel.release(); rel.release();
} }
...@@ -44,16 +44,17 @@ BackendPopulator::BackendPopulator(cta::objectstore::Backend & be): m_backend(be ...@@ -44,16 +44,17 @@ BackendPopulator::BackendPopulator(cta::objectstore::Backend & be): m_backend(be
// Destructor // Destructor
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
BackendPopulator::~BackendPopulator() throw() { BackendPopulator::~BackendPopulator() throw() {
cta::objectstore::ScopedExclusiveLock agl(m_agent); Agent agent(m_agentReference.getAgentAddress(), m_backend);
m_agent.fetch(); cta::objectstore::ScopedExclusiveLock agl(agent);
m_agent.removeAndUnregisterSelf(); agent.fetch();
agent.removeAndUnregisterSelf();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// getAgent // getAgent
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
cta::objectstore::Agent & BackendPopulator::getAgent() { cta::objectstore::AgentReference & BackendPopulator::getAgentReference() {
return m_agent; return m_agentReference;
} }
}} }}
\ No newline at end of file
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#pragma once #pragma once
#include "objectstore/Agent.hpp" #include "objectstore/Agent.hpp"
#include "objectstore/AgentReference.hpp"
#include "objectstore/Backend.hpp" #include "objectstore/Backend.hpp"
namespace cta { namespace objectstore { namespace cta { namespace objectstore {
...@@ -43,7 +44,7 @@ public: ...@@ -43,7 +44,7 @@ public:
* *
* @return the agent * @return the agent
*/ */
cta::objectstore::Agent & getAgent(); cta::objectstore::AgentReference & getAgentReference();
private: private:
/** /**
...@@ -54,7 +55,7 @@ private: ...@@ -54,7 +55,7 @@ private:
/** /**
* The agent * The agent
*/ */
cta::objectstore::Agent m_agent; cta::objectstore::AgentReference m_agentReference;
}; };
}} }}
\ No newline at end of file
...@@ -51,6 +51,7 @@ add_library (ctaobjectstore SHARED ...@@ -51,6 +51,7 @@ add_library (ctaobjectstore SHARED
${CTAProtoSources} ${CTAProtoSources}
RootEntry.cpp RootEntry.cpp
Agent.cpp Agent.cpp
AgentReference.cpp
AgentRegister.cpp AgentRegister.cpp
AgentWatchdog.cpp AgentWatchdog.cpp
ArchiveQueue.cpp ArchiveQueue.cpp
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "GarbageCollector.hpp" #include "GarbageCollector.hpp"
#include "RootEntry.hpp" #include "RootEntry.hpp"
#include "Agent.hpp" #include "Agent.hpp"
#include "AgentReference.hpp"
#include "AgentRegister.hpp" #include "AgentRegister.hpp"
#include "DriveRegister.hpp" #include "DriveRegister.hpp"
#include "ArchiveRequest.hpp" #include "ArchiveRequest.hpp"
...@@ -35,8 +36,8 @@ TEST(ObjectStore, GarbageCollectorBasicFuctionnality) { ...@@ -35,8 +36,8 @@ TEST(ObjectStore, GarbageCollectorBasicFuctionnality) {
// Here we check for the ability to detect dead (but empty agents) // Here we check for the ability to detect dead (but empty agents)
// and clean them up. // and clean them up.
cta::objectstore::BackendVFS be; cta::objectstore::BackendVFS be;
cta::objectstore::Agent agent(be); cta::objectstore::AgentReference agentRef("unitTestGarbageCollector");
agent.generateName("unitTestGarbageCollector"); cta::objectstore::Agent agent(agentRef.getAgentAddress(), be);
// Create the root entry // Create the root entry
cta::objectstore::RootEntry re(be); cta::objectstore::RootEntry re(be);
re.initialize(); re.initialize();
...@@ -45,24 +46,23 @@ TEST(ObjectStore, GarbageCollectorBasicFuctionnality) { ...@@ -45,24 +46,23 @@ TEST(ObjectStore, GarbageCollectorBasicFuctionnality) {
cta::objectstore::EntryLogSerDeser el("user0", cta::objectstore::EntryLogSerDeser el("user0",
"unittesthost", time(NULL)); "unittesthost", time(NULL));
cta::objectstore::ScopedExclusiveLock rel(re); cta::objectstore::ScopedExclusiveLock rel(re);
re.addOrGetAgentRegisterPointerAndCommit(agent, el); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el);
rel.release(); rel.release();
// Create 2 agents, A and B and register them // Create 2 agents, A and B and register them
// The agents are set with a timeout of 0, so they will be delclared // The agents are set with a timeout of 0, so they will be delclared
// dead immediately. // dead immediately.
cta::objectstore::Agent agA(be), agB(be); cta::objectstore::AgentReference agrA("unitTestAgentA"), agrB("unitTestAgentB");
cta::objectstore::Agent agA(agrA.getAgentAddress(), be), agB(agrB.getAgentAddress(), be);
agA.initialize(); agA.initialize();
agA.generateName("unitTestAgentA");
agA.setTimeout_us(0); agA.setTimeout_us(0);
agA.insertAndRegisterSelf(); agA.insertAndRegisterSelf();
agB.initialize(); agB.initialize();
agB.generateName("unitTestAgentB");
agB.setTimeout_us(0); agB.setTimeout_us(0);
agB.insertAndRegisterSelf(); agB.insertAndRegisterSelf();
// Create the garbage colletor and run it twice. // Create the garbage colletor and run it twice.
cta::objectstore::Agent gcAgent(be); cta::objectstore::AgentReference gcAgentRef("unitTestGarbageCollector");
cta::objectstore::Agent gcAgent(gcAgentRef.getAgentAddress(), be);
gcAgent.initialize(); gcAgent.initialize();
gcAgent.generateName("unitTestGarbageCollector");
gcAgent.setTimeout_us(0); gcAgent.setTimeout_us(0);
gcAgent.insertAndRegisterSelf(); gcAgent.insertAndRegisterSelf();
{ {
...@@ -83,8 +83,8 @@ TEST(ObjectStore, GarbageCollectorBasicFuctionnality) { ...@@ -83,8 +83,8 @@ TEST(ObjectStore, GarbageCollectorBasicFuctionnality) {
TEST(ObjectStore, GarbageCollectorRegister) { TEST(ObjectStore, GarbageCollectorRegister) {
// Here we check that can successfully call agentRegister's garbage collector // Here we check that can successfully call agentRegister's garbage collector
cta::objectstore::BackendVFS be; cta::objectstore::BackendVFS be;
cta::objectstore::Agent agent(be); cta::objectstore::AgentReference agentRef("unitTestGarbageCollector");
agent.generateName("unitTestGarbageCollector"); cta::objectstore::Agent agent(agentRef.getAgentAddress(), be);
// Create the root entry // Create the root entry
cta::objectstore::RootEntry re(be); cta::objectstore::RootEntry re(be);
re.initialize(); re.initialize();
...@@ -93,19 +93,19 @@ TEST(ObjectStore, GarbageCollectorRegister) { ...@@ -93,19 +93,19 @@ TEST(ObjectStore, GarbageCollectorRegister) {
cta::objectstore::EntryLogSerDeser el("user0", cta::objectstore::EntryLogSerDeser el("user0",
"unittesthost", time(NULL)); "unittesthost", time(NULL));
cta::objectstore::ScopedExclusiveLock rel(re); cta::objectstore::ScopedExclusiveLock rel(re);
re.addOrGetAgentRegisterPointerAndCommit(agent, el); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el);
rel.release(); rel.release();
// Create an agent and add and agent register to it as an owned object // Create an agent and add and agent register to it as an owned object
cta::objectstore::Agent agA(be); cta::objectstore::AgentReference agrA("unitTestAgentA");
cta::objectstore::Agent agA(agrA.getAgentAddress(), be);
agA.initialize(); agA.initialize();
agA.generateName("unitTestAgentA");
agA.setTimeout_us(0); agA.setTimeout_us(0);
agA.insertAndRegisterSelf(); agA.insertAndRegisterSelf();
// Create a new agent register, owned by agA (by hand as it is not an usual // Create a new agent register, owned by agA (by hand as it is not an usual
// situation) // situation)
std::string arName; std::string arName;
{ {
arName = agA.nextId("AgentRegister"); arName = agrA.nextId("AgentRegister");
cta::objectstore::AgentRegister ar(arName, be); cta::objectstore::AgentRegister ar(arName, be);
ar.initialize(); ar.initialize();
ar.setOwner(agA.getAddressIfSet()); ar.setOwner(agA.getAddressIfSet());
...@@ -116,9 +116,9 @@ TEST(ObjectStore, GarbageCollectorRegister) { ...@@ -116,9 +116,9 @@ TEST(ObjectStore, GarbageCollectorRegister) {
ar.insert(); ar.insert();
} }
// Create the garbage colletor and run it twice. // Create the garbage colletor and run it twice.
cta::objectstore::Agent gcAgent(be); cta::objectstore::AgentReference gcAgentRef("unitTestGarbageCollector");
cta::objectstore::Agent gcAgent(gcAgentRef.getAgentAddress(), be);
gcAgent.initialize(); gcAgent.initialize();
gcAgent.generateName("unitTestGarbageCollector");
gcAgent.setTimeout_us(0); gcAgent.setTimeout_us(0);
gcAgent.insertAndRegisterSelf(); gcAgent.insertAndRegisterSelf();
{ {
...@@ -140,8 +140,8 @@ TEST(ObjectStore, GarbageCollectorRegister) { ...@@ -140,8 +140,8 @@ TEST(ObjectStore, GarbageCollectorRegister) {
TEST(ObjectStore, GarbageCollectorArchiveQueue) { TEST(ObjectStore, GarbageCollectorArchiveQueue) {
// Here we check that can successfully call agentRegister's garbage collector // Here we check that can successfully call agentRegister's garbage collector
cta::objectstore::BackendVFS be; cta::objectstore::BackendVFS be;
cta::objectstore::Agent agent(be); cta::objectstore::AgentReference agentRef("unitTestGarbageCollector");
agent.generateName("unitTestGarbageCollector"); cta::objectstore::Agent agent(agentRef.getAgentAddress(), be);
// Create the root entry // Create the root entry
cta::objectstore::RootEntry re(be); cta::objectstore::RootEntry re(be);
re.initialize(); re.initialize();
...@@ -150,19 +150,19 @@ TEST(ObjectStore, GarbageCollectorArchiveQueue) { ...@@ -150,19 +150,19 @@ TEST(ObjectStore, GarbageCollectorArchiveQueue) {
cta::objectstore::EntryLogSerDeser el("user0", cta::objectstore::EntryLogSerDeser el("user0",
"unittesthost", time(NULL)); "unittesthost", time(NULL));
cta::objectstore::ScopedExclusiveLock rel(re); cta::objectstore::ScopedExclusiveLock rel(re);
re.addOrGetAgentRegisterPointerAndCommit(agent, el); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el);
rel.release(); rel.release();
// Create an agent and add and agent register to it as an owned object // Create an agent and add and agent register to it as an owned object
cta::objectstore::Agent agA(be); cta::objectstore::AgentReference agrA("unitTestAgentA");
cta::objectstore::Agent agA(agrA.getAgentAddress(), be);
agA.initialize(); agA.initialize();
agA.generateName("unitTestAgentA");
agA.setTimeout_us(0); agA.setTimeout_us(0);
agA.insertAndRegisterSelf(); agA.insertAndRegisterSelf();
// Create a new agent register, owned by agA (by hand as it is not an usual // Create a new agent register, owned by agA (by hand as it is not an usual
// situation) // situation)
std::string tpName; std::string tpName;
{ {
tpName = agA.nextId("ArchiveQueue"); tpName = agrA.nextId("ArchiveQueue");
cta::objectstore::ArchiveQueue aq(tpName, be); cta::objectstore::ArchiveQueue aq(tpName, be);
aq.initialize("SomeTP"); aq.initialize("SomeTP");
aq.setOwner(agA.getAddressIfSet()); aq.setOwner(agA.getAddressIfSet());
...@@ -173,9 +173,9 @@ TEST(ObjectStore, GarbageCollectorArchiveQueue) { ...@@ -173,9 +173,9 @@ TEST(ObjectStore, GarbageCollectorArchiveQueue) {
aq.insert(); aq.insert();
} }
// Create the garbage colletor and run it twice. // Create the garbage colletor and run it twice.
cta::objectstore::Agent gcAgent(be); cta::objectstore::AgentReference gcAgentRef("unitTestGarbageCollector");
cta::objectstore::Agent gcAgent(gcAgentRef.getAgentAddress(), be);
gcAgent.initialize(); gcAgent.initialize();
gcAgent.generateName("unitTestGarbageCollector");
gcAgent.setTimeout_us(0); gcAgent.setTimeout_us(0);
gcAgent.insertAndRegisterSelf(); gcAgent.insertAndRegisterSelf();
{ {
...@@ -197,8 +197,8 @@ TEST(ObjectStore, GarbageCollectorArchiveQueue) { ...@@ -197,8 +197,8 @@ TEST(ObjectStore, GarbageCollectorArchiveQueue) {
TEST(ObjectStore, GarbageCollectorDriveRegister) { TEST(ObjectStore, GarbageCollectorDriveRegister) {
// Here we check that can successfully call agentRegister's garbage collector // Here we check that can successfully call agentRegister's garbage collector
cta::objectstore::BackendVFS be; cta::objectstore::BackendVFS be;
cta::objectstore::Agent agent(be); cta::objectstore::AgentReference agentRef("unitTestGarbageCollector");
agent.generateName("unitTestGarbageCollector"); cta::objectstore::Agent agent(agentRef.getAgentAddress(), be);
// Create the root entry // Create the root entry
cta::objectstore::RootEntry re(be); cta::objectstore::RootEntry re(be);
re.initialize(); re.initialize();
...@@ -207,19 +207,19 @@ TEST(ObjectStore, GarbageCollectorDriveRegister) { ...@@ -207,19 +207,19 @@ TEST(ObjectStore, GarbageCollectorDriveRegister) {
cta::objectstore::EntryLogSerDeser el("user0", cta::objectstore::EntryLogSerDeser el("user0",
"unittesthost", time(NULL)); "unittesthost", time(NULL));
cta::objectstore::ScopedExclusiveLock rel(re); cta::objectstore::ScopedExclusiveLock rel(re);
re.addOrGetAgentRegisterPointerAndCommit(agent, el); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el);
rel.release(); rel.release();
// Create an agent and add the drive register to it as an owned object // Create an agent and add the drive register to it as an owned object
cta::objectstore::Agent agA(be); cta::objectstore::AgentReference agrA("unitTestAgentA");
cta::objectstore::Agent agA(agrA.getAgentAddress(), be);
agA.initialize(); agA.initialize();
agA.generateName("unitTestAgentA");
agA.setTimeout_us(0); agA.setTimeout_us(0);
agA.insertAndRegisterSelf(); agA.insertAndRegisterSelf();
// Create a new drive register, owned by agA (by hand as it is not an usual // Create a new drive register, owned by agA (by hand as it is not an usual
// situation) // situation)
std::string tpName; std::string tpName;
{ {
tpName = agA.nextId("ArchiveQueue"); tpName = agrA.nextId("ArchiveQueue");
cta::objectstore::DriveRegister dr(tpName, be); cta::objectstore::DriveRegister dr(tpName, be);
dr.initialize(); dr.initialize();
dr.setOwner(agA.getAddressIfSet()); dr.setOwner(agA.getAddressIfSet());
...@@ -230,9 +230,9 @@ TEST(ObjectStore, GarbageCollectorDriveRegister) { ...@@ -230,9 +230,9 @@ TEST(ObjectStore, GarbageCollectorDriveRegister) {
dr.insert(); dr.insert();
} }
// Create the garbage colletor and run it twice. // Create the garbage colletor and run it twice.
cta::objectstore::Agent gcAgent(be); cta::objectstore::AgentReference gcAgentRef("unitTestGarbageCollector");
cta::objectstore::Agent gcAgent(gcAgentRef.getAgentAddress(), be);
gcAgent.initialize(); gcAgent.initialize();
gcAgent.generateName("unitTestGarbageCollector");
gcAgent.setTimeout_us(0); gcAgent.setTimeout_us(0);
gcAgent.insertAndRegisterSelf(); gcAgent.insertAndRegisterSelf();
{ {
...@@ -254,8 +254,8 @@ TEST(ObjectStore, GarbageCollectorDriveRegister) { ...@@ -254,8 +254,8 @@ TEST(ObjectStore, GarbageCollectorDriveRegister) {
TEST(ObjectStore, GarbageCollectorArchiveRequest) { TEST(ObjectStore, GarbageCollectorArchiveRequest) {
// Here we check that can successfully call ArchiveRequests's garbage collector // Here we check that can successfully call ArchiveRequests's garbage collector
cta::objectstore::BackendVFS be; cta::objectstore::BackendVFS be;
cta::objectstore::Agent agent(be); cta::objectstore::AgentReference agentRef("unitTestGarbageCollector");
agent.generateName("unitTestGarbageCollector"); cta::objectstore::Agent agent(agentRef.getAgentAddress(), be);
// Create the root entry // Create the root entry
cta::objectstore::RootEntry re(be); cta::objectstore::RootEntry re(be);
re.initialize(); re.initialize();
...@@ -264,12 +264,12 @@ TEST(ObjectStore, GarbageCollectorArchiveRequest) { ...@@ -264,12 +264,12 @@ TEST(ObjectStore, GarbageCollectorArchiveRequest) {
cta::objectstore::EntryLogSerDeser el("user0", cta::objectstore::EntryLogSerDeser el("user0",
"unittesthost", time(NULL)); "unittesthost", time(NULL));
cta::objectstore::ScopedExclusiveLock rel(re); cta::objectstore::ScopedExclusiveLock rel(re);
re.addOrGetAgentRegisterPointerAndCommit(agent, el); re.addOrGetAgentRegisterPointerAndCommit(agentRef, el);
rel.release(); rel.release();
// Create an agent // Create an agent
cta::objectstore::Agent agA(be); cta::objectstore::AgentReference agrA("unitTestAgentA");
cta::objectstore::Agent agA(agrA.getAgentAddress(), be);
agA.initialize(); agA.initialize();
agA.generateName("unitTestAgentA");
agA.setTimeout_us(0); agA.setTimeout_us(0);
agA.insertAndRegisterSelf(); agA.insertAndRegisterSelf();
// Several use cases are present for the ArchiveRequests: // Several use cases are present for the ArchiveRequests:
...@@ -286,7 +286,7 @@ TEST(ObjectStore, GarbageCollectorArchiveRequest) { ...@@ -286,7 +286,7 @@ TEST(ObjectStore, GarbageCollectorArchiveRequest) {
{ {
std::stringstream aqid; std::stringstream aqid;
aqid << "ArchiveQueue" << i; aqid << "ArchiveQueue" << i;
tpAddr[i] = agent.nextId(aqid.str()); tpAddr[i] = agentRef.nextId(aqid.str());
cta::objectstore::ArchiveQueue aq(tpAddr[i], be); cta::objectstore::ArchiveQueue aq(tpAddr[i], be);
aq.initialize(aqid.str()); aq.initialize(aqid.str());
aq.setOwner(""); aq.setOwner("");
...@@ -297,7 +297,7 @@ TEST(ObjectStore, GarbageCollectorArchiveRequest) { ...@@ -297,7 +297,7 @@ TEST(ObjectStore, GarbageCollectorArchiveRequest) {
while (true) while (true)
{ {
// -just referenced // -just referenced
std::string atfrAddr = agA.nextId("ArchiveRequest"); std::string atfrAddr = agrA.nextId("ArchiveRequest");
cta::objectstore::ScopedExclusiveLock agl(agA); cta::objectstore::ScopedExclusiveLock agl(agA);
agA.fetch(); agA.fetch();
agA.addToOwnership(atfrAddr); agA.addToOwnership(atfrAddr);
...@@ -383,9 +383,9 @@ TEST(ObjectStore, GarbageCollectorArchiveRequest) { ...@@ -383,9 +383,9 @@ TEST(ObjectStore, GarbageCollectorArchiveRequest) {
break; break;
} }
// Create the garbage collector and run it twice. // Create the garbage collector and run it twice.
cta::objectstore::Agent gcAgent(be); cta::objectstore::AgentReference gcAgentRef("unitTestGarbageCollector");
cta::objectstore::Agent gcAgent(gcAgentRef.getAgentAddress(), be);
gcAgent.initialize(); gcAgent.initialize();
gcAgent.generateName("unitTestGarbageCollector");
gcAgent.setTimeout_us(0); gcAgent.setTimeout_us(0);
gcAgent.insertAndRegisterSelf(); gcAgent.insertAndRegisterSelf();
{ {
......
...@@ -19,15 +19,14 @@ ...@@ -19,15 +19,14 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "RetrieveQueue.hpp" #include "RetrieveQueue.hpp"
#include "BackendVFS.hpp" #include "BackendVFS.hpp"
#include "Agent.hpp" #include "AgentReference.hpp"
namespace unitTests { namespace unitTests {
TEST(ObjectStore, RetrieveQueueBasicAccess) { TEST(ObjectStore, RetrieveQueueBasicAccess) {
cta::objectstore::BackendVFS be; cta::objectstore::BackendVFS be;
cta::objectstore::Agent agent(be); cta::objectstore::AgentReference agentRef("unitTest");
agent.generateName("unitTest"); std::string retrieveQueueAddress = agentRef.nextId("RetrieveQueue");