public class ClientStateListener extends Object implements LifecycleListener
Constructor and Description |
---|
ClientStateListener(ClientConfig clientConfig)
Registers this instance with the provided client configuration
|
ClientStateListener(ClientFailoverConfig clientFailoverConfig)
Registers this instance with the provided client configuration
|
Modifier and Type | Method and Description |
---|---|
boolean |
awaitConnected()
Waits until the client is connected to cluster.
|
boolean |
awaitConnected(long timeout,
TimeUnit unit)
Waits until the client is connected to cluster or the timeout expires.
|
boolean |
awaitDisconnected()
Waits until the client is disconnected from the cluster.
|
boolean |
awaitDisconnected(long timeout,
TimeUnit unit)
Waits until the client is disconnected from the cluster or the timeout expires.
|
LifecycleEvent.LifecycleState |
getCurrentState() |
boolean |
isConnected() |
boolean |
isShutdown() |
boolean |
isStarted() |
void |
stateChanged(LifecycleEvent event)
Called when instance's state changes.
|
public ClientStateListener(@Nonnull ClientFailoverConfig clientFailoverConfig)
This constructor is introduced to let ClientStateListener to be used via
HazelcastClient.newHazelcastFailoverClient(ClientFailoverConfig)
Listeners used in the different client configs registered to single ClientFailoverConfig
should be
same. It can be achieved using this constructor while the other constructor
ClientStateListener(ClientConfig)
does not allow that usage.
Note that ClientStateListener should be created after all the alternative client configs are added to the client failoverConfig. Example usage:
ClientFailoverConfig clientFailoverConfig = new ClientFailoverConfig();
clientFailoverConfig.addClientConfig(clientConfig).addClientConfig(clientConfig2);
ClientStateListener listener = new ClientStateListener(clientFailoverConfig);
HazelcastClient.newHazelcastFailoverClient(clientFailoverConfig);
clientFailoverConfig
- The client configuration to which this listener will be registeredpublic ClientStateListener(@Nonnull ClientConfig clientConfig)
clientConfig
- The client configuration to which this listener will be registeredpublic void stateChanged(LifecycleEvent event)
LifecycleListener
stateChanged
in interface LifecycleListener
event
- the Lifecycle eventpublic boolean awaitConnected(long timeout, TimeUnit unit) throws InterruptedException
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumentisShutdown
getCurrentState
InterruptedException
public boolean awaitConnected() throws InterruptedException
awaitConnected(long timeout, TimeUnit unit)
returns.InterruptedException
public boolean awaitDisconnected(long timeout, TimeUnit unit) throws InterruptedException
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumentisShutdown
getCurrentState
InterruptedException
public boolean awaitDisconnected() throws InterruptedException
awaitDisconnected(long timeout, TimeUnit unit)
returns.InterruptedException
public boolean isConnected()
public boolean isShutdown()
public boolean isStarted()
public LifecycleEvent.LifecycleState getCurrentState()
Copyright © 2023 Hazelcast, Inc.. All rights reserved.