public abstract class ClientConnectionStrategy extends Object
ClientConnectionManager
to customize
how client connect to cluster, and provide various behaviours like async start or restart.Modifier and Type | Field and Description |
---|---|
protected ClientConnectionStrategyConfig |
clientConnectionStrategyConfig |
protected ClientContext |
clientContext |
protected ILogger |
logger |
Constructor and Description |
---|
ClientConnectionStrategy() |
Modifier and Type | Method and Description |
---|---|
abstract void |
beforeConnectToCluster(Address target)
If a cluster connection is established, this method will be called.
|
abstract void |
beforeGetConnection(Address target)
The purpose of this method is to validate a connection request by target, and exit the blocking invocation.
|
abstract 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
|
abstract void |
onClusterConnect()
If a cluster connection is established, this method will be called.
|
abstract void |
onConnect(ClientConnection connection)
If the
ClientConnectionManager opens a new connection to a member,
this method will be called with the connection parameter |
abstract void |
onDisconnect(ClientConnection connection)
If a connection is disconnected, this method will be called with the connection parameter
|
abstract void |
onDisconnectFromCluster()
If the cluster connection is lost for any reason, this method will be called.
|
abstract void |
shutdown()
This will be called as the last step of the HazelcastClient's shutdown.
|
abstract void |
start()
Starts the ClientConnectionStrategy; this will trigger connecting to the cluster.
|
protected ClientContext clientContext
protected ILogger logger
protected ClientConnectionStrategyConfig clientConnectionStrategyConfig
public void init(ClientContext clientContext)
clientContext
- hazelcast client context to access internal servicespublic abstract void start()
public abstract void beforeGetConnection(Address target)
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.target
- address of the requested connectionpublic abstract void beforeOpenConnection(Address target)
ClientConnectionManager
,
this method will be called.
This request can be rejected by throwing an instance of non retryable exceptions;
IOException
, HazelcastInstanceNotActiveException
or
RetryableException
target
- address of the requested connectionpublic abstract void beforeConnectToCluster(Address target)
target
- address of the requested connectionpublic abstract void onClusterConnect()
public abstract void onDisconnectFromCluster()
public abstract void onConnect(ClientConnection connection)
ClientConnectionManager
opens a new connection to a member,
this method will be called with the connection parameterconnection
- the new established connectionpublic abstract void onDisconnect(ClientConnection connection)
connection
- the closed connectionpublic abstract void shutdown()
Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.