diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-09-19 05:54:42 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-09-19 05:54:42 +0000 |
commit | a11ea64ba4cc566f1928b5df36d4b8114d57e8f0 (patch) | |
tree | b33f8818a35f03fffdc46963639e4302c66b1e64 /java/src | |
parent | minor refactoring (diff) | |
download | ice-a11ea64ba4cc566f1928b5df36d4b8114d57e8f0.tar.bz2 ice-a11ea64ba4cc566f1928b5df36d4b8114d57e8f0.tar.xz ice-a11ea64ba4cc566f1928b5df36d4b8114d57e8f0.zip |
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=435. added
removeRouter().
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/ObjectAdapterI.java | 57 | ||||
-rw-r--r-- | java/src/IceInternal/OutgoingConnectionFactory.java | 104 | ||||
-rw-r--r-- | java/src/IceInternal/RouterManager.java | 17 |
3 files changed, 124 insertions, 54 deletions
diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java index d0e65090264..bd644eddd9b 100644 --- a/java/src/Ice/ObjectAdapterI.java +++ b/java/src/Ice/ObjectAdapterI.java @@ -529,11 +529,65 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt // router's client proxy to use this object adapter for // callbacks. // - _instance.outgoingConnectionFactory().setRouter(routerInfo.getRouter()); + _instance.outgoingConnectionFactory().setRouterInfo(routerInfo); } } public synchronized void + removeRouter(RouterPrx router) + { + checkForDeactivation(); + + IceInternal.RouterInfo routerInfo = _instance.routerManager().erase(router); + if(routerInfo != null) + { + // + // Rebuild the router endpoints from our set of router infos. + // + _routerEndpoints = new java.util.ArrayList(); + java.util.Iterator p = _routerInfos.iterator(); + while(p.hasNext()) + { + IceInternal.RouterInfo curr = (IceInternal.RouterInfo)p.next(); + if(curr == routerInfo) + { + p.remove(); + continue; + } + ObjectPrxHelperBase proxy = (ObjectPrxHelperBase)routerInfo.getServerProxy(); + IceInternal.EndpointI[] endpoints = proxy.__reference().getEndpoints(); + for(int i = 0; i < endpoints.length; ++i) + { + _routerEndpoints.add(endpoints[i]); + } + } + + java.util.Collections.sort(_routerEndpoints); // Must be sorted. + for(int i = 0; i < _routerEndpoints.size() - 1; ++i) + { + java.lang.Object o1 = _routerEndpoints.get(i); + java.lang.Object o2 = _routerEndpoints.get(i + 1); + if(o1.equals(o2)) + { + _routerEndpoints.remove(i); + } + } + + // + // Clear this object adapter with the router. + // + routerInfo.setAdapter(null); + + // + // Also modify all existing outgoing connections to the + // router's client proxy to use this object adapter for + // callbacks. + // + _instance.outgoingConnectionFactory().setRouterInfo(routerInfo); + } + } + + public synchronized void setLocator(LocatorPrx locator) { checkForDeactivation(); @@ -1000,6 +1054,7 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt final private String _id; private java.util.ArrayList _incomingConnectionFactories = new java.util.ArrayList(); private java.util.ArrayList _routerEndpoints = new java.util.ArrayList(); + private java.util.ArrayList _routerInfos = new java.util.ArrayList(); private java.util.ArrayList _publishedEndpoints; private IceInternal.LocatorInfo _locatorInfo; private int _directCount; diff --git a/java/src/IceInternal/OutgoingConnectionFactory.java b/java/src/IceInternal/OutgoingConnectionFactory.java index 05a5473f4b6..0ec64faa614 100644 --- a/java/src/IceInternal/OutgoingConnectionFactory.java +++ b/java/src/IceInternal/OutgoingConnectionFactory.java @@ -398,71 +398,69 @@ public final class OutgoingConnectionFactory } public synchronized void - setRouter(Ice.RouterPrx router) + setRouterInfo(IceInternal.RouterInfo routerInfo) { if(_destroyed) { throw new Ice.CommunicatorDestroyedException(); } - RouterInfo routerInfo = _instance.routerManager().get(router); - if(routerInfo != null) - { - // - // 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. - // - Ice.ObjectPrx proxy = routerInfo.getClientProxy(); - Ice.ObjectAdapter adapter = routerInfo.getAdapter(); - DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides(); - EndpointI[] endpoints = ((Ice.ObjectPrxHelperBase)proxy).__reference().getEndpoints(); - for(int i = 0; i < endpoints.length; i++) - { - EndpointI endpoint = endpoints[i]; + assert(routerInfo != null); - // - // Modify endpoints with overrides. - // - if(defaultsAndOverrides.overrideTimeout) - { - endpoint = endpoint.timeout(defaultsAndOverrides.overrideTimeoutValue); - } + // + // 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. + // + Ice.ObjectPrx proxy = routerInfo.getClientProxy(); + Ice.ObjectAdapter adapter = routerInfo.getAdapter(); + DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides(); + EndpointI[] endpoints = ((Ice.ObjectPrxHelperBase)proxy).__reference().getEndpoints(); + for(int i = 0; i < endpoints.length; i++) + { + EndpointI endpoint = endpoints[i]; - // - // The Connection object does not take the compression flag of - // endpoints into account, but instead gets the information - // about whether messages should be compressed or not from - // other sources. In order to allow connection sharing for - // endpoints that differ in the value of the compression flag - // only, we always set the compression flag to false here in - // this connection factory. - // - endpoint = endpoint.compress(false); + // + // Modify endpoints with overrides. + // + if(defaultsAndOverrides.overrideTimeout) + { + endpoint = endpoint.timeout(defaultsAndOverrides.overrideTimeoutValue); + } - java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(endpoints[i]); - if(connectionList != null) + // + // The Connection object does not take the compression flag of + // endpoints into account, but instead gets the information + // about whether messages should be compressed or not from + // other sources. In order to allow connection sharing for + // endpoints that differ in the value of the compression flag + // only, we always set the compression flag to false here in + // this connection factory. + // + endpoint = endpoint.compress(false); + + java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(endpoints[i]); + if(connectionList != null) + { + java.util.Iterator p = connectionList.iterator(); + + while(p.hasNext()) { - java.util.Iterator p = connectionList.iterator(); - - while(p.hasNext()) + Ice.ConnectionI connection = (Ice.ConnectionI)p.next(); + try { - Ice.ConnectionI connection = (Ice.ConnectionI)p.next(); - try - { - connection.setAdapter(adapter); - } - catch(Ice.LocalException ex) - { - // - // Ignore, the connection is being closed or closed. - // - } + connection.setAdapter(adapter); } - } - } - } + catch(Ice.LocalException ex) + { + // + // Ignore, the connection is being closed or closed. + // + } + } + } + } } public synchronized void diff --git a/java/src/IceInternal/RouterManager.java b/java/src/IceInternal/RouterManager.java index 4dbaeb5a5f3..0fa349216f1 100644 --- a/java/src/IceInternal/RouterManager.java +++ b/java/src/IceInternal/RouterManager.java @@ -54,5 +54,22 @@ public final class RouterManager } } + public RouterInfo + erase(Ice.RouterPrx rtr) + { + RouterInfo info = null; + if(rtr != null) + { + // The router cannot be routed. + Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(rtr.ice_router(null)); + + synchronized(this) + { + info = (RouterInfo)_table.remove(router); + } + } + return info; + } + private java.util.HashMap _table = new java.util.HashMap(); } |