Class ConnectionStateManager
- java.lang.Object
-
- org.apache.curator.framework.state.ConnectionStateManager
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class ConnectionStateManager extends java.lang.Object implements java.io.CloseableUsed internally to manage connection state
-
-
Constructor Summary
Constructors Constructor Description ConnectionStateManager(CuratorFramework client, java.util.concurrent.ThreadFactory threadFactory, int sessionTimeoutMs, int sessionExpirationPercent)ConnectionStateManager(CuratorFramework client, java.util.concurrent.ThreadFactory threadFactory, int sessionTimeoutMs, int sessionExpirationPercent, ConnectionStateListenerManagerFactory managerFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddStateChange(ConnectionState newConnectionState)Post a state change.booleanblockUntilConnected(int maxWaitTime, java.util.concurrent.TimeUnit units)voidclose()Listenable<ConnectionStateListener>getListenable()Return the listenablebooleanisConnected()booleansetToSuspended()Change toConnectionState.SUSPENDEDonly if not already suspended and not lostvoidstart()Start the manager
-
-
-
Constructor Detail
-
ConnectionStateManager
public ConnectionStateManager(CuratorFramework client, java.util.concurrent.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, java.util.concurrent.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 Detail
-
start
public void start()
Start the manager
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
getListenable
public Listenable<ConnectionStateListener> getListenable()
Return the listenable- Returns:
- listenable
- Since:
- 4.2.0 return type has changed from ListenerContainer to Listenable
-
setToSuspended
public boolean setToSuspended()
Change toConnectionState.SUSPENDEDonly if not already suspended and not lost- Returns:
- true if connection is set to SUSPENDED
-
addStateChange
public boolean addStateChange(ConnectionState newConnectionState)
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
public boolean blockUntilConnected(int maxWaitTime, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedException- Throws:
java.lang.InterruptedException
-
isConnected
public boolean isConnected()
-
-