public class ConnectionStateManager extends Object implements Closeable
Constructor and Description |
---|
ConnectionStateManager(CuratorFramework client,
ThreadFactory threadFactory,
int sessionTimeoutMs,
int sessionExpirationPercent) |
ConnectionStateManager(CuratorFramework client,
ThreadFactory threadFactory,
int sessionTimeoutMs,
int sessionExpirationPercent,
ConnectionStateListenerManagerFactory managerFactory) |
Modifier and Type | Method and Description |
---|---|
boolean |
addStateChange(ConnectionState newConnectionState)
Post a state change.
|
boolean |
blockUntilConnected(int maxWaitTime,
TimeUnit units) |
void |
close() |
Listenable<ConnectionStateListener> |
getListenable()
Return the listenable
|
boolean |
isConnected() |
boolean |
setToSuspended()
Change to
ConnectionState.SUSPENDED only if not already suspended and not lost |
void |
start()
Start the manager
|
public ConnectionStateManager(CuratorFramework client, ThreadFactory threadFactory, int sessionTimeoutMs, int sessionExpirationPercent)
client
- the clientthreadFactory
- thread factory to use or null for a defaultsessionTimeoutMs
- the ZK session timeout in millisecondssessionExpirationPercent
- percentage of negotiated session timeout to use when simulating a session timeout. 0 means don't simulate at allpublic ConnectionStateManager(CuratorFramework client, ThreadFactory threadFactory, int sessionTimeoutMs, int sessionExpirationPercent, ConnectionStateListenerManagerFactory managerFactory)
client
- the clientthreadFactory
- thread factory to use or null for a defaultsessionTimeoutMs
- the ZK session timeout in millisecondssessionExpirationPercent
- percentage of negotiated session timeout to use when simulating a session timeout. 0 means don't simulate at allmanagerFactory
- manager factory to usepublic void start()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public Listenable<ConnectionStateListener> getListenable()
public boolean setToSuspended()
ConnectionState.SUSPENDED
only if not already suspended and not lostpublic boolean addStateChange(ConnectionState newConnectionState)
newConnectionState
- new statepublic boolean blockUntilConnected(int maxWaitTime, TimeUnit units) throws InterruptedException
InterruptedException
public boolean isConnected()
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.