Package py4j
Class ClientServerConnection
java.lang.Object
py4j.ClientServerConnection
- All Implemented Interfaces:
Runnable
,Py4JClientConnection
,Py4JServerConnection
public class ClientServerConnection
extends Object
implements Py4JServerConnection, Py4JClientConnection, Runnable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AuthCommand
protected final String
protected final int
protected final Py4JJavaServer
protected final Logger
protected final int
protected final Py4JPythonClientPerThread
protected BufferedReader
protected Socket
protected BufferedWriter
-
Constructor Summary
ConstructorsConstructorDescriptionClientServerConnection
(Gateway gateway, Socket socket, List<Class<? extends Command>> customCommands, Py4JPythonClientPerThread pythonClient, Py4JJavaServer javaServer, int readTimeout) ClientServerConnection
(Gateway gateway, Socket socket, List<Class<? extends Command>> customCommands, Py4JPythonClientPerThread pythonClient, Py4JJavaServer javaServer, int readTimeout, String authToken) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
initCommands
(Gateway gateway, List<Class<? extends Command>> commandsClazz) Override this method to initialize custom commands.boolean
protected void
quietSendFatalError
(BufferedWriter writer, Throwable exception) protected String
readBlockingResponse
(BufferedReader reader) protected String
readNonBlockingResponse
(Socket socket, BufferedReader reader) void
run()
sendCommand
(String command) sendCommand
(String command, boolean blocking) void
setInitiatedFromClient
(boolean initiatedFromClient) void
setUsed
(boolean used) void
shutdown()
void
shutdown
(boolean reset) void
start()
void
void
boolean
wasUsed()
-
Field Details
-
socket
-
writer
-
reader
-
commands
-
logger
-
javaServer
-
pythonClient
-
blockingReadTimeout
protected final int blockingReadTimeout -
nonBlockingReadTimeout
protected final int nonBlockingReadTimeout -
authToken
-
authCommand
-
-
Constructor Details
-
ClientServerConnection
public ClientServerConnection(Gateway gateway, Socket socket, List<Class<? extends Command>> customCommands, Py4JPythonClientPerThread pythonClient, Py4JJavaServer javaServer, int readTimeout) throws IOException - Throws:
IOException
-
ClientServerConnection
public ClientServerConnection(Gateway gateway, Socket socket, List<Class<? extends Command>> customCommands, Py4JPythonClientPerThread pythonClient, Py4JJavaServer javaServer, int readTimeout, String authToken) throws IOException - Throws:
IOException
-
-
Method Details
-
startServerConnection
- Throws:
IOException
-
run
public void run() -
initCommands
Override this method to initialize custom commands.
- Parameters:
gateway
-commandsClazz
-
-
fireConnectionStopped
protected void fireConnectionStopped() -
quietSendFatalError
-
getSocket
- Specified by:
getSocket
in interfacePy4JServerConnection
- Returns:
- The socket used by this gateway connection.
-
waitForCommands
public void waitForCommands() -
sendCommand
- Specified by:
sendCommand
in interfacePy4JClientConnection
-
sendCommand
- Specified by:
sendCommand
in interfacePy4JClientConnection
-
shutdown
public void shutdown()- Specified by:
shutdown
in interfacePy4JClientConnection
- Specified by:
shutdown
in interfacePy4JServerConnection
-
shutdown
public void shutdown(boolean reset) - Specified by:
shutdown
in interfacePy4JClientConnection
- Specified by:
shutdown
in interfacePy4JServerConnection
-
start
- Specified by:
start
in interfacePy4JClientConnection
- Throws:
IOException
-
setUsed
public void setUsed(boolean used) - Specified by:
setUsed
in interfacePy4JClientConnection
-
wasUsed
public boolean wasUsed()- Specified by:
wasUsed
in interfacePy4JClientConnection
-
isInitiatedFromClient
public boolean isInitiatedFromClient() -
setInitiatedFromClient
public void setInitiatedFromClient(boolean initiatedFromClient) -
readBlockingResponse
- Throws:
IOException
-
readNonBlockingResponse
- Throws:
IOException
-