com.hazelcast.client.connection.nio

## Class DefaultClientConnectionStrategy

- java.lang.Object
- - com.hazelcast.client.connection.ClientConnectionStrategy
  - - com.hazelcast.client.connection.nio.DefaultClientConnectionStrategy

-     public class DefaultClientConnectionStrategy
      extends ClientConnectionStrategy

  Default client connection strategy supporting async client start, reconnection modes and disabling reconnection.

- - ### Field Summary

    - ### Fields inherited from class com.hazelcast.client.connection.ClientConnectionStrategy

      `clientConnectionStrategyConfig, clientContext, logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultClientConnectionStrategy()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `beforeConnectToCluster(Address target)` If a cluster connection is established, this method will be called.
    `void` | `beforeGetConnection(Address target)` The purpose of this method is to validate a connection request by target, and exit the blocking invocation.
    `void` | `beforeOpenConnection(Address target)` If a new connection is required to open by `ClientConnectionManager`, this method will be called.
    `void` | `init(ClientContext clientContext)` Initialize this strategy with client context and config
    `void` | `onClusterConnect()` If a cluster connection is established, this method will be called.
    `void` | `onConnect(ClientConnection connection)` If the `ClientConnectionManager` opens a new connection to a member, this method will be called with the connection parameter
    `void` | `onDisconnect(ClientConnection connection)` If a connection is disconnected, this method will be called with the connection parameter
    `void` | `onDisconnectFromCluster()` If the cluster connection is lost for any reason, this method will be called.
    `void` | `shutdown()` This will be called as the last step of the HazelcastClient's shutdown.
    `void` | `start()` Starts the ClientConnectionStrategy; this will trigger connecting to the cluster.

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

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

- - ### Constructor Detail

    - #### DefaultClientConnectionStrategy

          public DefaultClientConnectionStrategy()

  - ### Method Detail

    - #### init

          public void init(ClientContext clientContext)

      Description copied from class: `ClientConnectionStrategy`
      Initialize this strategy with client context and config
      Overrides:
        `init` in class `ClientConnectionStrategy`
      Parameters:
        `clientContext` - hazelcast client context to access internal services

    - #### start

          public void start()

      Description copied from class: `ClientConnectionStrategy`
      Starts the ClientConnectionStrategy; this will trigger connecting to the cluster.
      Specified by:
        `start` in class `ClientConnectionStrategy`

    - #### beforeGetConnection

          public void beforeGetConnection(Address target)

      Description copied from class: `ClientConnectionStrategy`
      The purpose of this method is to validate a connection request by target, and exit the blocking invocation. For all connection requests on `ClientConnectionManager` this method will be called. The build in retry mechanism can be stopped by throwing an instance of non retryable exceptions; `IOException`, `HazelcastInstanceNotActiveException` or `RetryableException` The thrown exception will be received on the blocking user. Any blocking invocation will exit by that exception.
      Specified by:
        `beforeGetConnection` in class `ClientConnectionStrategy`
      Parameters:
        `target` - address of the requested connection

    - #### beforeOpenConnection

          public void beforeOpenConnection(Address target)

      Description copied from class: `ClientConnectionStrategy`
      If a new connection is required to open by `ClientConnectionManager`, this method will be called. This request can be rejected by throwing an instance of non retryable exceptions; `IOException`, `HazelcastInstanceNotActiveException` or `RetryableException`
      Specified by:
        `beforeOpenConnection` in class `ClientConnectionStrategy`
      Parameters:
        `target` - address of the requested connection

    - #### beforeConnectToCluster

          public void beforeConnectToCluster(Address target)

      Description copied from class: `ClientConnectionStrategy`
      If a cluster connection is established, this method will be called.
      Specified by:
        `beforeConnectToCluster` in class `ClientConnectionStrategy`
      Parameters:
        `target` - address of the requested connection

    - #### onClusterConnect

          public void onClusterConnect()

      Description copied from class: `ClientConnectionStrategy`
      If a cluster connection is established, this method will be called. if an exception is thrown, the already established connection will be closed.
      Specified by:
        `onClusterConnect` in class `ClientConnectionStrategy`

    - #### onDisconnectFromCluster

          public void onDisconnectFromCluster()

      Description copied from class: `ClientConnectionStrategy`
      If the cluster connection is lost for any reason, this method will be called.
      Specified by:
        `onDisconnectFromCluster` in class `ClientConnectionStrategy`

    - #### onConnect

          public void onConnect(ClientConnection connection)

      Description copied from class: `ClientConnectionStrategy`
      If the `ClientConnectionManager` opens a new connection to a member, this method will be called with the connection parameter
      Specified by:
        `onConnect` in class `ClientConnectionStrategy`
      Parameters:
        `connection` - the new established connection

    - #### onDisconnect

          public void onDisconnect(ClientConnection connection)

      Description copied from class: `ClientConnectionStrategy`
      If a connection is disconnected, this method will be called with the connection parameter
      Specified by:
        `onDisconnect` in class `ClientConnectionStrategy`
      Parameters:
        `connection` - the closed connection

    - #### shutdown

          public void shutdown()

      Description copied from class: `ClientConnectionStrategy`
      This will be called as the last step of the HazelcastClient's shutdown.
      Specified by:
        `shutdown` in class `ClientConnectionStrategy`

Copyright © 2019. All rights reserved.