use of java.nio.channels.UnresolvedAddressException in project SilverKing by Morgan-Stanley.
the class AsyncBase method newOutgoingConnection.
// //////////////////////////////////////////////////////////////////////////////////
public T newOutgoingConnection(InetSocketAddress dest, ConnectionListener listener) throws IOException {
SocketChannel channel;
channel = SocketChannel.open();
if (dest.isUnresolved()) {
Log.warning("Unresolved InetSocketAddress: " + dest);
throw new ConnectException("Unresolved InetSocketAddress" + dest.toString());
}
LWTThreadUtil.setBlocked();
try {
channel.socket().connect(dest, defSocketConnectTimeout);
// channel.connect(dest);
} catch (UnresolvedAddressException uae) {
Log.logErrorWarning(uae);
Log.warning(dest);
throw new ConnectException(dest.toString());
} finally {
LWTThreadUtil.setNonBlocked();
}
return addConnection(channel, listener);
}
use of java.nio.channels.UnresolvedAddressException in project zookeeper by apache.
the class ClientCnxnSocketNIO method connect.
@Override
void connect(InetSocketAddress addr) throws IOException {
SocketChannel sock = createSock();
try {
registerAndConnect(sock, addr);
} catch (UnresolvedAddressException | UnsupportedAddressTypeException | SecurityException | IOException e) {
LOG.error("Unable to open socket to {}", addr);
sock.close();
throw e;
}
initialized = false;
/*
* Reset incomingBuffer
*/
lenBuffer.clear();
incomingBuffer = lenBuffer;
}
use of java.nio.channels.UnresolvedAddressException in project zookeeper by apache.
the class QuorumCnxManager method initiateConnection.
/**
* First we create the socket, perform SSL handshake and authentication if needed.
* Then we perform the initiation protocol.
* If this server has initiated the connection, then it gives up on the
* connection if it loses challenge. Otherwise, it keeps the connection.
*/
public void initiateConnection(final MultipleAddresses electionAddr, final Long sid) {
Socket sock = null;
try {
LOG.debug("Opening channel to server {}", sid);
if (self.isSslQuorum()) {
sock = self.getX509Util().createSSLSocket();
} else {
sock = SOCKET_FACTORY.get();
}
setSockOpts(sock);
sock.connect(electionAddr.getReachableOrOne(), cnxTO);
if (sock instanceof SSLSocket) {
SSLSocket sslSock = (SSLSocket) sock;
sslSock.startHandshake();
LOG.info("SSL handshake complete with {} - {} - {}", sslSock.getRemoteSocketAddress(), sslSock.getSession().getProtocol(), sslSock.getSession().getCipherSuite());
}
LOG.debug("Connected to server {} using election address: {}:{}", sid, sock.getInetAddress(), sock.getPort());
} catch (X509Exception e) {
LOG.warn("Cannot open secure channel to {} at election address {}", sid, electionAddr, e);
closeSocket(sock);
return;
} catch (UnresolvedAddressException | IOException e) {
LOG.warn("Cannot open channel to {} at election address {}", sid, electionAddr, e);
closeSocket(sock);
return;
}
try {
startConnection(sock, sid);
} catch (IOException e) {
LOG.error("Exception while connecting, id: {}, addr: {}, closing learner connection", sid, sock.getRemoteSocketAddress(), e);
closeSocket(sock);
}
}
use of java.nio.channels.UnresolvedAddressException in project j2objc by google.
the class AsynchronousSocketChannelTest method test_bind_unresolvedAddress.
public void test_bind_unresolvedAddress() throws Exception {
AsynchronousSocketChannel asc = AsynchronousSocketChannel.open();
try {
asc.bind(new InetSocketAddress("unresolvedname", 31415));
fail();
} catch (UnresolvedAddressException expected) {
}
assertNull(asc.getLocalAddress());
assertNull(asc.getRemoteAddress());
assertTrue(asc.isOpen());
asc.close();
}
use of java.nio.channels.UnresolvedAddressException in project j2objc by google.
the class DatagramChannelTest method testConnect_Unresolved.
/**
* Test method for 'DatagramChannelImpl.connect(SocketAddress)'
*/
public void testConnect_Unresolved() throws IOException {
assertFalse(this.channel1.isConnected());
InetSocketAddress unresolved = new InetSocketAddress("unresolved address", 1080);
try {
this.channel1.connect(unresolved);
// $NON-NLS-1$
fail("Should throw an UnresolvedAddressException here.");
} catch (UnresolvedAddressException e) {
// OK.
}
}
Aggregations