Class ClientInstance

  • All Implemented Interfaces:
    java.lang.AutoCloseable, Client

    public final class ClientInstance
    extends java.lang.Object
    implements Client
    Container of Connection instances that are all created with the same container parent and therefore share the same container Id.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes all currently open Connection instances created by this client.
      java.util.concurrent.Future<Client> closeAsync()
      Closes all currently open Connection instances created by this client.
      Connection connect​(java.lang.String host)
      Connect to the specified host, using the default port, without credentials and with all connection options set to their defaults.
      Connection connect​(java.lang.String host, int port)
      Connect to the specified host and port, without credentials and with all connection options set to their defaults.
      Connection connect​(java.lang.String host, int port, ConnectionOptions options)
      Connect to the specified host and port, with given connection options.
      Connection connect​(java.lang.String host, ConnectionOptions options)
      Connect to the specified host, using the default port, without credentials and with all connection options set to their defaults.
      java.lang.String containerId()  
      static ClientInstance create()  
      static ClientInstance create​(ClientOptions options)
      Create a new Client instance using provided configuration options.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

        public static ClientInstance create​(ClientOptions options)
        Description copied from interface: Client
        Create a new Client instance using provided configuration options.
        Parameters:
        options - The configuration options to apply to the newly create ClientInstance.
        Returns:
        a newly create ClientInstance that uses the configuration provided.
      • connect

        public Connection connect​(java.lang.String host,
                                  int port)
                           throws ClientException
        Description copied from interface: Client
        Connect to the specified host and port, without credentials and with all connection options set to their defaults.
        Specified by:
        connect in interface Client
        Parameters:
        host - the host to connect to
        port - the port to connect to
        Returns:
        connection, establishment not yet completed
        Throws:
        ClientException - if the Client is closed or an error occurs during connect.
      • connect

        public Connection connect​(java.lang.String host,
                                  int port,
                                  ConnectionOptions options)
                           throws ClientException
        Description copied from interface: Client
        Connect to the specified host and port, with given connection options.
        Specified by:
        connect in interface Client
        Parameters:
        host - the host to connect to
        port - the port to connect to
        options - options to use when creating the connection.
        Returns:
        connection, establishment not yet completed
        Throws:
        ClientException - if the Client is closed or an error occurs during connect.
      • connect

        public Connection connect​(java.lang.String host)
                           throws ClientException
        Description copied from interface: Client
        Connect to the specified host, using the default port, without credentials and with all connection options set to their defaults.
        Specified by:
        connect in interface Client
        Parameters:
        host - the host to connect to
        Returns:
        connection, establishment not yet completed
        Throws:
        ClientException - if the Client is closed or an error occurs during connect.
      • connect

        public Connection connect​(java.lang.String host,
                                  ConnectionOptions options)
                           throws ClientException
        Description copied from interface: Client
        Connect to the specified host, using the default port, without credentials and with all connection options set to their defaults.
        Specified by:
        connect in interface Client
        Parameters:
        host - the host to connect to
        options - options to use when creating the connection.
        Returns:
        connection, establishment not yet completed
        Throws:
        ClientException - if the Client is closed or an error occurs during connect.
      • containerId

        public java.lang.String containerId()
        Specified by:
        containerId in interface Client
        Returns:
        the container id assigned to this Client instance.
      • close

        public void close()
        Description copied from interface: Client
        Closes all currently open Connection instances created by this client.

        This method blocks and waits for each connection to close in turn using the configured close timeout of the ConnectionOptions that the connection was created with.

        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface Client
      • closeAsync

        public java.util.concurrent.Future<Client> closeAsync()
        Description copied from interface: Client
        Closes all currently open Connection instances created by this client.

        This method blocks and waits for each connection to be closed in turn using the configured close timeout of the ConnectionOptions that the connection was created with.

        Specified by:
        closeAsync in interface Client
        Returns:
        a Future that will be completed when all open connections have closed.