public class CallbackConnection extends Object implements Py4JClientConnection
Default implementation of the CommunicationChannel interface using TCP sockets.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_NONBLOCKING_SO_TIMEOUT |
| Constructor and Description |
|---|
CallbackConnection(int port,
InetAddress address) |
CallbackConnection(int port,
InetAddress address,
SocketFactory socketFactory) |
CallbackConnection(int port,
InetAddress address,
SocketFactory socketFactory,
int readTimeout) |
CallbackConnection(int port,
InetAddress address,
SocketFactory socketFactory,
int readTimeout,
String authToken) |
| Modifier and Type | Method and Description |
|---|---|
protected String |
readBlockingResponse(BufferedReader reader) |
protected String |
readNonBlockingResponse(Socket socket,
BufferedReader reader) |
String |
sendCommand(String command) |
String |
sendCommand(String command,
boolean blocking) |
void |
setUsed(boolean used) |
void |
shutdown() |
void |
shutdown(boolean reset)
Shuts down the connection by closing the socket, the writer, and the reader.
|
void |
start() |
boolean |
wasUsed() |
public static final int DEFAULT_NONBLOCKING_SO_TIMEOUT
public CallbackConnection(int port,
InetAddress address)
public CallbackConnection(int port,
InetAddress address,
SocketFactory socketFactory)
public CallbackConnection(int port,
InetAddress address,
SocketFactory socketFactory,
int readTimeout)
port - The port used to connect to the Python side.address - The address used to connect to the Java side.socketFactory - The socket factory used to create a socket (connection) to the Python side.readTimeout - Time in milliseconds (0 = infinite). Once connected to the Python side,
if the Java side does not receive a response after this time, the connection with the Python
program is closed. If readTimeout = 0, a default readTimeout of 1000 is used for operations that
must absolutely be non-blocking.public CallbackConnection(int port,
InetAddress address,
SocketFactory socketFactory,
int readTimeout,
String authToken)
port - The port used to connect to the Python side.address - The address used to connect to the Java side.socketFactory - The socket factory used to create a socket (connection) to the Python side.readTimeout - Time in milliseconds (0 = infinite). Once connected to the Python side,
if the Java side does not receive a response after this time, the connection with the Python
program is closed. If readTimeout = 0, a default readTimeout of 1000 is used for operations that
must absolutely be non-blocking.authToken - Token for authenticating with the callback server.public String sendCommand(String command)
sendCommand in interface Py4JClientConnectionpublic String sendCommand(String command, boolean blocking)
sendCommand in interface Py4JClientConnectionprotected String readBlockingResponse(BufferedReader reader) throws IOException
IOExceptionprotected String readNonBlockingResponse(Socket socket, BufferedReader reader) throws IOException
IOExceptionpublic void setUsed(boolean used)
setUsed in interface Py4JClientConnectionpublic void shutdown()
shutdown in interface Py4JClientConnectionpublic void shutdown(boolean reset)
Shuts down the connection by closing the socket, the writer, and the reader.
Internal: at this point, the connection has not been given back to the connections deque, or the deque is about to be cleared.
shutdown in interface Py4JClientConnectionpublic void start()
throws IOException
start in interface Py4JClientConnectionIOExceptionpublic boolean wasUsed()
wasUsed in interface Py4JClientConnectionCopyright © 2018. All rights reserved.