summaryrefslogtreecommitdiff
path: root/java/src/IceInternal/OutgoingConnectionFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/IceInternal/OutgoingConnectionFactory.java')
-rw-r--r--java/src/IceInternal/OutgoingConnectionFactory.java85
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();