diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/Ice/Proxy.h | 3 | ||||
-rw-r--r-- | cpp/slice/IcePack/Admin.ice | 12 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 21 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.cpp | 13 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.h | 1 | ||||
-rw-r--r-- | cpp/src/IcePack/AdminI.cpp | 27 | ||||
-rw-r--r-- | cpp/src/IcePack/AdminI.h | 6 | ||||
-rw-r--r-- | cpp/src/IcePack/Forward.cpp | 9 | ||||
-rw-r--r-- | cpp/src/IcePack/Parser.cpp | 2 | ||||
-rw-r--r-- | cpp/test/IcePack/simple/AllTests.cpp | 2 | ||||
-rw-r--r-- | cpp/test/IcePack/simple/Client.cpp | 8 | ||||
-rw-r--r-- | cpp/test/IcePack/simple/Collocated.cpp | 2 | ||||
-rw-r--r-- | cpp/test/IcePack/simple/Server.cpp | 2 | ||||
-rwxr-xr-x | cpp/test/IcePack/simple/run.py | 37 |
14 files changed, 102 insertions, 43 deletions
diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index d8a9349ac9a..c63b1677886 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -56,6 +56,9 @@ public: bool operator!=(const Object&) const; bool operator<(const Object&) const; + std::string _getIdentity() const; + ::Ice::ObjectPrx _newIdentity(const std::string&) const; + ::Ice::ObjectPrx _twoway() const; ::Ice::ObjectPrx _oneway() const; ::Ice::ObjectPrx _secure() const; diff --git a/cpp/slice/IcePack/Admin.ice b/cpp/slice/IcePack/Admin.ice index 466eb8deed4..1d36f3a45c0 100644 --- a/cpp/slice/IcePack/Admin.ice +++ b/cpp/slice/IcePack/Admin.ice @@ -122,27 +122,27 @@ class Admin * * Remove a server and objects implemented by that server from &IcePack;. * - * @param object Must match the field <literal>object</literal> of - * the <literal>ServerDescription</literal> data to remove. + * @param identity Must match the identity of the + * <literal>ServerDescription::object</literal>. * * @see add * **/ - void remove(Object* object); + void remove(string identity); /** * * Find a server and objects implemented by that server from &IcePack;. * - * @param object Must match the field <literal>object</literal> of - * the <literal>ServerDescription</literal> data to find. + * @param identity Must match the identity of the + * <literal>ServerDescription::object</literal>. * * @return The server description, or null if no description was found. * * @see add * **/ - ServerDescription find(Object* object); + ServerDescription find(string identity); /** * diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index e818d04df6a..3b3ae6acaa5 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -151,6 +151,27 @@ IceProxy::Ice::Object::operator<(const Object& r) const return _reference->identity < r._reference->identity; } +std::string +IceProxy::Ice::Object::_getIdentity() const +{ + return _reference->identity; +} + +::Ice::ObjectPrx +IceProxy::Ice::Object::_newIdentity(const std::string& newIdentity) const +{ + if (newIdentity == _reference->identity) + { + return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); + } + else + { + ObjectPrx proxy(new ::IceProxy::Ice::Object()); + proxy->setup(_reference->changeIdentity(newIdentity)); + return proxy; + } +} + ObjectPrx IceProxy::Ice::Object::_twoway() const { diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index cf6bc223790..eee6feee1ee 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -203,6 +203,19 @@ IceInternal::Reference::streamWrite(Stream* s) const } ReferencePtr +IceInternal::Reference::changeIdentity(const string& newIdentity) const +{ + if (newIdentity == identity) + { + return ReferencePtr(const_cast<Reference*>(this)); + } + else + { + return new Reference(instance, newIdentity, origEndpoints, endpoints); + } +} + +ReferencePtr IceInternal::Reference::changeTimeout(int timeout) const { vector<EndpointPtr>::const_iterator p; diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index 0453b71e07d..bac2d947c17 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -54,6 +54,7 @@ public: // Get a new reference, based on the existing one, overwriting // certain values. // + ReferencePtr changeIdentity(const std::string&) const; ReferencePtr changeTimeout(int) const; ReferencePtr changeMode(Mode) const; ReferencePtr changeEndpoints(const std::vector<EndpointPtr>&) const; diff --git a/cpp/src/IcePack/AdminI.cpp b/cpp/src/IcePack/AdminI.cpp index b2c56c11bce..4a09e24b281 100644 --- a/cpp/src/IcePack/AdminI.cpp +++ b/cpp/src/IcePack/AdminI.cpp @@ -27,37 +27,26 @@ IcePack::AdminI::add(const ServerDescriptionPtr& p) if (p && p->object) { - _map[p->object] = p; + _map[p->object->_getIdentity()] = p; } } void -IcePack::AdminI::remove(const ObjectPrx& p) +IcePack::AdminI::remove(const string& identity) { JTCSyncT<JTCMutex> sync(*this); - - if (p) - { - _map.erase(p); - } + _map.erase(identity); } ServerDescriptionPtr -IcePack::AdminI::find(const ObjectPrx& p) +IcePack::AdminI::find(const string& identity) { JTCSyncT<JTCMutex> sync(*this); - if (p) + map<string, ServerDescriptionPtr>::iterator p = _map.find(identity); + if (p != _map.end()) { - map<ObjectPrx, ServerDescriptionPtr>::iterator q = _map.find(p); - if (q != _map.end()) - { - return q->second; - } - else - { - return 0; - } + return p->second; } else { @@ -70,7 +59,7 @@ IcePack::AdminI::getAll() { ServerDescriptions result; result.reserve(_map.size()); - for (map<ObjectPrx, ServerDescriptionPtr>::iterator p = _map.begin(); p != _map.end(); ++p) + for (map<string, ServerDescriptionPtr>::iterator p = _map.begin(); p != _map.end(); ++p) { result.push_back(p->second); } diff --git a/cpp/src/IcePack/AdminI.h b/cpp/src/IcePack/AdminI.h index 828de030cd5..591c58fdf84 100644 --- a/cpp/src/IcePack/AdminI.h +++ b/cpp/src/IcePack/AdminI.h @@ -24,15 +24,15 @@ public: AdminI(const Ice::CommunicatorPtr&); virtual void add(const ServerDescriptionPtr&); - virtual void remove(const Ice::ObjectPrx&); - virtual ServerDescriptionPtr find(const Ice::ObjectPrx&); + virtual void remove(const std::string&); + virtual ServerDescriptionPtr find(const std::string&); virtual ServerDescriptions getAll(); virtual void shutdown(); private: Ice::CommunicatorPtr _communicator; - std::map<Ice::ObjectPrx, ServerDescriptionPtr> _map; + std::map<std::string, ServerDescriptionPtr> _map; }; } diff --git a/cpp/src/IcePack/Forward.cpp b/cpp/src/IcePack/Forward.cpp index 91162b5ef3a..a5bbc9197df 100644 --- a/cpp/src/IcePack/Forward.cpp +++ b/cpp/src/IcePack/Forward.cpp @@ -40,8 +40,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity // // Look up the server description // - ObjectPrx proxy = adapter->identityToProxy(identity); - ServerDescriptionPtr desc = _admin->find(proxy); + ServerDescriptionPtr desc = _admin->find(identity); // // If we didn't find a server description, we return null, meaning @@ -52,6 +51,8 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity return 0; } + ObjectPrx object = desc->object; + #ifndef WIN32 // // We only try to activate if we have a path for the server @@ -95,7 +96,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity // server timeout, a crash, or an explicit // shutdown method. // - proxy->_ping(); + object->_ping(); // // Everything ok, the server is now up and @@ -142,7 +143,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity } #endif - throw LocationForward(desc->object); + throw LocationForward(object); } void diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp index 39ea972cd86..1f3febedad8 100644 --- a/cpp/src/IcePack/Parser.cpp +++ b/cpp/src/IcePack/Parser.cpp @@ -87,7 +87,7 @@ IcePack::Parser::remove(const list<string>& args) try { - _admin->remove(_communicator->stringToProxy(args.front())); + _admin->remove(args.front()); } catch(const LocalException& ex) { diff --git a/cpp/test/IcePack/simple/AllTests.cpp b/cpp/test/IcePack/simple/AllTests.cpp index 9d36cf379af..b48bc16f91a 100644 --- a/cpp/test/IcePack/simple/AllTests.cpp +++ b/cpp/test/IcePack/simple/AllTests.cpp @@ -19,7 +19,7 @@ TestPrx allTests(Ice::CommunicatorPtr communicator) { cout << "testing stringToProxy... " << flush; - string ref("test:tcp -p 12346 -t 2000"); + string ref("test:tcp -p 12346 -t 5000"); Ice::ObjectPrx base = communicator->stringToProxy(ref); test(base); cout << "ok" << endl; diff --git a/cpp/test/IcePack/simple/Client.cpp b/cpp/test/IcePack/simple/Client.cpp index 6a73321427d..3ae77a6499d 100644 --- a/cpp/test/IcePack/simple/Client.cpp +++ b/cpp/test/IcePack/simple/Client.cpp @@ -18,8 +18,12 @@ int run(int argc, char* argv[], Ice::CommunicatorPtr communicator) { TestPrx allTests(Ice::CommunicatorPtr); - TestPrx test = allTests(communicator); - test->shutdown(); + TestPrx obj = allTests(communicator); + + cout << "shutting down server... " << flush; + obj->shutdown(); + cout << "ok" << endl; + return EXIT_SUCCESS; } diff --git a/cpp/test/IcePack/simple/Collocated.cpp b/cpp/test/IcePack/simple/Collocated.cpp index 5df83c02733..5c02cfc2e94 100644 --- a/cpp/test/IcePack/simple/Collocated.cpp +++ b/cpp/test/IcePack/simple/Collocated.cpp @@ -16,7 +16,7 @@ using namespace std; int run(int argc, char* argv[], Ice::CommunicatorPtr communicator) { - string endpts("tcp -p 12345 -t 2000"); + string endpts("tcp -p 12345 -t 5000"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("TestAdapter", endpts); Ice::ObjectPtr object = new TestI(adapter); adapter->add(object, "test"); diff --git a/cpp/test/IcePack/simple/Server.cpp b/cpp/test/IcePack/simple/Server.cpp index 075d4a084f4..3ec39518793 100644 --- a/cpp/test/IcePack/simple/Server.cpp +++ b/cpp/test/IcePack/simple/Server.cpp @@ -16,7 +16,7 @@ using namespace std; int run(int argc, char* argv[], Ice::CommunicatorPtr communicator) { - string endpts("tcp -p 12345 -t 2000"); + string endpts("tcp -p 12345 -t 5000"); Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("TestAdapter", endpts); Ice::ObjectPtr object = new TestI(adapter); adapter->add(object, "test"); diff --git a/cpp/test/IcePack/simple/run.py b/cpp/test/IcePack/simple/run.py index 2772753b7ab..6305848431f 100755 --- a/cpp/test/IcePack/simple/run.py +++ b/cpp/test/IcePack/simple/run.py @@ -25,8 +25,8 @@ icePackAdmin = os.path.normpath(toplevel + "/bin/icepackadmin") print "starting icepack...", icePackPipe = os.popen(icePack + ' --Ice.PrintProcessId --nowarn' + \ - r' "--Ice.Adapter.Forward.Endpoints=tcp -p 12346 -t 2000"' + \ - r' "--Ice.Adapter.Admin.Endpoints=tcp -p 12347 -t 2000"') + r' "--Ice.Adapter.Forward.Endpoints=tcp -p 12346 -t 5000"' + \ + r' "--Ice.Adapter.Admin.Endpoints=tcp -p 12347 -t 5000"') output = icePackPipe.readline().strip() if not output: print "failed!" @@ -36,8 +36,8 @@ print "ok" print "registering server with icepack...", icePackAdminPipe = os.popen(icePackAdmin + \ - r' "--Ice.Adapter.Admin.Endpoints=tcp -p 12347 -t 2000"' + \ - r' -e "add \"test:tcp -p 12345 -t 2000\""') + r' "--Ice.Adapter.Admin.Endpoints=tcp -p 12347 -t 5000"' + \ + r' -e "add \"test:tcp -p 12345 -t 5000\""') icePackAdminPipe.close() print "ok" @@ -45,9 +45,36 @@ name = "IcePack/simple" TestUtil.clientServerTest(toplevel, name) TestUtil.collocatedTest(toplevel, name) +if os.name != "nt": + testdir = os.path.normpath(toplevel + "/test/IcePack/simple") + server = os.path.normpath(testdir + "/server") + client = os.path.normpath(testdir + "/client") + + print "registering server with icepack for automatic activation...", + icePackAdminPipe = os.popen(icePackAdmin + \ + r' "--Ice.Adapter.Admin.Endpoints=tcp -p 12347 -t 5000"' + \ + r' -e "add \"test:tcp -p 12345 -t 5000\" \"' + server + r'\""') + icePackAdminPipe.close() + print "ok" + + print "starting client...", + clientPipe = os.popen(client) + output = clientPipe.readline() + if not output: + print "failed!" + TestUtil.killServers() + sys.exit(0) + print "ok" + print output, + while 1: + output = clientPipe.readline() + if not output: + break; + print output, + print "shutting down icepack...", icePackAdminPipe = os.popen(icePackAdmin + \ - r' "--Ice.Adapter.Admin.Endpoints=tcp -p 12347 -t 2000"' + \ + r' "--Ice.Adapter.Admin.Endpoints=tcp -p 12347 -t 5000"' + \ r' -e "shutdown"') icePackAdminPipe.close() print "ok" |