Class ZooKeeperService

java.lang.Object
org.apache.zookeeper.server.jersey.ZooKeeperService

public class ZooKeeperService extends Object
Singleton which provides JAX-RS resources access to the ZooKeeper client. There's a single session for each base uri (so usually just one).
  • Constructor Details

    • ZooKeeperService

      public ZooKeeperService()
  • Method Details

    • mapContext

      public static void mapContext(String contextPath, Endpoint e)
      Specify ZooKeeper host:port for a particular context path. The host:port string is passed to the ZK client, so this can be formatted with more than a single host:port pair.
    • resetTimer

      public static void resetTimer(String contextPath, String session)
      Reset timer for a session
    • close

      public static void close(String contextPath)
      Close the ZooKeeper session and remove it from the internal maps
    • close

      public static void close(String contextPath, String session)
      Close the ZooKeeper session and remove it
    • closeAll

      public static void closeAll()
      Close all the ZooKeeper sessions and remove them from the internal maps
    • isConnected

      public static boolean isConnected(String contextPath, String session)
      Is there an active connection for this session?
    • getClient

      public static ZooKeeper getClient(String contextPath) throws IOException
      Return a ZooKeeper client not tied to a specific session.
      Throws:
      IOException
    • getClient

      public static ZooKeeper getClient(String contextPath, String session) throws IOException
      Return a ZooKeeper client for a session with a default expire time
      Throws:
      IOException
    • getClient

      public static ZooKeeper getClient(String contextPath, String session, int expireTime) throws IOException
      Return a ZooKeeper client which may or may not be connected, but it will not be expired. This method can be called multiple times, the same object will be returned except in the case where the session expires (at which point a new session will be returned)
      Throws:
      IOException