py4j

## Class CallbackClient

- java.lang.Object
- - py4j.CallbackClient

-     public class CallbackClient
      extends Object

  A CallbackClient is responsible for managing communication channels: channels are created as needed (e.g., one per concurrent thread) and are closed after a certain time.

  Author:
    Barthelemy Dagenais

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DEFAULT_ADDRESS`
    `static long` | `DEFAULT_MIN_CONNECTION_TIME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CallbackClient(int port)`
    `CallbackClient(int port, InetAddress address)`
    `CallbackClient(int port, InetAddress address, long minConnectionTime, TimeUnit minConnectionTimeUnit)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `InetAddress` | `getAddress()`
    `int` | `getPort()`
    `void` | `periodicCleanup()` Closes communication channels that have not been used for a time specified at the creation of the callback client.
    `String` | `sendCommand(String command)` Sends a command to the Python side.
    `void` | `shutdown()` Closes all active channels, stops the periodic cleanup of channels and mark the client as shutting down.

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

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

- - ### Field Detail

    - #### DEFAULT_ADDRESS

          public static final String DEFAULT_ADDRESS

      See Also:
        Constant Field Values

    - #### DEFAULT_MIN_CONNECTION_TIME

          public static final long DEFAULT_MIN_CONNECTION_TIME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CallbackClient

          public CallbackClient(int port)

    - #### CallbackClient

          public CallbackClient(int port,
                                InetAddress address)

    - #### CallbackClient

          public CallbackClient(int port,
                                InetAddress address,
                                long minConnectionTime,
                                TimeUnit minConnectionTimeUnit)

      Parameters:
        `port` - The port used by channels to connect to the Python side.
        `address` - The addressed used by channels to connect to the Python side..
        `minConnectionTime` - The minimum connection time: channels are guaranteed to stay connected for this time after sending a command.
        `minConnectionTimeUnit` - The minimum coonnection time unit.

  - ### Method Detail

    - #### getAddress

          public InetAddress getAddress()

    - #### getPort

          public int getPort()

    - #### periodicCleanup

          public void periodicCleanup()

      Closes communication channels that have not been used for a time specified at the creation of the callback client.

      Clients should not directly call this method: it is called by a periodic cleaner thread.

    - #### sendCommand

          public String sendCommand(String command)

      Sends a command to the Python side. This method is typically used by Python proxies to call Python methods or to request the garbage collection of a proxy.

      Parameters:
        `command` - The command to send.
      Returns:
        The response.

    - #### shutdown

          public void shutdown()

      Closes all active channels, stops the periodic cleanup of channels and mark the client as shutting down. No more commands can be sent after this method has been called, except commands that were initiated before the shutdown method was called..