summaryrefslogtreecommitdiff
path: root/cppe/src
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2005-09-19 07:23:38 +0000
committerMatthew Newhook <matthew@zeroc.com>2005-09-19 07:23:38 +0000
commitb93783c5787ebf9bc9ef3d6579d389bcc7af9398 (patch)
tree913efa3db1c22775c54f174d52db42a34913d057 /cppe/src
parenthttp://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=459 (diff)
downloadice-b93783c5787ebf9bc9ef3d6579d389bcc7af9398.tar.bz2
ice-b93783c5787ebf9bc9ef3d6579d389bcc7af9398.tar.xz
ice-b93783c5787ebf9bc9ef3d6579d389bcc7af9398.zip
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=435. added
removeRouter().
Diffstat (limited to 'cppe/src')
-rw-r--r--cppe/src/IceE/ObjectAdapter.cpp49
-rwxr-xr-xcppe/src/IceE/OutgoingConnectionFactory.cpp73
-rwxr-xr-xcppe/src/IceE/OutgoingConnectionFactory.h4
-rw-r--r--cppe/src/IceE/RouterInfo.cpp31
-rw-r--r--cppe/src/IceE/RouterInfo.h1
-rw-r--r--cppe/src/IceE/RouterInfoF.h36
6 files changed, 117 insertions, 77 deletions
diff --git a/cppe/src/IceE/ObjectAdapter.cpp b/cppe/src/IceE/ObjectAdapter.cpp
index 724a7f2737e..878e9934f09 100644
--- a/cppe/src/IceE/ObjectAdapter.cpp
+++ b/cppe/src/IceE/ObjectAdapter.cpp
@@ -450,6 +450,8 @@ Ice::ObjectAdapter::addRouter(const RouterPrx& router)
RouterInfoPtr routerInfo = _instance->routerManager()->get(router);
if(routerInfo)
{
+ _routerInfos.push_back(routerInfo);
+
//
// Add the router's server proxy endpoints to this object
// adapter.
@@ -472,7 +474,52 @@ Ice::ObjectAdapter::addRouter(const RouterPrx& router)
// router's client proxy to use this object adapter for
// callbacks.
//
- _instance->outgoingConnectionFactory()->setRouter(routerInfo->getRouter());
+ _instance->outgoingConnectionFactory()->setRouterInfo(routerInfo);
+ }
+}
+
+void
+Ice::ObjectAdapter::removeRouter(const RouterPrx& router)
+{
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ checkForDeactivation();
+
+ RouterInfoPtr routerInfo = _instance->routerManager()->erase(router);
+ if(routerInfo)
+ {
+ //
+ // Rebuild the router endpoints from our set of router infos.
+ //
+ _routerEndpoints.clear();
+ vector<RouterInfoPtr>::iterator p = _routerInfos.begin();
+ while(p != _routerInfos.end())
+ {
+ if(*p == routerInfo)
+ {
+ p = _routerInfos.erase(p);
+ continue;
+ }
+ ObjectPrx proxy = (*p)->getServerProxy();
+ vector<EndpointPtr> endpoints = proxy->__reference()->getEndpoints();
+ copy(endpoints.begin(), endpoints.end(), back_inserter(_routerEndpoints));
+ ++p;
+ }
+
+ sort(_routerEndpoints.begin(), _routerEndpoints.end()); // Must be sorted.
+ _routerEndpoints.erase(unique(_routerEndpoints.begin(), _routerEndpoints.end()), _routerEndpoints.end());
+
+ //
+ // Clear this object adapter with the router.
+ //
+ routerInfo->setAdapter(0);
+
+ //
+ // Also modify all existing outgoing connections to the
+ // router's client proxy to use this object adapter for
+ // callbacks.
+ //
+ _instance->outgoingConnectionFactory()->setRouterInfo(routerInfo);
}
}
#endif
diff --git a/cppe/src/IceE/OutgoingConnectionFactory.cpp b/cppe/src/IceE/OutgoingConnectionFactory.cpp
index 9d3fcf18e6c..cdf0fe582e7 100755
--- a/cppe/src/IceE/OutgoingConnectionFactory.cpp
+++ b/cppe/src/IceE/OutgoingConnectionFactory.cpp
@@ -331,7 +331,7 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointPtr>& endpts
#ifdef ICEE_HAS_ROUTER
void
-IceInternal::OutgoingConnectionFactory::setRouter(const RouterPrx& router)
+IceInternal::OutgoingConnectionFactory::setRouterInfo(const RouterInfoPtr& routerInfo)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
@@ -340,53 +340,50 @@ IceInternal::OutgoingConnectionFactory::setRouter(const RouterPrx& router)
throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
- RouterInfoPtr routerInfo = _instance->routerManager()->get(router);
- if(routerInfo)
+ assert(routerInfo);
+ //
+ // Search for connections to the router's client proxy
+ // endpoints, and update the object adapter for such
+ // connections, so that callbacks from the router can be
+ // received over such connections.
+ //
+ ObjectPrx proxy = routerInfo->getClientProxy();
+#ifndef ICEE_PURE_CLIENT
+ ObjectAdapterPtr adapter = routerInfo->getAdapter();
+#endif
+ vector<EndpointPtr> endpoints = proxy->__reference()->getEndpoints();
+ vector<EndpointPtr>::const_iterator p;
+ for(p = endpoints.begin(); p != endpoints.end(); ++p)
{
+ EndpointPtr endpoint = *p;
+
//
- // Search for connections to the router's client proxy
- // endpoints, and update the object adapter for such
- // connections, so that callbacks from the router can be
- // received over such connections.
+ // Modify endpoints with overrides.
//
- ObjectPrx proxy = routerInfo->getClientProxy();
-#ifndef ICEE_PURE_CLIENT
- ObjectAdapterPtr adapter = routerInfo->getAdapter();
-#endif
- vector<EndpointPtr> endpoints = proxy->__reference()->getEndpoints();
- vector<EndpointPtr>::const_iterator p;
- for(p = endpoints.begin(); p != endpoints.end(); ++p)
+ if(_instance->defaultsAndOverrides()->overrideTimeout)
{
- EndpointPtr endpoint = *p;
+ endpoint = endpoint->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
+ }
- //
- // Modify endpoints with overrides.
- //
- if(_instance->defaultsAndOverrides()->overrideTimeout)
+#ifndef ICEE_PURE_CLIENT
+ pair<multimap<EndpointPtr, ConnectionPtr>::iterator,
+ multimap<EndpointPtr, ConnectionPtr>::iterator> pr = _connections.equal_range(endpoint);
+
+ while(pr.first != pr.second)
+ {
+ try
{
- endpoint = endpoint->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
+ pr.first->second->setAdapter(adapter);
}
-
-#ifndef ICEE_PURE_CLIENT
- pair<multimap<EndpointPtr, ConnectionPtr>::iterator,
- multimap<EndpointPtr, ConnectionPtr>::iterator> pr = _connections.equal_range(endpoint);
-
- while(pr.first != pr.second)
+ catch(const Ice::LocalException&)
{
- try
- {
- pr.first->second->setAdapter(adapter);
- }
- catch(const Ice::LocalException&)
- {
- //
- // Ignore, the connection is being closed or closed.
- //
- }
- ++pr.first;
+ //
+ // Ignore, the connection is being closed or closed.
+ //
}
-#endif
+ ++pr.first;
}
+#endif
}
}
diff --git a/cppe/src/IceE/OutgoingConnectionFactory.h b/cppe/src/IceE/OutgoingConnectionFactory.h
index b4851d65a48..c14c9ecdb2e 100755
--- a/cppe/src/IceE/OutgoingConnectionFactory.h
+++ b/cppe/src/IceE/OutgoingConnectionFactory.h
@@ -16,7 +16,7 @@
#include <IceE/ObjectAdapterF.h>
#include <IceE/EndpointF.h>
#ifdef ICEE_HAS_ROUTER
-# include <IceE/RouterF.h>
+# include <IceE/RouterInfoF.h>
#endif
#include <IceE/Shared.h>
#include <IceE/Mutex.h>
@@ -36,7 +36,7 @@ public:
Ice::ConnectionPtr create(const std::vector<EndpointPtr>&);
#ifdef ICEE_HAS_ROUTER
- void setRouter(const ::Ice::RouterPrx&);
+ void setRouterInfo(const RouterInfoPtr&);
#endif
void removeAdapter(const ::Ice::ObjectAdapterPtr&);
#ifdef ICEE_HAS_BATCH
diff --git a/cppe/src/IceE/RouterInfo.cpp b/cppe/src/IceE/RouterInfo.cpp
index 130166f4e23..6c0e16f16cf 100644
--- a/cppe/src/IceE/RouterInfo.cpp
+++ b/cppe/src/IceE/RouterInfo.cpp
@@ -83,6 +83,37 @@ IceInternal::RouterManager::get(const RouterPrx& rtr)
return _tableHint->second;
}
+RouterInfoPtr
+IceInternal::RouterManager::erase(const RouterPrx& rtr)
+{
+ RouterInfoPtr info;
+ if(rtr)
+ {
+ RouterPrx router = RouterPrx::uncheckedCast(rtr->ice_router(0)); // The router cannot be routed.
+ IceUtil::Mutex::Lock sync(*this);
+
+ map<RouterPrx, RouterInfoPtr>::iterator p = _table.end();
+ if(_tableHint != _table.end() && _tableHint->first == router)
+ {
+ p = _tableHint;
+ _tableHint = _table.end();
+ }
+
+ if(p == _table.end())
+ {
+ p = _table.find(router);
+ }
+
+ if(p != _table.end())
+ {
+ info = p->second;
+ _table.erase(p);
+ }
+ }
+
+ return info;
+}
+
IceInternal::RouterInfo::RouterInfo(const RouterPrx& router) :
_router(router),
_routingTable(new RoutingTable)
diff --git a/cppe/src/IceE/RouterInfo.h b/cppe/src/IceE/RouterInfo.h
index e641a132943..04d7bbe7f95 100644
--- a/cppe/src/IceE/RouterInfo.h
+++ b/cppe/src/IceE/RouterInfo.h
@@ -39,6 +39,7 @@ public:
// the router info if it doesn't exist yet.
//
RouterInfoPtr get(const Ice::RouterPrx&);
+ RouterInfoPtr erase(const Ice::RouterPrx&);
private:
diff --git a/cppe/src/IceE/RouterInfoF.h b/cppe/src/IceE/RouterInfoF.h
deleted file mode 100644
index 33f02b33a01..00000000000
--- a/cppe/src/IceE/RouterInfoF.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice-E is licensed to you under the terms described in the
-// ICEE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#ifndef ICEE_ROUTER_INFO_F_H
-#define ICEE_ROUTER_INFO_F_H
-
-#include <IceE/Config.h>
-
-#ifdef ICEE_HAS_ROUTER
-
-#include <IceE/Handle.h>
-
-namespace IceInternal
-{
-
-class RouterManager;
-void incRef(RouterManager*);
-void decRef(RouterManager*);
-typedef Handle<RouterManager> RouterManagerPtr;
-
-class RouterInfo;
-void incRef(RouterInfo*);
-void decRef(RouterInfo*);
-typedef Handle<RouterInfo> RouterInfoPtr;
-
-}
-
-#endif
-
-#endif