Class ConnectionStateManager
java.lang.Object
org.apache.curator.framework.state.ConnectionStateManager
- All Implemented Interfaces:
Closeable
,AutoCloseable
Used internally to manage connection state
-
Constructor Summary
ConstructorDescriptionConnectionStateManager
(CuratorFramework client, ThreadFactory threadFactory, int sessionTimeoutMs, int sessionExpirationPercent) ConnectionStateManager
(CuratorFramework client, ThreadFactory threadFactory, int sessionTimeoutMs, int sessionExpirationPercent, ConnectionStateListenerManagerFactory managerFactory) -
Method Summary
Modifier and TypeMethodDescriptionboolean
addStateChange
(ConnectionState newConnectionState) Post a state change.boolean
blockUntilConnected
(int maxWaitTime, TimeUnit units) void
close()
Return the listenableboolean
boolean
Change toConnectionState.SUSPENDED
only if not already suspended and not lostvoid
start()
Start the manager
-
Constructor Details
-
ConnectionStateManager
public ConnectionStateManager(CuratorFramework client, ThreadFactory threadFactory, int sessionTimeoutMs, int sessionExpirationPercent) - Parameters:
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 all
-
ConnectionStateManager
public ConnectionStateManager(CuratorFramework client, ThreadFactory threadFactory, int sessionTimeoutMs, int sessionExpirationPercent, ConnectionStateListenerManagerFactory managerFactory) - Parameters:
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 use
-
-
Method Details
-
start
public void start()Start the manager -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getListenable
Return the listenable- Returns:
- listenable
- Since:
- 4.2.0 return type has changed from ListenerContainer to Listenable
-
setToSuspended
public boolean setToSuspended()Change toConnectionState.SUSPENDED
only if not already suspended and not lost- Returns:
- true if connection is set to SUSPENDED
-
addStateChange
Post a state change. If the manager is already in that state the change is ignored. Otherwise the change is queued for listeners.- Parameters:
newConnectionState
- new state- Returns:
- true if the state actually changed, false if it was already at that state
-
blockUntilConnected
- Throws:
InterruptedException
-
isConnected
public boolean isConnected()
-