PythonClient (py4j-java 0.10.0 API)
Date: 2016-04-18

py4j

## Class PythonClient

- java.lang.Object
- - py4j.CallbackClient
  - - py4j.PythonClient

- All Implemented Interfaces:
    Py4JPythonClient

      public class PythonClient
      extends CallbackClient

  Subclass of CallbackClient that implements the new threading model, ensuring that each thread uses its own connection.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.logging.Logger` | `logger`

    - ### Fields inherited from class py4j.CallbackClient

      `address, connections, DEFAULT_ADDRESS, DEFAULT_MIN_CONNECTION_TIME, minConnectionTime, minConnectionTimeUnit, port, socketFactory`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PythonClient(Gateway gateway, java.util.List<java.lang.Class<? extends Command>> customCommands, int pythonPort, java.net.InetAddress pythonAddress, long minConnectionTime, java.util.concurrent.TimeUnit minConnectionTimeUnit, javax.net.SocketFactory socketFactory, Py4JJavaServer javaServer)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Py4JPythonClient` | `copyWith(java.net.InetAddress pythonAddress, int pythonPort)` Creates a callback client which connects to the given address and port, but retains all the other settings (like the `CallbackClient.minConnectionTime` and the `CallbackClient.socketFactory`.
    `protected Py4JClientConnection` | `getConnection()`
    `Gateway` | `getGateway()`
    `Py4JJavaServer` | `getJavaServer()`
    `protected void` | `giveBackConnection(Py4JClientConnection cc)`
    `void` | `setGateway(Gateway gateway)`
    `void` | `setJavaServer(Py4JJavaServer javaServer)`
    `protected void` | `setupCleaner()`
    `protected boolean` | `shouldRetrySendCommand(Py4JClientConnection cc, Py4JException pe)`

    - ### Methods inherited from class py4j.CallbackClient

      `getAddress, getConnectionLock, getPort, periodicCleanup, sendCommand, sendCommand, shutdown`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### logger

          protected final java.util.logging.Logger logger

  - ### Constructor Detail

    - #### PythonClient

          public PythonClient(Gateway gateway,
                              java.util.List<java.lang.Class<? extends Command>> customCommands,
                              int pythonPort,
                              java.net.InetAddress pythonAddress,
                              long minConnectionTime,
                              java.util.concurrent.TimeUnit minConnectionTimeUnit,
                              javax.net.SocketFactory socketFactory,
                              Py4JJavaServer javaServer)

  - ### Method Detail

    - #### getGateway

          public Gateway getGateway()

    - #### setGateway

          public void setGateway(Gateway gateway)

    - #### getJavaServer

          public Py4JJavaServer getJavaServer()

    - #### setJavaServer

          public void setJavaServer(Py4JJavaServer javaServer)

    - #### setupCleaner

          protected void setupCleaner()

      Overrides:
        `setupCleaner` in class `CallbackClient`

    - #### getConnection

          protected Py4JClientConnection getConnection()
                                                throws java.io.IOException

      Overrides:
        `getConnection` in class `CallbackClient`
      Throws:
        `java.io.IOException`

    - #### shouldRetrySendCommand

          protected boolean shouldRetrySendCommand(Py4JClientConnection cc,
                                                   Py4JException pe)

      Overrides:
        `shouldRetrySendCommand` in class `CallbackClient`

    - #### giveBackConnection

          protected void giveBackConnection(Py4JClientConnection cc)

      Overrides:
        `giveBackConnection` in class `CallbackClient`

    - #### copyWith

          public Py4JPythonClient copyWith(java.net.InetAddress pythonAddress,
                                           int pythonPort)

      Description copied from class: `CallbackClient`

      Creates a callback client which connects to the given address and port, but retains all the other settings (like the `CallbackClient.minConnectionTime` and the `CallbackClient.socketFactory`. This method is useful if for some reason your CallbackServer changes its address or you come to know of the address after Gateway has already instantiated.

      Specified by:
        `copyWith` in interface `Py4JPythonClient`
      Overrides:
        `copyWith` in class `CallbackClient`
      Parameters:
        `pythonAddress` - The address used by a PythonProxyHandler to connect to a Python gateway.
        `pythonPort` - The port used by a PythonProxyHandler to connect to a Python gateway. Essentially the port used for Python callbacks.