Package com.clickhouse.client
Class AbstractSocketClient
java.lang.Object
com.clickhouse.client.AbstractSocketClient
- All Implemented Interfaces:
AutoCloseable
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractSocketClient(ClickHouseConfig config) AbstractSocketClient(ClickHouseNode server) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()connect(ClickHouseNode server) connect(InetSocketAddress address) static final ClickHouseSocketFactorygetCustomSocketFactory(String className, ClickHouseSocketFactory defaultFactory, Class<?> forClass) protected SocketChannelbooleanisActive()booleanprotected voidonConnect(ClickHouseConfig config, SocketChannel channel) protected booleanonRead(ClickHouseConfig config, SocketChannel sc, ClickHouseOutputStream out) Reads byte from socket input buffer.protected longonWrite(ClickHouseConfig config, SocketChannel sc, ClickHouseInputStream in, long startPosition) protected CompletableFuture<Boolean>processRequest(ClickHouseConfig config, ClickHouseInputStream in, ClickHouseOutputStream out) protected final voidremoveInterestOp(int op) send(ClickHouseConfig config, ClickHouseInputStream rawRequest) voidsend(ClickHouseConfig config, ClickHouseInputStream rawRequest, ClickHouseOutputStream responseStream) protected final voidsetInterestOp(int op) static final SocketsetSocketOptions(ClickHouseConfig config, Socket socket) Sets socket options.static final SocketChannelsetSocketOptions(ClickHouseConfig config, SocketChannel socket) Sets socket options.protected booleanstart()
-
Field Details
-
ERROR_INVALID_INPUT_STREAM
- See Also:
-
ERROR_INVALID_OUTPUT_STREAM
- See Also:
-
ERROR_READ_TIMEOUT
- See Also:
-
ERROR_WRITE_TIMEOUT
- See Also:
-
-
Constructor Details
-
AbstractSocketClient
- Throws:
IOException
-
AbstractSocketClient
- Throws:
IOException
-
AbstractSocketClient
- Throws:
IOException
-
-
Method Details
-
getCustomSocketFactory
public static final ClickHouseSocketFactory getCustomSocketFactory(String className, ClickHouseSocketFactory defaultFactory, Class<?> forClass) -
setSocketOptions
public static final Socket setSocketOptions(ClickHouseConfig config, Socket socket) throws SocketException Sets socket options. May be called at any time(e.g. before or even after the socket is bound or connected).- Parameters:
config- non-null configurationsocket- non-null socket- Returns:
- the given socket
- Throws:
SocketException- when there's error setting socket options
-
setSocketOptions
public static final SocketChannel setSocketOptions(ClickHouseConfig config, SocketChannel socket) throws IOException Sets socket options. May be called at any time(e.g. before or even after the socket is bound or connected).- Parameters:
config- non-null configurationsocket- non-null socket channel- Returns:
- the given socket channel
- Throws:
IOException- when there's error setting socket options
-
getSocketChannel
-
processRequest
protected CompletableFuture<Boolean> processRequest(ClickHouseConfig config, ClickHouseInputStream in, ClickHouseOutputStream out) throws IOException - Throws:
IOException
-
setInterestOp
protected final void setInterestOp(int op) -
removeInterestOp
protected final void removeInterestOp(int op) -
onConnect
- Throws:
IOException
-
onRead
protected boolean onRead(ClickHouseConfig config, SocketChannel sc, ClickHouseOutputStream out) throws IOException Reads byte from socket input buffer.- Parameters:
config- non-null configurationsc- socket channelout- output stream- Returns:
- true if the read was a success; false otherwise
- Throws:
IOException
-
onWrite
protected long onWrite(ClickHouseConfig config, SocketChannel sc, ClickHouseInputStream in, long startPosition) throws IOException - Throws:
IOException
-
start
- Throws:
IOException
-
connect
- Throws:
IOException
-
connect
- Throws:
IOException
-
isActive
public boolean isActive() -
isShutdown
public boolean isShutdown() -
localAddress
- Throws:
IOException
-
remoteAddress
- Throws:
IOException
-
send
public ClickHouseInputStream send(ClickHouseConfig config, ClickHouseInputStream rawRequest) throws IOException - Throws:
IOException
-
send
public void send(ClickHouseConfig config, ClickHouseInputStream rawRequest, ClickHouseOutputStream responseStream) throws IOException - Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-