Class MockCurator

  • All Implemented Interfaces:
    VespaCurator, java.lang.AutoCloseable

    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 Detail

      • 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 queries. This is not what ZooKeeper does.
    • Method Detail

      • dumpState

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

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

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

        public java.lang.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​(java.lang.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​(java.lang.String path)
        Description copied from class: Curator
        For internal use; prefer creating a Lock
        Overrides:
        createMutex in class Curator
      • createDirectoryCache

        public Curator.DirectoryCache createDirectoryCache​(java.lang.String path,
                                                           boolean cacheData,
                                                           boolean dataIsCompressed,
                                                           java.util.concurrent.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​(java.lang.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