Class ResolverWriter

java.lang.Object
io.deephaven.enterprise.etcdclient.resolver.ResolverWriter

public class ResolverWriter extends Object
Class used to register (write in etcd) entries in the DH service resolver
  • Constructor Summary

    Constructors
    Constructor
    Description
    ResolverWriter(LeaseHandlerEtcd handler, String servicePath, byte[] uuid)
    Create a ResolverWriter object that can be used to register hosts for a given service path.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Stop using this object; calls deregister.
    void
    Remove our registration.
    boolean
    register(DhService service, int port)
    Register for the given service, automatically calculating the host from (in order of precedence) a property consisting of the upper case string for the service name, concatenated to @code{.registry.host}.
    boolean
    register(String host, int port)
    Register the given host and port using the service path and uuid given on construction.
    boolean
    registerConditional(io.deephaven.shadow.jetcd.io.etcd.jetcd.ByteSequence conditionalKey, DhService service, int port)
    Register for the given service and port, conditional to the given key existing in etcd.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ResolverWriter

      public ResolverWriter(LeaseHandlerEtcd handler, String servicePath, byte[] uuid)
      Create a ResolverWriter object that can be used to register hosts for a given service path. A separate lease handler object should be created to manage a lease id and keep it live. This constructor takes that lease handler object as parameter, and uses it on registration to create a KV associated with the lease id of the lease handler
      Parameters:
      handler - a lease handler
      servicePath - the service path to register
      uuid - the uuid to use as the key for the registration KV
  • Method Details

    • register

      public boolean register(String host, int port)
      Register the given host and port using the service path and uuid given on construction.
      Parameters:
      host - the host to register
      port - the port to register
      Returns:
      true if the registration was successfully written, false otherwise.
    • register

      public boolean register(DhService service, int port) throws UnknownHostException
      Register for the given service, automatically calculating the host from (in order of precedence)
      • a property consisting of the upper case string for the service name, concatenated to @code{.registry.host}. Example: "PersistentQueryController.registry.host".
      • an environment variable consisting of the upper case string for the service name, concatenated to @code{_REGISTRY_HOST}. Example: "AUTHSERVER_REGISTRY_HOST"
      • an environment variable consisting of the upper case string for the service path with the leading '/' character removed, concatenated to @code{_REGISTRY_HOST}. Example: "CONTROLLER_REGISTRY_HOST".
      • the canonical form of the machine configured local host address, as returned by Java's @code{InetAddress.getLocalHost().getCanonicalHostName()}

      A log line will be written indicating the service and the host and port registered.

      Parameters:
      service - the service to register for
      port - the port for the registration
      Returns:
      true if the registration was successfully written, false otherwise.
      Throws:
      UnknownHostException - if no other means of calculating the host name are provided and the default @code{InetAddress.getLocalHost().getCanonicalHostName()} throws
    • registerConditional

      public boolean registerConditional(io.deephaven.shadow.jetcd.io.etcd.jetcd.ByteSequence conditionalKey, DhService service, int port) throws UnknownHostException
      Register for the given service and port, conditional to the given key existing in etcd.
      Parameters:
      conditionalKey - the key to check for existence
      service - the service to register
      port - the port to register
      Returns:
      true if the registration was successfully written, false otherwise.
      Throws:
      UnknownHostException
    • deregister

      public void deregister()
      Remove our registration.
    • close

      public void close()
      Stop using this object; calls deregister.