/**
* Connects to the given {@link URI}.
*/
private void _connect() throws IOException, DeploymentException {
TCPNIOTransport privateTransport = null;
try {
if (sharedTransport) {
privateTransport = getOrCreateSharedTransport(workerThreadPoolConfig, selectorThreadPoolConfig);
}
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Transport failed to start.", e);
synchronized (TRANSPORT_LOCK) {
transport = null;
}
throw e;
}
for (Proxy proxy : proxies) {
try {
if (!sharedTransport) {
privateTransport = createTransport(workerThreadPoolConfig, selectorThreadPoolConfig);
privateTransport.start();
}
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Transport failed to start.", e);
throw e;
}
final TCPNIOConnectorHandler connectorHandler = new TCPNIOConnectorHandler(sharedTransport ? transport : privateTransport) {
};
connectorHandler.setSyncConnectTimeout(timeoutMs, TimeUnit.MILLISECONDS);
GrizzlyFuture<Connection> connectionGrizzlyFuture;
final TCPNIOTransport finalPrivateTransport = privateTransport;
final ClientEngine.TimeoutHandler timeoutHandler = sharedTransport ? null : new ClientEngine.TimeoutHandler() {
@Override
public void handleTimeout() {
closeTransport(finalPrivateTransport);
}