Package py4j

Class ClientServer

java.lang.Object
py4j.ClientServer

public class ClientServer extends Object

This class creates the JavaServer and the PythonClient necessary to communicate with a Python virtual machine with the new threading model.

  • Field Details

    • javaPort

      protected final int javaPort
    • javaAddress

      protected final InetAddress javaAddress
    • pythonPort

      protected final int pythonPort
    • pythonAddress

      protected final InetAddress pythonAddress
    • connectTimeout

      protected final int connectTimeout
    • readTimeout

      protected final int readTimeout
    • sSocketFactory

      protected final ServerSocketFactory sSocketFactory
    • socketFactory

      protected final SocketFactory socketFactory
    • gateway

      protected final Gateway gateway
    • javaServer

      protected final Py4JJavaServer javaServer
    • pythonClient

      protected final Py4JPythonClientPerThread pythonClient
    • autoStartJavaServer

      protected final boolean autoStartJavaServer
    • enableMemoryManagement

      protected final boolean enableMemoryManagement
    • authToken

      protected final String authToken
    • logger

      protected final Logger logger
  • Constructor Details

    • ClientServer

      public ClientServer(Object entryPoint)
      Parameters:
      entryPoint -
    • ClientServer

      public ClientServer(int javaPort, InetAddress javaAddress, int pythonPort, InetAddress pythonAddress, int connectTimeout, int readTimeout, ServerSocketFactory sSocketFactory, SocketFactory socketFactory, Object entryPoint)
      Parameters:
      javaPort -
      javaAddress -
      pythonPort -
      pythonAddress -
      connectTimeout -
      readTimeout -
      sSocketFactory -
      socketFactory -
      entryPoint -
    • ClientServer

      public ClientServer(int javaPort, InetAddress javaAddress, int pythonPort, InetAddress pythonAddress, int connectTimeout, int readTimeout, ServerSocketFactory sSocketFactory, SocketFactory socketFactory, Object entryPoint, boolean autoStartJavaServer, boolean enableMemoryManagement)
      Parameters:
      javaPort -
      javaAddress -
      pythonPort -
      pythonAddress -
      connectTimeout -
      readTimeout -
      sSocketFactory -
      socketFactory -
      entryPoint -
      autoStartJavaServer -
      enableMemoryManagement -
  • Method Details

    • createPythonClient

      protected Py4JPythonClientPerThread createPythonClient()
    • createJavaServer

      protected Py4JJavaServer createJavaServer(Object entryPoint, Py4JPythonClientPerThread pythonClient)
    • getJavaServer

      public Py4JJavaServer getJavaServer()
    • getPythonClient

      public Py4JPythonClient getPythonClient()
    • startServer

      public void startServer()

      Starts the JavaServer on its own thread.

      Does nothing if autoStartJavaServer was set to true when constructing the instance.

    • startServer

      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.

      Parameters:
      fork - If the JavaServer is started in this thread or in its own thread.
    • shutdown

      public void shutdown()
      Shuts down the Java Server so that it stops accepting requests and it closes existing connections.
    • getPythonServerEntryPoint

      public Object getPythonServerEntryPoint(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.

      Parameters:
      interfacesToImplement -
      Returns: