Class ResolverWriter
java.lang.Object
io.deephaven.enterprise.etcdclient.resolver.ResolverWriter
Class used to register (write in etcd) entries in the DH service resolver
-
Constructor Summary
ConstructorsConstructorDescriptionResolverWriter(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 TypeMethodDescriptionvoidclose()Stop using this object; calls deregister.voidRemove our registration.booleanRegister 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}.booleanRegister the given host and port using the service path and uuid given on construction.booleanregisterConditional(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.
-
Constructor Details
-
ResolverWriter
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 handlerservicePath- the service path to registeruuid- the uuid to use as the key for the registration KV
-
-
Method Details
-
register
Register the given host and port using the service path and uuid given on construction.- Parameters:
host- the host to registerport- the port to register- Returns:
- true if the registration was successfully written, false otherwise.
-
register
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 forport- 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 existenceservice- the service to registerport- 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.
-