public class ClientServer
extends java.lang.Object
This class creates the JavaServer and the PythonClient necessary to communicate with a Python virtual machine with the new threading model.
Modifier and Type | Class and Description |
---|---|
static class |
ClientServer.ClientServerBuilder
Helper class to make it easier and self-documenting how a
ClientServer is constructed. |
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
authToken |
protected boolean |
autoStartJavaServer |
protected int |
connectTimeout |
protected boolean |
enableMemoryManagement |
protected Gateway |
gateway |
protected java.net.InetAddress |
javaAddress |
protected int |
javaPort |
protected Py4JJavaServer |
javaServer |
protected java.util.logging.Logger |
logger |
protected java.net.InetAddress |
pythonAddress |
protected Py4JPythonClientPerThread |
pythonClient |
protected int |
pythonPort |
protected int |
readTimeout |
protected javax.net.SocketFactory |
socketFactory |
protected javax.net.ServerSocketFactory |
sSocketFactory |
Constructor and Description |
---|
ClientServer(int javaPort,
java.net.InetAddress javaAddress,
int pythonPort,
java.net.InetAddress pythonAddress,
int connectTimeout,
int readTimeout,
javax.net.ServerSocketFactory sSocketFactory,
javax.net.SocketFactory socketFactory,
java.lang.Object entryPoint) |
ClientServer(int javaPort,
java.net.InetAddress javaAddress,
int pythonPort,
java.net.InetAddress pythonAddress,
int connectTimeout,
int readTimeout,
javax.net.ServerSocketFactory sSocketFactory,
javax.net.SocketFactory socketFactory,
java.lang.Object entryPoint,
boolean autoStartJavaServer,
boolean enableMemoryManagement) |
ClientServer(java.lang.Object entryPoint) |
Modifier and Type | Method and Description |
---|---|
protected Py4JJavaServer |
createJavaServer(java.lang.Object entryPoint,
Py4JPythonClientPerThread pythonClient) |
protected Py4JPythonClientPerThread |
createPythonClient() |
Py4JJavaServer |
getJavaServer() |
Py4JPythonClient |
getPythonClient() |
java.lang.Object |
getPythonServerEntryPoint(java.lang.Class[] interfacesToImplement)
Gets a reference to the entry point on the Python side.
|
void |
shutdown()
Shuts down the Java Server so that it stops accepting requests and it
closes existing connections.
|
void |
startServer()
Starts the JavaServer on its own thread.
|
void |
startServer(boolean fork)
Starts the JavaServer, which will handle requests from the Python side.
|
protected final int javaPort
protected final java.net.InetAddress javaAddress
protected final int pythonPort
protected final java.net.InetAddress pythonAddress
protected final int connectTimeout
protected final int readTimeout
protected final javax.net.ServerSocketFactory sSocketFactory
protected final javax.net.SocketFactory socketFactory
protected final Gateway gateway
protected final Py4JJavaServer javaServer
protected final Py4JPythonClientPerThread pythonClient
protected final boolean autoStartJavaServer
protected final boolean enableMemoryManagement
protected final java.lang.String authToken
protected final java.util.logging.Logger logger
public ClientServer(java.lang.Object entryPoint)
entryPoint
- public ClientServer(int javaPort, java.net.InetAddress javaAddress, int pythonPort, java.net.InetAddress pythonAddress, int connectTimeout, int readTimeout, javax.net.ServerSocketFactory sSocketFactory, javax.net.SocketFactory socketFactory, java.lang.Object entryPoint)
javaPort
- javaAddress
- pythonPort
- pythonAddress
- connectTimeout
- readTimeout
- sSocketFactory
- socketFactory
- entryPoint
- public ClientServer(int javaPort, java.net.InetAddress javaAddress, int pythonPort, java.net.InetAddress pythonAddress, int connectTimeout, int readTimeout, javax.net.ServerSocketFactory sSocketFactory, javax.net.SocketFactory socketFactory, java.lang.Object entryPoint, boolean autoStartJavaServer, boolean enableMemoryManagement)
javaPort
- javaAddress
- pythonPort
- pythonAddress
- connectTimeout
- readTimeout
- sSocketFactory
- socketFactory
- entryPoint
- autoStartJavaServer
- enableMemoryManagement
- protected Py4JPythonClientPerThread createPythonClient()
protected Py4JJavaServer createJavaServer(java.lang.Object entryPoint, Py4JPythonClientPerThread pythonClient)
public Py4JJavaServer getJavaServer()
public Py4JPythonClient getPythonClient()
public void startServer()
Starts the JavaServer on its own thread.
Does nothing if autoStartJavaServer was set to true when constructing the instance.
public void startServer(boolean fork)
Starts the JavaServer, which will handle requests from the Python side.
Does nothing if autoStartJavaServer was set to true when constructing the instance.
fork
- If the JavaServer is started in this thread or in its own
thread.public void shutdown()
public java.lang.Object getPythonServerEntryPoint(java.lang.Class[] interfacesToImplement)
Gets a reference to the entry point on the Python side. This is often necessary if Java is driving the communication because Java cannot call static methods, initialize Python objects or load Python modules yet.
interfacesToImplement
-