diff options
author | Mark Spruiell <mes@zeroc.com> | 2003-06-17 23:26:29 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2003-06-17 23:26:29 +0000 |
commit | 91bc70a83fa8159610c1aeb9b922094fa36ce746 (patch) | |
tree | 4310fe17c194bfd068eeba104afa71da91d807bc | |
parent | Removed removeServantLocator() from ObjectAdapter. (diff) | |
download | ice-91bc70a83fa8159610c1aeb9b922094fa36ce746.tar.bz2 ice-91bc70a83fa8159610c1aeb9b922094fa36ce746.tar.xz ice-91bc70a83fa8159610c1aeb9b922094fa36ce746.zip |
removing use of removeServantLocator
-rw-r--r-- | cpp/test/Freeze/evictor/Client.cpp | 17 | ||||
-rw-r--r-- | cpp/test/Freeze/evictor/Server.cpp | 4 | ||||
-rw-r--r-- | cpp/test/Freeze/evictor/Test.ice | 3 | ||||
-rw-r--r-- | cpp/test/Freeze/evictor/TestI.cpp | 33 | ||||
-rw-r--r-- | cpp/test/Freeze/evictor/TestI.h | 5 | ||||
-rw-r--r-- | java/test/Freeze/evictor/Client.java | 16 | ||||
-rw-r--r-- | java/test/Freeze/evictor/RemoteEvictorFactoryI.java | 1 | ||||
-rw-r--r-- | java/test/Freeze/evictor/RemoteEvictorI.java | 29 | ||||
-rw-r--r-- | java/test/Freeze/evictor/Test.ice | 3 |
9 files changed, 76 insertions, 35 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; }; diff --git a/java/test/Freeze/evictor/Client.java b/java/test/Freeze/evictor/Client.java index b33c57fcba8..b9613759063 100644 --- a/java/test/Freeze/evictor/Client.java +++ b/java/test/Freeze/evictor/Client.java @@ -64,7 +64,7 @@ public class Client Test.ServantPrx[] servants = new Test.ServantPrx[size]; for(int i = 0; i < size; i++) { - servants[i] = evictor.createServant(i); + servants[i] = evictor.createServant(i, i); test(evictor.getLastSavedValue() == i); } @@ -133,7 +133,7 @@ public class Client // for(int i = 0; i < size; i++) { - servants[i] = evictor.createServant(i); + servants[i] = evictor.createServant(i, i); } // @@ -145,6 +145,7 @@ public class Client evictor.setSize(size); for(int i = 0; i < size; i++) { + servants[i] = evictor.getServant(i); test(servants[i].getValue() == i); } @@ -156,7 +157,7 @@ public class Client // // Create new servant - should cause eviction. // - servants[size] = evictor.createServant(size); + servants[size] = evictor.createServant(size, size); test(evictor.getLastEvictedValue() == 0); // @@ -198,6 +199,7 @@ public class Client servants[i].destroy(); } + evictor.deactivate(); System.out.println("ok"); } @@ -221,7 +223,7 @@ public class Client Test.ServantPrx[] servants = new Test.ServantPrx[size]; for(int i = 0; i < size; i++) { - servants[i] = evictor.createServant(i); + servants[i] = evictor.createServant(i, i); test(evictor.getLastSavedValue() == i); } @@ -327,7 +329,7 @@ public class Client // for(int i = 0; i < size; i++) { - servants[i] = evictor.createServant(i); + servants[i] = evictor.createServant(i, i); } // @@ -339,6 +341,7 @@ public class Client evictor.setSize(size); for(int i = 0; i < size; i++) { + servants[i] = evictor.getServant(i); test(servants[i].getValue() == i); } @@ -351,7 +354,7 @@ public class Client // Create new servant - should cause eviction but no // servants should be saved. // - servants[size] = evictor.createServant(size); + servants[size] = evictor.createServant(size, size); test(evictor.getLastSavedValue() == size); test(evictor.getLastEvictedValue() != -1); @@ -374,6 +377,7 @@ public class Client servants[i].destroy(); } + evictor.deactivate(); System.out.println("ok"); } diff --git a/java/test/Freeze/evictor/RemoteEvictorFactoryI.java b/java/test/Freeze/evictor/RemoteEvictorFactoryI.java index cfd2dae5b71..e8d9bc3abd3 100644 --- a/java/test/Freeze/evictor/RemoteEvictorFactoryI.java +++ b/java/test/Freeze/evictor/RemoteEvictorFactoryI.java @@ -55,7 +55,6 @@ public final class RemoteEvictorFactoryI extends Test._RemoteEvictorFactoryDisp } StrategyI strategy = new StrategyI(delegate); Freeze.Evictor evictor = db.createEvictor(strategy); - _adapter.addServantLocator(evictor, name); RemoteEvictorI remoteEvictor = new RemoteEvictorI(_adapter, name, db, strategy, evictor); evictor.installServantInitializer(new Initializer(remoteEvictor, evictor)); diff --git a/java/test/Freeze/evictor/RemoteEvictorI.java b/java/test/Freeze/evictor/RemoteEvictorI.java index 1311865a2bc..67a88df28e4 100644 --- a/java/test/Freeze/evictor/RemoteEvictorI.java +++ b/java/test/Freeze/evictor/RemoteEvictorI.java @@ -21,6 +21,10 @@ public final class RemoteEvictorI extends Test._RemoteEvictorDisp _db = db; _strategy = strategy; _evictor = evictor; + Ice.Communicator communicator = adapter.getCommunicator(); + _evictorAdapter = communicator.createObjectAdapterWithEndpoints(Ice.Util.generateUUID(), "default"); + _evictorAdapter.addServantLocator(evictor, category); + _evictorAdapter.activate(); _lastSavedValue = -1; } @@ -31,14 +35,23 @@ public final class RemoteEvictorI extends Test._RemoteEvictorDisp } public Test.ServantPrx - createServant(int value, Ice.Current current) + createServant(int id, int value, Ice.Current current) { - Ice.Identity id = new Ice.Identity(); - id.category = _category; - id.name = "" + value; + Ice.Identity ident = new Ice.Identity(); + ident.category = _category; + ident.name = "" + id; ServantI servant = new ServantI(this, _evictor, value); - _evictor.createObject(id, servant); - return Test.ServantPrxHelper.uncheckedCast(_adapter.createProxy(id)); + _evictor.createObject(ident, servant); + return Test.ServantPrxHelper.uncheckedCast(_evictorAdapter.createProxy(ident)); + } + + public Test.ServantPrx + getServant(int id, Ice.Current current) + { + Ice.Identity ident = new Ice.Identity(); + ident.category = _category; + ident.name = "" + id; + return Test.ServantPrxHelper.uncheckedCast(_evictorAdapter.createProxy(ident)); } public int @@ -70,7 +83,8 @@ public final class RemoteEvictorI extends Test._RemoteEvictorDisp public void deactivate(Ice.Current current) { - _adapter.removeServantLocator(_category); + _evictorAdapter.deactivate(); + _evictorAdapter.waitForDeactivate(); _adapter.remove(Ice.Util.stringToIdentity(_category)); _db.close(); } @@ -86,5 +100,6 @@ public final class RemoteEvictorI extends Test._RemoteEvictorDisp private Freeze.DB _db; private StrategyI _strategy; private Freeze.Evictor _evictor; + private Ice.ObjectAdapter _evictorAdapter; private int _lastSavedValue; } diff --git a/java/test/Freeze/evictor/Test.ice b/java/test/Freeze/evictor/Test.ice index 1878cf64451..4850f02fec0 100644 --- a/java/test/Freeze/evictor/Test.ice +++ b/java/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(); |