summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2008-03-14 18:47:45 +0100
committerBenoit Foucher <benoit@zeroc.com>2008-03-14 18:47:45 +0100
commit1ec8426013773ceb6b649137b7016793065d6c44 (patch)
treebcdf2e9f0bd4eba61e08aebd61e5801e4fdf04dd /java/src
parentBug 2787 (diff)
downloadice-1ec8426013773ceb6b649137b7016793065d6c44.tar.bz2
ice-1ec8426013773ceb6b649137b7016793065d6c44.tar.xz
ice-1ec8426013773ceb6b649137b7016793065d6c44.zip
Fixed bug 2684 + collocation optimization bug
Diffstat (limited to 'java/src')
-rwxr-xr-xjava/src/IceGridGUI/Coordinator.java90
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/Node.java5
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/Root.java6
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/Server.java15
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/Service.java8
-rw-r--r--java/src/IceGridGUI/LiveDeployment/Slave.java6
-rwxr-xr-xjava/src/IceGridGUI/SessionKeeper.java35
-rw-r--r--java/src/IceInternal/LocatorInfo.java46
-rw-r--r--java/src/IceInternal/RoutableReference.java6
-rw-r--r--java/src/IceInternal/RouterInfo.java33
10 files changed, 149 insertions, 101 deletions
diff --git a/java/src/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/Coordinator.java
index 8d9ebb0400c..fde2343d28f 100755
--- a/java/src/IceGridGUI/Coordinator.java
+++ b/java/src/IceGridGUI/Coordinator.java
@@ -582,6 +582,41 @@ public class Coordinator
}
}
+ static private class ReuseConnectionRouter extends Ice._RouterDisp
+ {
+ public
+ ReuseConnectionRouter(Ice.ObjectPrx proxy)
+ {
+ _clientProxy = proxy;
+ }
+
+ public Ice.ObjectPrx
+ getClientProxy(Ice.Current current)
+ {
+ return _clientProxy;
+ }
+
+ public Ice.ObjectPrx
+ getServerProxy(Ice.Current current)
+ {
+ return null;
+ }
+
+ /** @deprecated **/
+ public void
+ addProxy(Ice.ObjectPrx proxy, Ice.Current current)
+ {
+ }
+
+ public Ice.ObjectPrx[]
+ addProxies(Ice.ObjectPrx[] proxies, Ice.Current current)
+ {
+ return new Ice.ObjectPrx[0];
+ }
+
+ private final Ice.ObjectPrx _clientProxy;
+ };
+
public Ice.Communicator getCommunicator()
{
if(_communicator == null)
@@ -1257,8 +1292,7 @@ public class Coordinator
try
{
- Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.
- uncheckedCast(_communicator.stringToProxy(str));
+ Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.uncheckedCast(_communicator.stringToProxy(str));
//
// The session must be routed through this router
@@ -1268,8 +1302,7 @@ public class Coordinator
Glacier2.SessionPrx s;
if(info.routerUseSSL)
{
- router = Glacier2.RouterPrxHelper.
- uncheckedCast(router.ice_secure(true));
+ router = Glacier2.RouterPrxHelper.uncheckedCast(router.ice_secure(true));
s = router.createSessionFromSecureConnection();
@@ -1288,8 +1321,8 @@ public class Coordinator
}
else
{
- s = router.createSession(
- info.routerUsername, new String(info.routerPassword));
+ router = Glacier2.RouterPrxHelper.uncheckedCast(router.ice_preferSecure(true));
+ s = router.createSession(info.routerUsername, new String(info.routerPassword));
if(s == null)
{
@@ -1363,12 +1396,10 @@ public class Coordinator
str += ":" + info.registryEndpoints;
RegistryPrx currentRegistry = null;
-
+ IceGrid.LocatorPrx defaultLocator = null;
try
{
- IceGrid.LocatorPrx defaultLocator = IceGrid.LocatorPrxHelper.
- checkedCast(_communicator.stringToProxy(str));
-
+ defaultLocator = IceGrid.LocatorPrxHelper.checkedCast(_communicator.stringToProxy(str));
if(defaultLocator == null)
{
JOptionPane.showMessageDialog(
@@ -1381,13 +1412,6 @@ public class Coordinator
currentRegistry = defaultLocator.getLocalRegistry();
- //
- // Make sure the currentRegistry uses the same endpoints as the locator
- // (for when IceGrid Admin is used over a ssh tunnel)
- //
- currentRegistry = RegistryPrxHelper.uncheckedCast(
- currentRegistry.ice_endpoints(defaultLocator.ice_getEndpoints()));
-
_communicator.setDefaultLocator(defaultLocator);
}
catch(Ice.LocalException e)
@@ -1401,7 +1425,6 @@ public class Coordinator
}
RegistryPrx registry = currentRegistry;
-
if(info.connectToMaster && !currentRegistry.ice_getIdentity().name.equals("Registry"))
{
Ice.Identity masterRegistryId = new Ice.Identity();
@@ -1412,6 +1435,22 @@ public class Coordinator
uncheckedCast(_communicator.stringToProxy(
"\"" + _communicator.identityToString(masterRegistryId) + "\""));
}
+
+ //
+ // If the registry to use is the locator local registry, we install a default router
+ // to ensure we'll use a single connection regardless of the endpoints returned in the
+ // proxies of the various session/admin methods (useful if used over an ssh tunnel).
+ //
+ if(registry.ice_getIdentity().equals(currentRegistry.ice_getIdentity()))
+ {
+ Ice.Properties properties = _communicator.getProperties();
+ properties.setProperty("CollocInternal.AdapterId", Ice.Util.generateUUID());
+ Ice.ObjectAdapter colloc = _communicator.createObjectAdapter("CollocInternal");
+ colloc.setLocator(null);
+ Ice.ObjectPrx router = colloc.addWithUUID(new ReuseConnectionRouter(defaultLocator));
+ _communicator.setDefaultRouter(Ice.RouterPrxHelper.uncheckedCast(router));
+ registry = RegistryPrxHelper.uncheckedCast(registry.ice_router(_communicator.getDefaultRouter()));
+ }
do
{
@@ -1419,29 +1458,20 @@ public class Coordinator
{
if(info.registryUseSSL)
{
- registry = RegistryPrxHelper.
- uncheckedCast(registry.ice_secure(true));
+ registry = RegistryPrxHelper.uncheckedCast(registry.ice_secure(true));
session = registry.createAdminSessionFromSecureConnection();
assert session != null;
}
else
{
+ registry = RegistryPrxHelper.uncheckedCast(registry.ice_preferSecure(true));
+
session = registry.createAdminSession(info.registryUsername,
new String(info.registryPassword));
assert session != null;
}
keepAlivePeriodHolder.value = registry.getSessionTimeout() * 1000 / 2;
-
- //
- // Make sure the session uses the same endpoints as the locator
- // (for when IceGrid Admin is used over a ssh tunnel)
- //
- if(registry == currentRegistry)
- {
- session = AdminSessionPrxHelper.uncheckedCast(
- session.ice_endpoints(currentRegistry.ice_getEndpoints()));
- }
}
catch(IceGrid.PermissionDeniedException e)
{
diff --git a/java/src/IceGridGUI/LiveDeployment/Node.java b/java/src/IceGridGUI/LiveDeployment/Node.java
index b65efb3baa2..beee165e4a2 100755
--- a/java/src/IceGridGUI/LiveDeployment/Node.java
+++ b/java/src/IceGridGUI/LiveDeployment/Node.java
@@ -58,11 +58,6 @@ class Node extends ListTreeNode
{
result = session.openNodeStdErr(_id, count);
}
- if(getRoot().getCoordinator().getCommunicator().getDefaultRouter() == null)
- {
- result = FileIteratorPrxHelper.uncheckedCast(
- result.ice_endpoints(session.ice_getEndpoints()));
- }
return result;
}
diff --git a/java/src/IceGridGUI/LiveDeployment/Root.java b/java/src/IceGridGUI/LiveDeployment/Root.java
index c3106643c98..be4557922ce 100755
--- a/java/src/IceGridGUI/LiveDeployment/Root.java
+++ b/java/src/IceGridGUI/LiveDeployment/Root.java
@@ -932,12 +932,6 @@ public class Root extends ListArrayTreeNode
{
result = session.openRegistryStdErr(_replicaName, count);
}
-
- if(_coordinator.getCommunicator().getDefaultRouter() == null)
- {
- result = FileIteratorPrxHelper.uncheckedCast(
- result.ice_endpoints(session.ice_getEndpoints()));
- }
return result;
}
diff --git a/java/src/IceGridGUI/LiveDeployment/Server.java b/java/src/IceGridGUI/LiveDeployment/Server.java
index 7845e16db8d..a9ac2d67c1e 100755
--- a/java/src/IceGridGUI/LiveDeployment/Server.java
+++ b/java/src/IceGridGUI/LiveDeployment/Server.java
@@ -190,11 +190,6 @@ class Server extends ListArrayTreeNode
{
result = session.openServerStdErr(_id, count);
}
- if(getRoot().getCoordinator().getCommunicator().getDefaultRouter() == null)
- {
- result = FileIteratorPrxHelper.uncheckedCast(
- result.ice_endpoints(session.ice_getEndpoints()));
- }
return result;
}
@@ -247,14 +242,7 @@ class Server extends ListArrayTreeNode
DeploymentException
{
AdminSessionPrx session = getRoot().getCoordinator().getSession();
- FileIteratorPrx result = session.openServerLog(_id, fPath, count);
-
- if(getRoot().getCoordinator().getCommunicator().getDefaultRouter() == null)
- {
- result = FileIteratorPrxHelper.uncheckedCast(
- result.ice_endpoints(session.ice_getEndpoints()));
- }
- return result;
+ return session.openServerLog(_id, fPath, count);
}
public String getTitle()
@@ -456,6 +444,7 @@ class Server extends ListArrayTreeNode
}
else
{
+ e.printStackTrace();
_editor.setBuildId("Error: " + e.toString(), Server.this);
}
}
diff --git a/java/src/IceGridGUI/LiveDeployment/Service.java b/java/src/IceGridGUI/LiveDeployment/Service.java
index c254d88d900..bceae0538f3 100755
--- a/java/src/IceGridGUI/LiveDeployment/Service.java
+++ b/java/src/IceGridGUI/LiveDeployment/Service.java
@@ -194,13 +194,7 @@ class Service extends ListArrayTreeNode
DeploymentException
{
AdminSessionPrx session = getRoot().getCoordinator().getSession();
- FileIteratorPrx result = session.openServerLog(_parent.getId(), fPath, count);
- if(getRoot().getCoordinator().getCommunicator().getDefaultRouter() == null)
- {
- result = FileIteratorPrxHelper.uncheckedCast(
- result.ice_endpoints(session.ice_getEndpoints()));
- }
- return result;
+ return session.openServerLog(_parent.getId(), fPath, count);
}
public String getTitle()
diff --git a/java/src/IceGridGUI/LiveDeployment/Slave.java b/java/src/IceGridGUI/LiveDeployment/Slave.java
index 081a2be7216..ab2d0fb700a 100644
--- a/java/src/IceGridGUI/LiveDeployment/Slave.java
+++ b/java/src/IceGridGUI/LiveDeployment/Slave.java
@@ -99,12 +99,6 @@ class Slave extends TreeNode
{
result = session.openRegistryStdErr(_id, count);
}
-
- if(getCoordinator().getCommunicator().getDefaultRouter() == null)
- {
- result = FileIteratorPrxHelper.uncheckedCast(
- result.ice_endpoints(session.ice_getEndpoints()));
- }
return result;
}
diff --git a/java/src/IceGridGUI/SessionKeeper.java b/java/src/IceGridGUI/SessionKeeper.java
index 4e2fc1e6cf5..1168731f2af 100755
--- a/java/src/IceGridGUI/SessionKeeper.java
+++ b/java/src/IceGridGUI/SessionKeeper.java
@@ -49,7 +49,7 @@ class SessionKeeper
//
private class Session
{
- Session(AdminSessionPrx session, long keepAliveperiod, Component parent)
+ Session(AdminSessionPrx session, long keepAliveperiod, boolean routed, Component parent)
{
_session = session;
@@ -68,14 +68,9 @@ class SessionKeeper
throw e;
}
- if(_coordinator.getCommunicator().getDefaultRouter() == null)
- {
- _admin = AdminPrxHelper.uncheckedCast(_admin.ice_endpoints(session.ice_getEndpoints()));
- }
-
try
{
- if(_coordinator.getCommunicator().getDefaultRouter() == null)
+ if(!routed)
{
Ice.ObjectPrx adminCallbackTemplate = _session.getAdminCallbackTemplate();
@@ -97,7 +92,8 @@ class SessionKeeper
publishedEndpoints += ":" + endpointString;
}
}
- _coordinator.getCommunicator().getProperties().setProperty("CallbackAdapter.PublishedEndpoints", publishedEndpoints);
+ _coordinator.getCommunicator().getProperties().setProperty(
+ "CallbackAdapter.PublishedEndpoints", publishedEndpoints);
}
}
_serverAdminCategory = _admin.getServerAdminCategory();
@@ -119,7 +115,7 @@ class SessionKeeper
try
{
- registerObservers();
+ registerObservers(routed);
}
catch(Ice.LocalException e)
{
@@ -236,33 +232,31 @@ class SessionKeeper
_coordinator.getStatusBar().setConnected(false);
}
- private void registerObservers()
+ private void registerObservers(boolean routed)
{
//
// Create the object adapter for the observers
//
String category;
- Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.uncheckedCast(
- _coordinator.getCommunicator().getDefaultRouter());
- if(router == null)
+ if(!routed)
{
category = "observer";
String adapterName = _adminCallbackCategory == null ? "" : "CallbackAdapter";
- _adapter =
- _coordinator.getCommunicator().createObjectAdapter(adapterName);
+ _adapter = _coordinator.getCommunicator().createObjectAdapter(adapterName);
_adapter.activate();
_session.ice_getConnection().setAdapter(_adapter);
}
else
{
+ Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.uncheckedCast(
+ _coordinator.getCommunicator().getDefaultRouter());
category = router.getCategoryForClient();
_adminCallbackCategory = category;
- _adapter =
- _coordinator.getCommunicator().createObjectAdapterWithRouter("RoutedAdapter", router);
+ _adapter = _coordinator.getCommunicator().createObjectAdapterWithRouter("RoutedAdapter", router);
_adapter.activate();
}
@@ -310,7 +304,7 @@ class SessionKeeper
try
{
- if(router != null)
+ if(routed)
{
_session.setObservers(registryObserver,
nodeObserver,
@@ -1242,8 +1236,7 @@ class SessionKeeper
Ice.LongHolder keepAlivePeriodHolder = new Ice.LongHolder();
- AdminSessionPrx session = _coordinator.login(
- _loginInfo, parent, keepAlivePeriodHolder);
+ AdminSessionPrx session = _coordinator.login(_loginInfo, parent, keepAlivePeriodHolder);
if(session == null)
{
return false;
@@ -1277,7 +1270,7 @@ class SessionKeeper
try
{
- _session = new Session(session, keepAlivePeriodHolder.value, parent);
+ _session = new Session(session, keepAlivePeriodHolder.value, _loginInfo.routed, parent);
}
catch(Ice.LocalException e)
{
diff --git a/java/src/IceInternal/LocatorInfo.java b/java/src/IceInternal/LocatorInfo.java
index 67971859ba9..40c59bbd946 100644
--- a/java/src/IceInternal/LocatorInfo.java
+++ b/java/src/IceInternal/LocatorInfo.java
@@ -236,7 +236,22 @@ public final class LocatorInfo
public void
ice_exception(Ice.LocalException ex)
{
- getEndpointsException(ref, ex, callback);
+ if(ex instanceof Ice.CollocationOptimizationException)
+ {
+ try
+ {
+ Ice.BooleanHolder cached = new Ice.BooleanHolder();
+ callback.setEndpoints(getEndpoints(ref, ttl, cached), cached.value);
+ }
+ catch(Ice.LocalException e)
+ {
+ callback.setException(e);
+ }
+ }
+ else
+ {
+ getEndpointsException(ref, ex, callback);
+ }
}
}, adapterId);
return;
@@ -281,7 +296,22 @@ public final class LocatorInfo
public void
ice_exception(Ice.LocalException ex)
{
- getEndpointsException(ref, ex, callback);
+ if(ex instanceof Ice.CollocationOptimizationException)
+ {
+ try
+ {
+ Ice.BooleanHolder cached = new Ice.BooleanHolder();
+ callback.setEndpoints(getEndpoints(ref, ttl, cached), cached.value);
+ }
+ catch(Ice.LocalException e)
+ {
+ callback.setException(e);
+ }
+ }
+ else
+ {
+ getEndpointsException(ref, ex, callback);
+ }
}
}, identity);
return;
@@ -499,12 +529,12 @@ public final class LocatorInfo
_table.addProxy(ref.getIdentity(), object);
}
- if(ref.getInstance().traceLevels().location >= 1)
- {
- getEndpointsTrace(ref, endpoints, objectCached || endpointsCached);
- }
-
- callback.setEndpoints(endpoints, objectCached || endpointsCached);
+ if(ref.getInstance().traceLevels().location >= 1)
+ {
+ getEndpointsTrace(ref, endpoints, objectCached || endpointsCached);
+ }
+
+ callback.setEndpoints(endpoints, objectCached || endpointsCached);
}
public void
diff --git a/java/src/IceInternal/RoutableReference.java b/java/src/IceInternal/RoutableReference.java
index a16fffe72c6..8113eea9dae 100644
--- a/java/src/IceInternal/RoutableReference.java
+++ b/java/src/IceInternal/RoutableReference.java
@@ -817,7 +817,7 @@ public class RoutableReference extends Reference
// (if any) to the new connection, so that callbacks from the
// router can be received over this new connection.
//
- if(_routerInfo != null)
+ if(_routerInfo != null && _routerInfo.getAdapter() != null)
{
connection.setAdapter(_routerInfo.getAdapter());
}
@@ -856,7 +856,7 @@ public class RoutableReference extends Reference
// (if any) to the new connection, so that callbacks from the
// router can be received over this new connection.
//
- if(_routerInfo != null)
+ if(_routerInfo != null && _routerInfo.getAdapter() != null)
{
connection.setAdapter(_routerInfo.getAdapter());
}
@@ -891,7 +891,7 @@ public class RoutableReference extends Reference
// (if any) to the new connection, so that callbacks from the
// router can be received over this new connection.
//
- if(_routerInfo != null)
+ if(_routerInfo != null && _routerInfo.getAdapter() != null)
{
connection.setAdapter(_routerInfo.getAdapter());
}
diff --git a/java/src/IceInternal/RouterInfo.java b/java/src/IceInternal/RouterInfo.java
index b266d65b1c0..2adae792f56 100644
--- a/java/src/IceInternal/RouterInfo.java
+++ b/java/src/IceInternal/RouterInfo.java
@@ -105,7 +105,21 @@ public final class RouterInfo
public void
ice_exception(Ice.LocalException ex)
{
- callback.setException(ex);
+ if(ex instanceof Ice.CollocationOptimizationException)
+ {
+ try
+ {
+ callback.setEndpoints(getClientEndpoints());
+ }
+ catch(Ice.LocalException e)
+ {
+ callback.setException(e);
+ }
+ }
+ else
+ {
+ callback.setException(ex);
+ }
}
});
}
@@ -169,7 +183,22 @@ public final class RouterInfo
public void
ice_exception(Ice.LocalException ex)
{
- callback.setException(ex);
+ if(ex instanceof Ice.CollocationOptimizationException)
+ {
+ try
+ {
+ addProxy(proxy);
+ callback.addedProxy();
+ }
+ catch(Ice.LocalException e)
+ {
+ callback.setException(ex);
+ }
+ }
+ else
+ {
+ callback.setException(ex);
+ }
}
},
new Ice.ObjectPrx[] { proxy });