Interface VespaCurator

All Known Implementing Classes:
CuratorWrapper

public interface VespaCurator
A client for a ZooKeeper cluster running inside Vespa. Applications that want to use ZooKeeper can inject this in their code.
Author:
mpolden, jonmv
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    Data of a ZK node, including content (possibly empty, never null) and metadata.
    static final record 
    Metadata for a ZK node.
    static interface 
    Callback interface for processes of which only a single instance should be active at any time, across all containers in the cluster, and across all component generations.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    delete(com.yahoo.path.Path path)
    Deletes the node at the given path.
    boolean
    delete(com.yahoo.path.Path path, int expectedVersion)
    Atomically compares the version in the stat of the node at the given path, with the expected version, and then: if they are equal, attempts the delete operation (see delete(Path)), and returns true; otherwise, returns false.
    void
    deleteAll(com.yahoo.path.Path path)
    Recursively deletes any node at the given path, and any children it may have.
    boolean
    isActive(String singletonId)
    Whether this container currently holds the exclusive lease for activation of singletons with this ID.
    list(com.yahoo.path.Path path)
    Lists the children of the node at the given path, or throws if there is no node at that path.
    lock(com.yahoo.path.Path path, Duration timeout)
    Creates and acquires a re-entrant lock with the given path.
    read(com.yahoo.path.Path path)
    Returns the content and stat for the node at the given path, or empty if no node exists at that path.
    Register the singleton with the framework, so it may become active, and returns a synchronisation handle to any deactivations or activations triggered by this.
    stat(com.yahoo.path.Path path)
    Returns the stat for the node at the given path, or empty if no node exists at that path.
    Unregister with the framework, so this singleton may no longer be active, and returns a synchronisation handle to any deactivation or activation triggered by this.
    write(com.yahoo.path.Path path, byte[] data)
    Writes the given data to a node at the given path, creating it and its parents as needed, and returns the stat of the modified node.
    write(com.yahoo.path.Path path, byte[] data, int expectedVersion)
    Atomically compares the version in the stat of the node at the given path, with the expected version, and then: if they are equal, attempts the write operation (see write(Path, byte[])); otherwise, return empty.
  • Method Details

    • stat

      Optional<VespaCurator.Meta> stat(com.yahoo.path.Path path)
      Returns the stat for the node at the given path, or empty if no node exists at that path.
    • read

      Optional<VespaCurator.Data> read(com.yahoo.path.Path path)
      Returns the content and stat for the node at the given path, or empty if no node exists at that path.
    • write

      VespaCurator.Meta write(com.yahoo.path.Path path, byte[] data)
      Writes the given data to a node at the given path, creating it and its parents as needed, and returns the stat of the modified node. Failure to write, due to connection loss, is retried a limited number of times.
    • write

      Optional<VespaCurator.Meta> write(com.yahoo.path.Path path, byte[] data, int expectedVersion)
      Atomically compares the version in the stat of the node at the given path, with the expected version, and then: if they are equal, attempts the write operation (see write(Path, byte[])); otherwise, return empty.
    • deleteAll

      void deleteAll(com.yahoo.path.Path path)
      Recursively deletes any node at the given path, and any children it may have.
    • delete

      void delete(com.yahoo.path.Path path)
      Deletes the node at the given path. Failres due to connection loss are retried a limited number of times.
    • delete

      boolean delete(com.yahoo.path.Path path, int expectedVersion)
      Atomically compares the version in the stat of the node at the given path, with the expected version, and then: if they are equal, attempts the delete operation (see delete(Path)), and returns true; otherwise, returns false.
    • list

      List<String> list(com.yahoo.path.Path path)
      Lists the children of the node at the given path, or throws if there is no node at that path.
    • lock

      AutoCloseable lock(com.yahoo.path.Path path, Duration timeout) throws com.yahoo.concurrent.UncheckedTimeoutException
      Creates and acquires a re-entrant lock with the given path. This blocks until the lock is acquired or timeout elapses.
      Throws:
      com.yahoo.concurrent.UncheckedTimeoutException
    • registerSingleton

      Future<?> registerSingleton(String singletonId, VespaCurator.SingletonWorker singleton)
      Register the singleton with the framework, so it may become active, and returns a synchronisation handle to any deactivations or activations triggered by this. If there is already another active singleton with the given ID (in this JVM), that will be deactivated before the new one is activated.
    • unregisterSingleton

      Future<?> unregisterSingleton(VespaCurator.SingletonWorker singleton)
      Unregister with the framework, so this singleton may no longer be active, and returns a synchronisation handle to any deactivation or activation triggered by this. If this is the last singleton registered with its ID, then this container immediately releases the activation lease for that ID, so another container may acquire it.
    • isActive

      boolean isActive(String singletonId)
      Whether this container currently holds the exclusive lease for activation of singletons with this ID.