Class MockCurator

java.lang.Object
com.yahoo.component.AbstractComponent
com.yahoo.vespa.curator.Curator
com.yahoo.vespa.curator.mock.MockCurator
All Implemented Interfaces:
com.yahoo.component.Component, com.yahoo.component.Deconstructable, AutoCloseable, Comparable<com.yahoo.component.Component>

public class MockCurator extends Curator

A non thread safe mock of the curator API. The methods are implemented lazily, due to laziness. You may trigger an UnsupportedOperationException, and in some cases a NullPointerException in using this, which means additional functionality is needed. Due to the "fluent API" style of Curator managing to break JavaDoc at a fundamental level, there is no documentation on the contract of each method. The behavior here is deduced by observing what using code exists and peeking at the Curator code. It may be incorrect in some corner cases.

Contains some code from PathUtils in ZooKeeper, licensed under the Apache 2.0 license.

Author:
bratseth
  • Constructor Details

    • MockCurator

      @Inject public MockCurator()
      Creates a mock curator with stable ordering
    • MockCurator

      public MockCurator(boolean stableOrdering)
      Creates a mock curator
      Parameters:
      stableOrdering - if true children of a node are returned in the same order each time they are queried. This is not what ZooKeeper does.
  • Method Details

    • dumpState

      public String dumpState()
      Lists the entire content of this curator instance as a multiline string. Useful for debugging.
    • counter

      public Optional<org.apache.curator.framework.recipes.atomic.DistributedAtomicLong> counter(String path)
      Returns an atomic counter in this, or empty if no such counter is created
    • setZooKeeperEnsembleConnectionSpec

      public void setZooKeeperEnsembleConnectionSpec(String ensembleSpec)
      Sets the ZooKeeper ensemble connection spec, which must be on the form host1:port,host2:port ...
    • zooKeeperEnsembleConnectionSpec

      public String zooKeeperEnsembleConnectionSpec()
      Overrides:
      zooKeeperEnsembleConnectionSpec in class Curator
      Returns:
      The non-null connect string containing all ZooKeeper servers in the ensemble. WARNING: This may be different from the servers this Curator may connect to. TODO: Move method out of this class.
    • createAtomicCounter

      public org.apache.curator.framework.recipes.atomic.DistributedAtomicLong createAtomicCounter(String path)
      Description copied from class: Curator
      For internal use; prefer creating a CuratorCounter
      Overrides:
      createAtomicCounter in class Curator
    • createMutex

      public org.apache.curator.framework.recipes.locks.InterProcessLock createMutex(String path)
      Description copied from class: Curator
      For internal use; prefer creating a Lock
      Overrides:
      createMutex in class Curator
    • getCompletionWaiter

      public Curator.CompletionWaiter getCompletionWaiter(com.yahoo.path.Path parentPath, String id, Duration waitForAll)
      Overrides:
      getCompletionWaiter in class Curator
    • createCompletionWaiter

      public Curator.CompletionWaiter createCompletionWaiter(com.yahoo.path.Path parentPath, String waiterNode, String id, Duration waitForAll)
      Overrides:
      createCompletionWaiter in class Curator
    • createDirectoryCache

      public Curator.DirectoryCache createDirectoryCache(String path, boolean cacheData, boolean dataIsCompressed, ExecutorService executorService)
      Description copied from class: Curator
      Creates a listenable cache which keeps in sync with changes to all the immediate children of a path
      Overrides:
      createDirectoryCache in class Curator
    • createFileCache

      public Curator.FileCache createFileCache(String path, boolean dataIsCompressed)
      Description copied from class: Curator
      Creates a listenable cache which keeps in sync with changes to a given node
      Overrides:
      createFileCache in class Curator
    • zooKeeperEnsembleCount

      public int zooKeeperEnsembleCount()
      Description copied from class: Curator
      Returns the number of zooKeeper servers in this ensemble. WARNING: This may be different from the number of servers this Curator may connect to. TODO: Move method out of this class.
      Overrides:
      zooKeeperEnsembleCount in class Curator