summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2003-06-17 23:26:29 +0000
committerMark Spruiell <mes@zeroc.com>2003-06-17 23:26:29 +0000
commit91bc70a83fa8159610c1aeb9b922094fa36ce746 (patch)
tree4310fe17c194bfd068eeba104afa71da91d807bc /cpp
parentRemoved removeServantLocator() from ObjectAdapter. (diff)
downloadice-91bc70a83fa8159610c1aeb9b922094fa36ce746.tar.bz2
ice-91bc70a83fa8159610c1aeb9b922094fa36ce746.tar.xz
ice-91bc70a83fa8159610c1aeb9b922094fa36ce746.zip
removing use of removeServantLocator
Diffstat (limited to 'cpp')
-rw-r--r--cpp/test/Freeze/evictor/Client.cpp17
-rw-r--r--cpp/test/Freeze/evictor/Server.cpp4
-rw-r--r--cpp/test/Freeze/evictor/Test.ice3
-rw-r--r--cpp/test/Freeze/evictor/TestI.cpp33
-rw-r--r--cpp/test/Freeze/evictor/TestI.h5
5 files changed, 42 insertions, 20 deletions
diff --git a/cpp/test/Freeze/evictor/Client.cpp b/cpp/test/Freeze/evictor/Client.cpp
index 4eda5245fe3..08d7077b77d 100644
--- a/cpp/test/Freeze/evictor/Client.cpp
+++ b/cpp/test/Freeze/evictor/Client.cpp
@@ -55,7 +55,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
vector<Test::ServantPrx> servants;
for(i = 0; i < size; i++)
{
- servants.push_back(evictor->createServant(i));
+ servants.push_back(evictor->createServant(i, i));
test(evictor->getLastSavedValue() == i);
}
@@ -124,7 +124,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- servants.push_back(evictor->createServant(i));
+ servants.push_back(evictor->createServant(i, i));
}
//
@@ -136,6 +136,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
evictor->setSize(size);
for(i = 0; i < size; i++)
{
+ servants[i] = evictor->getServant(i);
test(servants[i]->getValue() == i);
}
@@ -147,7 +148,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
// Create new servant - should cause eviction.
//
- servants.push_back(evictor->createServant(size));
+ servants.push_back(evictor->createServant(size, size));
test(evictor->getLastEvictedValue() == 0);
//
@@ -171,7 +172,6 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
}
test(evictor->getLastEvictedValue() == -1);
-
//
// Test explicit saves
//
@@ -189,6 +189,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
servants[i]->destroy();
}
+ evictor->deactivate();
cout << "ok" << endl;
}
@@ -212,7 +213,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
vector<Test::ServantPrx> servants;
for(i = 0; i < size; i++)
{
- servants.push_back(evictor->createServant(i));
+ servants.push_back(evictor->createServant(i, i));
test(evictor->getLastSavedValue() == i);
}
@@ -312,7 +313,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- servants.push_back(evictor->createServant(i));
+ servants.push_back(evictor->createServant(i, i));
}
//
@@ -324,6 +325,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
evictor->setSize(size);
for(i = 0; i < size; i++)
{
+ servants[i] = evictor->getServant(i);
test(servants[i]->getValue() == i);
}
@@ -336,7 +338,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
// Create new servant - should cause eviction but no
// servants should be saved.
//
- servants.push_back(evictor->createServant(size));
+ servants.push_back(evictor->createServant(size, size));
test(evictor->getLastSavedValue() == size);
test(evictor->getLastEvictedValue() != -1);
@@ -359,6 +361,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
servants[i]->destroy();
}
+ evictor->deactivate();
cout << "ok" << endl;
}
diff --git a/cpp/test/Freeze/evictor/Server.cpp b/cpp/test/Freeze/evictor/Server.cpp
index 763c24dcf53..08302080020 100644
--- a/cpp/test/Freeze/evictor/Server.cpp
+++ b/cpp/test/Freeze/evictor/Server.cpp
@@ -38,9 +38,9 @@ public:
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator, const Freeze::DBEnvironmentPtr& dbEnv)
{
- communicator->getProperties()->setProperty("Evictor.Endpoints", "default -p 12345 -t 2000");
+ communicator->getProperties()->setProperty("Factory.Endpoints", "default -p 12345 -t 2000");
- Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Evictor");
+ Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Factory");
Test::RemoteEvictorFactoryPtr factory = new Test::RemoteEvictorFactoryI(adapter, dbEnv);
adapter->add(factory, Ice::stringToIdentity("factory"));
diff --git a/cpp/test/Freeze/evictor/Test.ice b/cpp/test/Freeze/evictor/Test.ice
index 1878cf64451..4850f02fec0 100644
--- a/cpp/test/Freeze/evictor/Test.ice
+++ b/cpp/test/Freeze/evictor/Test.ice
@@ -37,7 +37,8 @@ class Servant
interface RemoteEvictor
{
void setSize(int size);
- Servant* createServant(int value);
+ Servant* createServant(int id, int value);
+ Servant* getServant(int id);
nonmutating int getLastSavedValue();
void clearLastSavedValue();
nonmutating int getLastEvictedValue();
diff --git a/cpp/test/Freeze/evictor/TestI.cpp b/cpp/test/Freeze/evictor/TestI.cpp
index e70a63681a2..bbdfb88d5db 100644
--- a/cpp/test/Freeze/evictor/TestI.cpp
+++ b/cpp/test/Freeze/evictor/TestI.cpp
@@ -106,6 +106,10 @@ Test::RemoteEvictorI::RemoteEvictorI(const ObjectAdapterPtr& adapter, const stri
_evictor(evictor),
_lastSavedValue(-1)
{
+ CommunicatorPtr communicator = adapter->getCommunicator();
+ _evictorAdapter = communicator->createObjectAdapterWithEndpoints(IceUtil::generateUUID(), "default");
+ _evictorAdapter->addServantLocator(evictor, category);
+ _evictorAdapter->activate();
}
void
@@ -115,16 +119,27 @@ Test::RemoteEvictorI::setSize(Int size, const Current&)
}
Test::ServantPrx
-Test::RemoteEvictorI::createServant(Int value, const Current&)
+Test::RemoteEvictorI::createServant(Int id, Int value, const Current&)
{
- Identity id;
- id.category = _category;
+ Identity ident;
+ ident.category = _category;
ostringstream ostr;
- ostr << value;
- id.name = ostr.str();
+ ostr << id;
+ ident.name = ostr.str();
ServantPtr servant = new ServantI(this, _evictor, value);
- _evictor->createObject(id, servant);
- return ServantPrx::uncheckedCast(_adapter->createProxy(id));
+ _evictor->createObject(ident, servant);
+ return ServantPrx::uncheckedCast(_evictorAdapter->createProxy(ident));
+}
+
+Test::ServantPrx
+Test::RemoteEvictorI::getServant(Int id, const Current&)
+{
+ Identity ident;
+ ident.category = _category;
+ ostringstream ostr;
+ ostr << id;
+ ident.name = ostr.str();
+ return ServantPrx::uncheckedCast(_evictorAdapter->createProxy(ident));
}
Int
@@ -156,7 +171,8 @@ Test::RemoteEvictorI::clearLastEvictedValue(const Current&)
void
Test::RemoteEvictorI::deactivate(const Current& current)
{
- _adapter->removeServantLocator(_category);
+ _evictorAdapter->deactivate();
+ _evictorAdapter->waitForDeactivate();
_adapter->remove(stringToIdentity(_category));
_db->close();
}
@@ -215,7 +231,6 @@ Test::RemoteEvictorFactoryI::createEvictor(const string& name,
}
StrategyIPtr strategy = new StrategyI(delegate);
Freeze::EvictorPtr evictor = db->createEvictor(strategy);
- _adapter->addServantLocator(evictor, name);
RemoteEvictorIPtr remoteEvictor = new RemoteEvictorI(_adapter, name, db, strategy, evictor);
Freeze::ServantInitializerPtr initializer = new Initializer(remoteEvictor, evictor);
diff --git a/cpp/test/Freeze/evictor/TestI.h b/cpp/test/Freeze/evictor/TestI.h
index f3194f9311f..4f2150c799a 100644
--- a/cpp/test/Freeze/evictor/TestI.h
+++ b/cpp/test/Freeze/evictor/TestI.h
@@ -74,7 +74,9 @@ public:
virtual void setSize(::Ice::Int, const Ice::Current&);
- virtual ::Test::ServantPrx createServant(::Ice::Int, const Ice::Current&);
+ virtual ::Test::ServantPrx createServant(::Ice::Int, ::Ice::Int, const Ice::Current&);
+
+ virtual ::Test::ServantPrx getServant(::Ice::Int, const Ice::Current&);
virtual ::Ice::Int getLastSavedValue(const Ice::Current&) const;
@@ -95,6 +97,7 @@ private:
Freeze::DBPtr _db;
StrategyIPtr _strategy;
Freeze::EvictorPtr _evictor;
+ Ice::ObjectAdapterPtr _evictorAdapter;
Ice::Int _lastSavedValue;
};