diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2006-04-10 12:36:07 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2006-04-10 12:36:07 +0000 |
commit | 44e9b26499e9e907176af9011e535a32cc0239b0 (patch) | |
tree | 9a2ead95f1edd81f003af5ae90381dd02edf60fe /java/src | |
parent | Ported fix for bug 540 (diff) | |
download | ice-44e9b26499e9e907176af9011e535a32cc0239b0.tar.bz2 ice-44e9b26499e9e907176af9011e535a32cc0239b0.tar.xz ice-44e9b26499e9e907176af9011e535a32cc0239b0.zip |
Port fix for bug 540
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/RoutingTable.java | 76 | ||||
-rw-r--r-- | java/src/IceInternal/ProxyFactory.java | 46 | ||||
-rw-r--r-- | java/src/IceInternal/RouterInfo.java | 39 | ||||
-rw-r--r-- | java/src/IceInternal/RoutingTable.java | 59 |
4 files changed, 62 insertions, 158 deletions
diff --git a/java/src/Ice/RoutingTable.java b/java/src/Ice/RoutingTable.java deleted file mode 100644 index 0976ab10431..00000000000 --- a/java/src/Ice/RoutingTable.java +++ /dev/null @@ -1,76 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -package Ice; - -public final class RoutingTable -{ - public - RoutingTable() - { - } - - // - // Clear the contents of the routing table. - // - synchronized public void - clear() - { - _table.clear(); - } - - // - // Returns false if the Proxy exists already. - // - public boolean - add(ObjectPrx prx) - { - if(prx == null) - { - return false; - } - - // - // We insert the proxy in its default form into the routing table. - // - ObjectPrx proxy = prx.ice_twoway().ice_secure(false); - - synchronized(this) - { - if(!_table.containsKey(proxy.ice_getIdentity())) - { - _table.put(proxy.ice_getIdentity(), proxy); - return true; - } - else - { - return false; - } - } - } - - // - // Returns null if no Proxy exists for the given identity. - // - public ObjectPrx - get(Identity ident) - { - if(ident.name.length() == 0) - { - return null; - } - - synchronized(this) - { - return (ObjectPrx)_table.get(ident); - } - } - - private java.util.HashMap _table = new java.util.HashMap(); -} diff --git a/java/src/IceInternal/ProxyFactory.java b/java/src/IceInternal/ProxyFactory.java index 4db252530c7..a4cfbd9bc4f 100644 --- a/java/src/IceInternal/ProxyFactory.java +++ b/java/src/IceInternal/ProxyFactory.java @@ -79,19 +79,46 @@ public final class ProxyFactory public int checkRetryAfterException(Ice.LocalException ex, Reference ref, int cnt) { - // - // We retry ObjectNotExistException if the reference is - // indirect. Otherwise, we don't retry other *NotExistException, - // which are all derived from RequestFailedException. - // + TraceLevels traceLevels = _instance.traceLevels(); + Ice.Logger logger = _instance.initializationData().logger; + if(ex instanceof Ice.ObjectNotExistException) { + Ice.ObjectNotExistException one = (Ice.ObjectNotExistException)ex; + LocatorInfo li = ref.getLocatorInfo(); - if(li == null) + if(li != null) + { + // + // We retry ObjectNotExistException if the reference is + // indirect. + // + li.clearObjectCache((IceInternal.IndirectReference)ref); + } + else if(ref.getRouterInfo() != null && one.operation.equals("ice_add_proxy")) + { + // + // If we have a router, an ObjectNotExistException with an + // operation name "ice_add_proxy" indicates to the client + // that the router isn't aware of the proxy (for example, + // because it was evicted by the router). In this case, we + // must *always* retry, so that the missing proxy is added + // to the router. + // + if(traceLevels.retry >= 1) + { + String s = "retrying operation call to add proxy to router\n" + ex.toString(); + logger.trace(traceLevels.retryCat, s); + } + return cnt; // We must always retry, so we don't look at the retry count. + } + else { + // + // For all other cases, we don't retry ObjectNotExistException. + // throw ex; } - li.clearObjectCache((IceInternal.IndirectReference)ref); } else if(ex instanceof Ice.RequestFailedException) { @@ -128,9 +155,6 @@ public final class ProxyFactory ++cnt; assert(cnt > 0); - TraceLevels traceLevels = _instance.traceLevels(); - Ice.Logger logger = _instance.initializationData().logger; - if(cnt > _retryIntervals.length) { if(traceLevels.retry >= 1) @@ -145,7 +169,7 @@ public final class ProxyFactory if(traceLevels.retry >= 1) { - String s = "re-trying operation call"; + String s = "retrying operation call"; if(interval > 0) { s += " in " + interval + "ms"; diff --git a/java/src/IceInternal/RouterInfo.java b/java/src/IceInternal/RouterInfo.java index c4addcc20a5..5c3b36c17b3 100644 --- a/java/src/IceInternal/RouterInfo.java +++ b/java/src/IceInternal/RouterInfo.java @@ -14,7 +14,6 @@ public final class RouterInfo RouterInfo(Ice.RouterPrx router) { _router = router; - _routingTable = new RoutingTable(); assert(_router != null); } @@ -25,7 +24,7 @@ public final class RouterInfo _clientProxy = null; _serverProxy = null; _adapter = null; - _routingTable.clear(); + _identities.clear(); } public boolean @@ -127,17 +126,33 @@ public final class RouterInfo _serverProxy = serverProxy.ice_router(null); // The server proxy cannot be routed. } - public void + public synchronized void addProxy(Ice.ObjectPrx proxy) { - // - // No mutex lock necessary, _routingTable is immutable, and - // RoutingTable is mutex protected. - // - if(_routingTable.add(proxy)) // Only add the proxy to the router if it's not already in the routing table. - { - _router.addProxy(proxy); - } + assert(proxy != null); + + if(!_identities.contains(proxy.ice_getIdentity())) + { + // + // Only add the proxy to the router if it's not already in our local map. + // + Ice.ObjectPrx[] proxies = new Ice.ObjectPrx[1]; + proxies[0] = proxy; + Ice.ObjectPrx[] evictedProxies = _router.addProxies(proxies); + + // + // If we successfully added the proxy to the router, we add it to our local map. + // + _identities.add(proxy.ice_getIdentity()); + + // + // We also must remove whatever proxies the router evicted. + // + for(int i = 0; i < evictedProxies.length; ++i) + { + _identities.remove(evictedProxies[i].ice_getIdentity()); + } + } } public synchronized void @@ -155,6 +170,6 @@ public final class RouterInfo private final Ice.RouterPrx _router; private Ice.ObjectPrx _clientProxy; private Ice.ObjectPrx _serverProxy; - private final RoutingTable _routingTable; private Ice.ObjectAdapter _adapter; + private java.util.HashSet _identities = new java.util.HashSet(); } diff --git a/java/src/IceInternal/RoutingTable.java b/java/src/IceInternal/RoutingTable.java deleted file mode 100644 index 0b459a0588f..00000000000 --- a/java/src/IceInternal/RoutingTable.java +++ /dev/null @@ -1,59 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -package IceInternal; - -public final class RoutingTable -{ - public - RoutingTable() - { - } - - // - // Clear the contents of the routing table. - // - synchronized public void - clear() - { - _table.clear(); - } - - // - // Returns false if the Proxy exists already. - // - public boolean - add(Ice.ObjectPrx prx) - { - if(prx == null) - { - return false; - } - - // - // We insert the proxy in its default form into the routing table. - // - Ice.ObjectPrx proxy = prx.ice_twoway().ice_secure(false); - - synchronized(this) - { - if(!_table.containsKey(proxy.ice_getIdentity())) - { - _table.put(proxy.ice_getIdentity(), proxy); - return true; - } - else - { - return false; - } - } - } - - private java.util.HashMap _table = new java.util.HashMap(); -} |