diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2007-05-18 13:34:42 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2007-05-18 13:34:42 +0000 |
commit | 3f53f8f12436f8c731a11cbb78738d34037d2dac (patch) | |
tree | b14241e46b8877c5b7db79149ebfee21e9906f4e /java/src/IceInternal/OutgoingConnectionFactory.java | |
parent | Multi-home host support (diff) | |
download | ice-3f53f8f12436f8c731a11cbb78738d34037d2dac.tar.bz2 ice-3f53f8f12436f8c731a11cbb78738d34037d2dac.tar.xz ice-3f53f8f12436f8c731a11cbb78738d34037d2dac.zip |
Multi-home post support
Diffstat (limited to 'java/src/IceInternal/OutgoingConnectionFactory.java')
-rw-r--r-- | java/src/IceInternal/OutgoingConnectionFactory.java | 85 |
1 files changed, 64 insertions, 21 deletions
diff --git a/java/src/IceInternal/OutgoingConnectionFactory.java b/java/src/IceInternal/OutgoingConnectionFactory.java index 8e64eb846e6..93d6e032232 100644 --- a/java/src/IceInternal/OutgoingConnectionFactory.java +++ b/java/src/IceInternal/OutgoingConnectionFactory.java @@ -91,7 +91,8 @@ public final class OutgoingConnectionFactory } public Ice.ConnectionI - create(EndpointI[] endpts, boolean hasMore, boolean threadPerConnection, Ice.BooleanHolder compress) + create(EndpointI[] endpts, boolean hasMore, boolean threadPerConnection, Ice.EndpointSelectionType selType, + Ice.BooleanHolder compress) { assert(endpts.length > 0); EndpointI[] endpoints = new EndpointI[endpts.length]; @@ -301,13 +302,22 @@ public final class OutgoingConnectionFactory try { - Transceiver transceiver = endpoint.clientTransceiver(); - if(transceiver == null) + java.util.ArrayList connectors = null; + int size; + int timeout = -1; + + java.util.ArrayList transceivers = endpoint.clientTransceivers(); + if(transceivers.size() == 0) { - Connector connector = endpoint.connector(); - assert(connector != null); + connectors = endpoint.connectors(); + size = connectors.size(); + assert(size > 0); + + if(selType == Ice.EndpointSelectionType.Random) + { + java.util.Collections.shuffle(connectors); + } - int timeout; if(defaultsAndOverrides.overrideConnectTimeout) { timeout = defaultsAndOverrides.overrideConnectTimeoutValue; @@ -319,13 +329,56 @@ public final class OutgoingConnectionFactory { timeout = endpoint.timeout(); } + } + else + { + size = transceivers.size(); + if(selType == Ice.EndpointSelectionType.Random) + { + java.util.Collections.shuffle(transceivers); + } + } + + for(int j = 0; j < size; ++j) + { + try + { + Transceiver transceiver; + if(transceivers.size() == size) + { + transceiver = (Transceiver)transceivers.get(j); + } + else + { + transceiver = ((Connector)connectors.get(j)).connect(timeout); + assert(transceiver != null); + } + + connection = new Ice.ConnectionI(_instance, transceiver, endpoint, null, threadPerConnection); + connection.start(); + connection.validate(); + } + catch(Ice.LocalException ex) + { + // + // If a connection object was constructed, then validate() + // must have raised the exception. + // + if(connection != null) + { + connection.waitUntilFinished(); // We must call waitUntilFinished() for cleanup. + connection = null; + } - transceiver = connector.connect(timeout); - assert(transceiver != null); + // + // Throw exception if this is last transceiver in list. + // + if(j == size - 1) + { + throw ex; + } + } } - connection = new Ice.ConnectionI(_instance, transceiver, endpoint, null, threadPerConnection); - connection.start(); - connection.validate(); if(defaultsAndOverrides.overrideCompress) { @@ -340,16 +393,6 @@ public final class OutgoingConnectionFactory catch(Ice.LocalException ex) { exception = ex; - - // - // If a connection object was constructed, then validate() - // must have raised the exception. - // - if(connection != null) - { - connection.waitUntilFinished(); // We must call waitUntilFinished() for cleanup. - connection = null; - } } TraceLevels traceLevels = _instance.traceLevels(); |