use of org.apache.ignite.internal.util.ipc.loopback.IpcClientTcpEndpoint in project ignite by apache.
the class JdbcThinTcpIo method start.
/**
* @throws IgniteCheckedException On error.
* @throws IOException On IO error in handshake.
*/
public void start() throws IgniteCheckedException, IOException {
Socket sock = new Socket();
if (sockSndBuf != 0)
sock.setSendBufferSize(sockSndBuf);
if (sockRcvBuf != 0)
sock.setReceiveBufferSize(sockRcvBuf);
sock.setTcpNoDelay(tcpNoDelay);
try {
sock.connect(new InetSocketAddress(host, port));
} catch (IOException e) {
throw new IgniteCheckedException("Failed to connect to server [host=" + host + ", port=" + port + ']', e);
}
endpoint = new IpcClientTcpEndpoint(sock);
out = new BufferedOutputStream(endpoint.outputStream());
in = new BufferedInputStream(endpoint.inputStream());
handshake();
}
use of org.apache.ignite.internal.util.ipc.loopback.IpcClientTcpEndpoint in project ignite by apache.
the class JdbcThinTcpIo method connect.
/**
* Connect to host.
*
* @param addr Address.
* @param timeout Socket connection timeout in ms.
* @throws IOException On IO error.
* @throws SQLException On connection reject.
*/
private void connect(InetSocketAddress addr, int timeout) throws IOException, SQLException {
Socket sock;
if (ConnectionProperties.SSL_MODE_REQUIRE.equalsIgnoreCase(connProps.getSslMode()))
sock = JdbcThinSSLUtil.createSSLSocket(addr, connProps);
else if (ConnectionProperties.SSL_MODE_DISABLE.equalsIgnoreCase(connProps.getSslMode())) {
sock = new Socket();
try {
sock.connect(addr, timeout);
} catch (IOException e) {
throw new SQLException("Failed to connect to server [host=" + addr.getHostName() + ", port=" + addr.getPort() + ']', SqlStateCode.CLIENT_CONNECTION_FAILED, e);
}
} else {
throw new SQLException("Unknown sslMode. [sslMode=" + connProps.getSslMode() + ']', SqlStateCode.CLIENT_CONNECTION_FAILED);
}
if (connProps.getSocketSendBuffer() != 0)
sock.setSendBufferSize(connProps.getSocketSendBuffer());
if (connProps.getSocketReceiveBuffer() != 0)
sock.setReceiveBufferSize(connProps.getSocketReceiveBuffer());
sock.setTcpNoDelay(connProps.isTcpNoDelay());
try {
endpoint = new IpcClientTcpEndpoint(sock);
out = new BufferedOutputStream(endpoint.outputStream());
in = new BufferedInputStream(endpoint.inputStream());
} catch (IgniteCheckedException e) {
throw new SQLException("Failed to connect to server [url=" + connProps.getUrl() + ']', SqlStateCode.CLIENT_CONNECTION_FAILED, e);
}
}
Aggregations