Class ConnectionStateManager

java.lang.Object
org.apache.curator.framework.state.ConnectionStateManager
All Implemented Interfaces:
Closeable, AutoCloseable

public class ConnectionStateManager extends Object implements Closeable
Used internally to manage connection state
  • Constructor Details

    • ConnectionStateManager

      public ConnectionStateManager(CuratorFramework client, ThreadFactory threadFactory, int sessionTimeoutMs, int sessionExpirationPercent)
      Parameters:
      client - the client
      threadFactory - thread factory to use or null for a default
      sessionTimeoutMs - the ZK session timeout in milliseconds
      sessionExpirationPercent - 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 client
      threadFactory - thread factory to use or null for a default
      sessionTimeoutMs - the ZK session timeout in milliseconds
      sessionExpirationPercent - percentage of negotiated session timeout to use when simulating a session timeout. 0 means don't simulate at all
      managerFactory - manager factory to use
  • Method Details

    • start

      public void start()
      Start the manager
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface 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 to ConnectionState.SUSPENDED only 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, TimeUnit units) throws InterruptedException
      Throws:
      InterruptedException
    • isConnected

      public boolean isConnected()