Class MockZooKeeper

java.lang.Object
org.apache.zookeeper.ZooKeeper
org.apache.zookeeper.MockZooKeeper
All Implemented Interfaces:
AutoCloseable

public class MockZooKeeper extends org.apache.zookeeper.ZooKeeper
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     

    Nested classes/interfaces inherited from class org.apache.zookeeper.ZooKeeper

    org.apache.zookeeper.ZooKeeper.States, org.apache.zookeeper.ZooKeeper.WatchRegistration
  • Field Summary

    Fields inherited from class org.apache.zookeeper.ZooKeeper

    cnxn, hostProvider, SECURE_CLIENT, ZOOKEEPER_CLIENT_CNXN_SOCKET
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addWatch(String basePath, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AddWatchMode mode)
     
    void
    addWatch(String basePath, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AddWatchMode mode, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object ctx)
     
    void
     
    create(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode)
     
    void
    create(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode, org.apache.zookeeper.AsyncCallback.StringCallback cb, Object ctx)
     
    void
    delay(long millis, BiPredicate<MockZooKeeper.Op,String> predicate)
     
    void
    delete(String path, int version)
     
    void
    delete(String path, int version, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object ctx)
     
    org.apache.zookeeper.data.Stat
    exists(String path, boolean watch)
     
    void
    exists(String path, boolean watch, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object ctx)
     
    org.apache.zookeeper.data.Stat
    exists(String path, org.apache.zookeeper.Watcher watcher)
     
    void
    exists(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object ctx)
     
    void
    failConditional(org.apache.zookeeper.KeeperException.Code rc, BiPredicate<MockZooKeeper.Op,String> predicate)
     
    getChildren(String path, boolean watch)
     
    void
    getChildren(String path, boolean watcher, org.apache.zookeeper.AsyncCallback.Children2Callback cb, Object ctx)
     
    getChildren(String path, org.apache.zookeeper.Watcher watcher)
     
    void
    getChildren(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.ChildrenCallback cb, Object ctx)
     
    void
    getData(String path, boolean watch, org.apache.zookeeper.AsyncCallback.DataCallback cb, Object ctx)
     
    void
    getData(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.DataCallback cb, Object ctx)
     
    byte[]
    getData(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat)
     
    protected long
     
    long
     
    int
     
    org.apache.zookeeper.ZooKeeper.States
     
    List<org.apache.zookeeper.OpResult>
    multi(Iterable<org.apache.zookeeper.Op> ops)
     
    void
    multi(Iterable<org.apache.zookeeper.Op> ops, org.apache.zookeeper.AsyncCallback.MultiCallback cb, Object ctx)
     
     
     
    newInstance(ExecutorService executor, int readOpDelayMs)
     
     
    newInstanceForGlobalZK(ExecutorService executor, int readOpDelayMs)
     
    void
    overrideEpheralOwner(long epheralOwner)
     
    void
    register(org.apache.zookeeper.Watcher watcher)
     
    void
     
    void
    setAlwaysFail(org.apache.zookeeper.KeeperException.Code rc)
     
    org.apache.zookeeper.data.Stat
    setData(String path, byte[] data, int version)
     
    void
    setData(String path, byte[] data, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object ctx)
     
    void
    setSessionId(long id)
     
    void
     
    void
    sync(String path, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object ctx)
     
     
    void
     

    Methods inherited from class org.apache.zookeeper.ZooKeeper

    addAuthInfo, addWatch, addWatch, close, create, create, create, create, getACL, getACL, getAllChildrenNumber, getAllChildrenNumber, getChildren, getChildren, getChildren, getChildren, getChildWatches, getClientConfig, getConfig, getConfig, getConfig, getConfig, getData, getDataWatches, getEphemerals, getEphemerals, getEphemerals, getEphemerals, getExistWatches, getPersistentRecursiveWatches, getPersistentWatches, getSaslClient, getSessionPasswd, getTestable, multiInternal, multiInternal, removeAllWatches, removeAllWatches, removeWatches, removeWatches, setACL, setACL, sync, testableLocalSocketAddress, testableRemoteSocketAddress, testableWaitForShutdown, transaction, updateServerList, whoAmI

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • newInstance

      public static MockZooKeeper newInstance()
    • newInstance

      public static MockZooKeeper newInstance(ExecutorService executor)
    • newInstanceForGlobalZK

      public static MockZooKeeper newInstanceForGlobalZK(ExecutorService executor)
    • newInstanceForGlobalZK

      public static MockZooKeeper newInstanceForGlobalZK(ExecutorService executor, int readOpDelayMs)
    • newInstance

      public static MockZooKeeper newInstance(ExecutorService executor, int readOpDelayMs)
    • getSessionTimeout

      public int getSessionTimeout()
      Overrides:
      getSessionTimeout in class org.apache.zookeeper.ZooKeeper
    • getState

      public org.apache.zookeeper.ZooKeeper.States getState()
      Overrides:
      getState in class org.apache.zookeeper.ZooKeeper
    • register

      public void register(org.apache.zookeeper.Watcher watcher)
      Overrides:
      register in class org.apache.zookeeper.ZooKeeper
    • create

      public String create(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      create in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • getEphemeralOwner

      protected long getEphemeralOwner()
    • overrideEpheralOwner

      public void overrideEpheralOwner(long epheralOwner)
    • removeEpheralOwnerOverride

      public void removeEpheralOwnerOverride()
    • create

      public void create(String path, byte[] data, List<org.apache.zookeeper.data.ACL> acl, org.apache.zookeeper.CreateMode createMode, org.apache.zookeeper.AsyncCallback.StringCallback cb, Object ctx)
      Overrides:
      create in class org.apache.zookeeper.ZooKeeper
    • getData

      public byte[] getData(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.data.Stat stat) throws org.apache.zookeeper.KeeperException
      Overrides:
      getData in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
    • getData

      public void getData(String path, boolean watch, org.apache.zookeeper.AsyncCallback.DataCallback cb, Object ctx)
      Overrides:
      getData in class org.apache.zookeeper.ZooKeeper
    • getData

      public void getData(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.DataCallback cb, Object ctx)
      Overrides:
      getData in class org.apache.zookeeper.ZooKeeper
    • getChildren

      public void getChildren(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.ChildrenCallback cb, Object ctx)
      Overrides:
      getChildren in class org.apache.zookeeper.ZooKeeper
    • getChildren

      public List<String> getChildren(String path, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException
      Overrides:
      getChildren in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
    • getChildren

      public List<String> getChildren(String path, boolean watch) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      getChildren in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • getChildren

      public void getChildren(String path, boolean watcher, org.apache.zookeeper.AsyncCallback.Children2Callback cb, Object ctx)
      Overrides:
      getChildren in class org.apache.zookeeper.ZooKeeper
    • exists

      public org.apache.zookeeper.data.Stat exists(String path, boolean watch) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      exists in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • exists

      public org.apache.zookeeper.data.Stat exists(String path, org.apache.zookeeper.Watcher watcher) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      exists in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • exists

      public void exists(String path, boolean watch, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object ctx)
      Overrides:
      exists in class org.apache.zookeeper.ZooKeeper
    • exists

      public void exists(String path, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object ctx)
      Overrides:
      exists in class org.apache.zookeeper.ZooKeeper
    • sync

      public void sync(String path, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object ctx)
      Overrides:
      sync in class org.apache.zookeeper.ZooKeeper
    • setData

      public org.apache.zookeeper.data.Stat setData(String path, byte[] data, int version) throws org.apache.zookeeper.KeeperException, InterruptedException
      Overrides:
      setData in class org.apache.zookeeper.ZooKeeper
      Throws:
      org.apache.zookeeper.KeeperException
      InterruptedException
    • setData

      public void setData(String path, byte[] data, int version, org.apache.zookeeper.AsyncCallback.StatCallback cb, Object ctx)
      Overrides:
      setData in class org.apache.zookeeper.ZooKeeper
    • delete

      public void delete(String path, int version) throws InterruptedException, org.apache.zookeeper.KeeperException
      Overrides:
      delete in class org.apache.zookeeper.ZooKeeper
      Throws:
      InterruptedException
      org.apache.zookeeper.KeeperException
    • delete

      public void delete(String path, int version, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object ctx)
      Overrides:
      delete in class org.apache.zookeeper.ZooKeeper
    • multi

      public void multi(Iterable<org.apache.zookeeper.Op> ops, org.apache.zookeeper.AsyncCallback.MultiCallback cb, Object ctx)
      Overrides:
      multi in class org.apache.zookeeper.ZooKeeper
    • multi

      public List<org.apache.zookeeper.OpResult> multi(Iterable<org.apache.zookeeper.Op> ops) throws InterruptedException, org.apache.zookeeper.KeeperException
      Overrides:
      multi in class org.apache.zookeeper.ZooKeeper
      Throws:
      InterruptedException
      org.apache.zookeeper.KeeperException
    • addWatch

      public void addWatch(String basePath, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AddWatchMode mode)
      Overrides:
      addWatch in class org.apache.zookeeper.ZooKeeper
    • addWatch

      public void addWatch(String basePath, org.apache.zookeeper.Watcher watcher, org.apache.zookeeper.AddWatchMode mode, org.apache.zookeeper.AsyncCallback.VoidCallback cb, Object ctx)
      Overrides:
      addWatch in class org.apache.zookeeper.ZooKeeper
    • close

      public void close() throws InterruptedException
      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class org.apache.zookeeper.ZooKeeper
      Throws:
      InterruptedException
    • shutdown

      public void shutdown() throws InterruptedException
      Throws:
      InterruptedException
    • failConditional

      public void failConditional(org.apache.zookeeper.KeeperException.Code rc, BiPredicate<MockZooKeeper.Op,String> predicate)
    • delay

      public void delay(long millis, BiPredicate<MockZooKeeper.Op,String> predicate)
    • setAlwaysFail

      public void setAlwaysFail(org.apache.zookeeper.KeeperException.Code rc)
    • unsetAlwaysFail

      public void unsetAlwaysFail()
    • setSessionId

      public void setSessionId(long id)
    • getSessionId

      public long getSessionId()
      Overrides:
      getSessionId in class org.apache.zookeeper.ZooKeeper
    • toString

      public String toString()
      Overrides:
      toString in class org.apache.zookeeper.ZooKeeper