public class ClientServerConnection extends Object implements Py4JServerConnection, Py4JClientConnection, Runnable
Modifier and Type | Field and Description |
---|---|
protected int |
blockingReadTimeout |
protected Map<String,Command> |
commands |
protected Py4JJavaServer |
javaServer |
protected Logger |
logger |
protected int |
nonBlockingReadTimeout |
protected Py4JPythonClientPerThread |
pythonClient |
protected BufferedReader |
reader |
protected Socket |
socket |
protected BufferedWriter |
writer |
Constructor and Description |
---|
ClientServerConnection(Gateway gateway,
Socket socket,
List<Class<? extends Command>> customCommands,
Py4JPythonClientPerThread pythonClient,
Py4JJavaServer javaServer,
int readTimeout) |
Modifier and Type | Method and Description |
---|---|
protected void |
fireConnectionStopped() |
Socket |
getSocket() |
protected void |
initCommands(Gateway gateway,
List<Class<? extends Command>> commandsClazz)
Override this method to initialize custom commands.
|
boolean |
isInitiatedFromClient() |
protected void |
quietSendError(BufferedWriter writer,
Throwable exception) |
protected String |
readBlockingResponse(BufferedReader reader) |
protected String |
readNonBlockingResponse(Socket socket,
BufferedReader reader) |
void |
run() |
String |
sendCommand(String command) |
String |
sendCommand(String command,
boolean blocking) |
void |
setInitiatedFromClient(boolean initiatedFromClient) |
void |
setUsed(boolean used) |
void |
shutdown() |
void |
shutdown(boolean reset) |
void |
start() |
void |
startServerConnection() |
void |
waitForCommands() |
boolean |
wasUsed() |
protected Socket socket
protected BufferedWriter writer
protected BufferedReader reader
protected final Logger logger
protected final Py4JJavaServer javaServer
protected final Py4JPythonClientPerThread pythonClient
protected final int blockingReadTimeout
protected final int nonBlockingReadTimeout
public ClientServerConnection(Gateway gateway, Socket socket, List<Class<? extends Command>> customCommands, Py4JPythonClientPerThread pythonClient, Py4JJavaServer javaServer, int readTimeout) throws IOException
IOException
public void startServerConnection()
protected void initCommands(Gateway gateway, List<Class<? extends Command>> commandsClazz)
Override this method to initialize custom commands.
gateway
- commandsClazz
- protected void fireConnectionStopped()
protected void quietSendError(BufferedWriter writer, Throwable exception)
public Socket getSocket()
getSocket
in interface Py4JServerConnection
public void waitForCommands()
public String sendCommand(String command)
sendCommand
in interface Py4JClientConnection
public String sendCommand(String command, boolean blocking)
sendCommand
in interface Py4JClientConnection
public void shutdown()
shutdown
in interface Py4JClientConnection
shutdown
in interface Py4JServerConnection
public void shutdown(boolean reset)
shutdown
in interface Py4JClientConnection
shutdown
in interface Py4JServerConnection
public void start() throws IOException
start
in interface Py4JClientConnection
IOException
public void setUsed(boolean used)
setUsed
in interface Py4JClientConnection
public boolean wasUsed()
wasUsed
in interface Py4JClientConnection
public boolean isInitiatedFromClient()
public void setInitiatedFromClient(boolean initiatedFromClient)
protected String readBlockingResponse(BufferedReader reader) throws IOException
IOException
protected String readNonBlockingResponse(Socket socket, BufferedReader reader) throws IOException
IOException
Copyright © 2016. All rights reserved.