com.hazelcast.client.connection.nio

## Class ClientConnectionManagerImpl

- java.lang.Object
- - com.hazelcast.client.connection.nio.ClientConnectionManagerImpl

- All Implemented Interfaces:
    ClientConnectionManager, com.hazelcast.client.spi.impl.ConnectionHeartbeatListener, ConnectionListenable

      public class ClientConnectionManagerImpl
      extends Object
      implements ClientConnectionManager, com.hazelcast.client.spi.impl.ConnectionHeartbeatListener

  Implementation of `ClientConnectionManager`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `alive`
    `protected AtomicInteger` | `connectionIdGen`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientConnectionManagerImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl client, AddressTranslator addressTranslator, Collection<AddressProvider> addressProviders)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addConnectionHeartbeatListener(com.hazelcast.client.spi.impl.ConnectionHeartbeatListener connectionHeartbeatListener)`
    `void` | `addConnectionListener(ConnectionListener connectionListener)` Registers a ConnectionListener.
    `void` | `connectToCluster()`
    `Future<Void>` | `connectToClusterAsync()`
    `protected ClientConnection` | `createSocketConnection(Address address)`
    `Connection` | `getActiveConnection(Address target)`
    `Collection<ClientConnection>` | `getActiveConnections()`
    `com.hazelcast.internal.networking.nio.NioEventLoopGroup` | `getEventLoopGroup()`
    `Connection` | `getOrConnect(Address address)`
    `Connection` | `getOrTriggerConnect(Address target, boolean acquiresResources)`
    `ClientConnection` | `getOwnerConnection()`
    `Address` | `getOwnerConnectionAddress()`
    `com.hazelcast.client.impl.client.ClientPrincipal` | `getPrincipal()`
    `void` | `heartbeatResumed(Connection connection)` This event will be fired when the heartbeat is resumed for a connection to a member.
    `void` | `heartbeatStopped(Connection connection)` This event will be fired when no heartbeat response is received for `ClientProperty.HEARTBEAT_TIMEOUT` milliseconds from the member.
    `protected com.hazelcast.internal.networking.nio.NioEventLoopGroup` | `initEventLoopGroup(com.hazelcast.client.impl.HazelcastClientInstanceImpl client)`
    `boolean` | `isAlive()` Check if client connection manager is alive.
    `void` | `shutdown()`
    `void` | `start(ClientContext clientContext)`
    `protected void` | `startEventLoopGroup()`
    `protected void` | `stopEventLoopGroup()`

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

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

- - ### Field Detail

    - #### connectionIdGen

          protected final AtomicInteger connectionIdGen

    - #### alive

          protected volatile boolean alive

  - ### Constructor Detail

    - #### ClientConnectionManagerImpl

          public ClientConnectionManagerImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl client,
                                             AddressTranslator addressTranslator,
                                             Collection<AddressProvider> addressProviders)

  - ### Method Detail

    - #### getEventLoopGroup

          public com.hazelcast.internal.networking.nio.NioEventLoopGroup getEventLoopGroup()

    - #### initEventLoopGroup

          protected com.hazelcast.internal.networking.nio.NioEventLoopGroup initEventLoopGroup(com.hazelcast.client.impl.HazelcastClientInstanceImpl client)

    - #### getActiveConnections

          public Collection<ClientConnection> getActiveConnections()

      Specified by:
        `getActiveConnections` in interface `ClientConnectionManager`

    - #### isAlive

          public boolean isAlive()

      Description copied from interface: `ClientConnectionManager`
      Check if client connection manager is alive. ClientConnectionManager is not alive only when client is closing.
      Specified by:
        `isAlive` in interface `ClientConnectionManager`
      Returns:
        true if alive, false otherwise.

    - #### start

          public void start(ClientContext clientContext)

    - #### startEventLoopGroup

          protected void startEventLoopGroup()

    - #### shutdown

          public void shutdown()

    - #### getPrincipal

          public com.hazelcast.client.impl.client.ClientPrincipal getPrincipal()

      Specified by:
        `getPrincipal` in interface `ClientConnectionManager`

    - #### stopEventLoopGroup

          protected void stopEventLoopGroup()

    - #### getActiveConnection

          public Connection getActiveConnection(Address target)

      Specified by:
        `getActiveConnection` in interface `ClientConnectionManager`
      Parameters:
        `target` - to be connected
      Returns:
        connection if available, null otherwise

    - #### getOrConnect

          public Connection getOrConnect(Address address)
                                  throws IOException

      Specified by:
        `getOrConnect` in interface `ClientConnectionManager`
      Parameters:
        `address` - to be connected
      Returns:
        associated connection if available, creates new connection otherwise
      Throws:
        `IOException` - if connection is not established

    - #### getOrTriggerConnect

          public Connection getOrTriggerConnect(Address target,
                                                boolean acquiresResources)
                                         throws IOException

      Specified by:
        `getOrTriggerConnect` in interface `ClientConnectionManager`
      Parameters:
        `target` - to be connected
      Returns:
        associated connection if available, returns null and triggers new connection creation otherwise
      Throws:
        `IOException` - if connection is not able to triggered

    - #### getOwnerConnectionAddress

          public Address getOwnerConnectionAddress()

      Specified by:
        `getOwnerConnectionAddress` in interface `ClientConnectionManager`

    - #### getOwnerConnection

          public ClientConnection getOwnerConnection()

      Specified by:
        `getOwnerConnection` in interface `ClientConnectionManager`

    - #### createSocketConnection

          protected ClientConnection createSocketConnection(Address address)
                                                     throws IOException

      Throws:
        `IOException`

    - #### addConnectionListener

          public void addConnectionListener(ConnectionListener connectionListener)

      Description copied from interface: `ConnectionListenable`
      Registers a ConnectionListener. If the same listener is registered multiple times, it will be notified multiple times.
      Specified by:
        `addConnectionListener` in interface `ConnectionListenable`
      Parameters:
        `connectionListener` - the ConnectionListener to add.

    - #### addConnectionHeartbeatListener

          public void addConnectionHeartbeatListener(com.hazelcast.client.spi.impl.ConnectionHeartbeatListener connectionHeartbeatListener)

      Specified by:
        `addConnectionHeartbeatListener` in interface `ClientConnectionManager`

    - #### heartbeatResumed

          public void heartbeatResumed(Connection connection)

      Description copied from interface: `com.hazelcast.client.spi.impl.ConnectionHeartbeatListener`
      This event will be fired when the heartbeat is resumed for a connection to a member.
      Specified by:
        `heartbeatResumed` in interface `com.hazelcast.client.spi.impl.ConnectionHeartbeatListener`

    - #### heartbeatStopped

          public void heartbeatStopped(Connection connection)

      Description copied from interface: `com.hazelcast.client.spi.impl.ConnectionHeartbeatListener`
      This event will be fired when no heartbeat response is received for `ClientProperty.HEARTBEAT_TIMEOUT` milliseconds from the member.
      Specified by:
        `heartbeatStopped` in interface `com.hazelcast.client.spi.impl.ConnectionHeartbeatListener`

    - #### connectToCluster

          public void connectToCluster()

      Specified by:
        `connectToCluster` in interface `ClientConnectionManager`

    - #### connectToClusterAsync

          public Future<Void> connectToClusterAsync()

      Specified by:
        `connectToClusterAsync` in interface `ClientConnectionManager`

Copyright © 2018. All rights reserved.