Class RenewingLeaseManagerImpl<K,V>

java.lang.Object
io.deephaven.kv.etcd.lease.RenewingLeaseManagerImpl<K,V>
Type Parameters:
K - The type of Key for which the value is mapped
V - The type of value that would be registered using the lease
All Implemented Interfaces:
RenewingLeaseManager<K,V>

public abstract class RenewingLeaseManagerImpl<K,V> extends Object implements RenewingLeaseManager<K,V>
Generic implementation of RenewingLeaseManager
  • Constructor Details

    • RenewingLeaseManagerImpl

      protected RenewingLeaseManagerImpl(@NotNull @NotNull com.fishlib.io.logger.Logger log, @NotNull @NotNull String dataIdentifier)
      Constructor that creates new DeephavenLeaseHandler and stores the related key-value combination provided to be used in recreation.
      Parameters:
      log - The passed in logger for the associated service that is registering
      dataIdentifier - The dataIdentifier (e.g. process name) associated with the lease.
  • Method Details

    • getDataIdentifier

      @NotNull public @NotNull String getDataIdentifier()
      Description copied from interface: RenewingLeaseManager
      Returns the data identifier associated with the lease that is being managed
      Specified by:
      getDataIdentifier in interface RenewingLeaseManager<K,V>
      Returns:
      The associated data identifier of the managed lease
    • add

      public void add(@NotNull K key, @NotNull V value) throws RenewingLeaseManagerException
      Description copied from interface: RenewingLeaseManager
      Adds associated key-value to be stored and associates them with the provided lease. These key-values will be used to recreate registrations.
      Specified by:
      add in interface RenewingLeaseManager<K,V>
      Parameters:
      key - The mapping key used to register the value
      value - The value that should be registered under the lease
      Throws:
      RetryableRenewingLeaseManagerException - if underlying exception is or caused by IOException
      RenewingLeaseManagerException - All other errors will result in this exception being thrown
    • recreateRegistrations

      public Future<ReCreateRegistrationResponse> recreateRegistrations(@NotNull @NotNull String dataIdentifier) throws RenewingLeaseManagerException
      Description copied from interface: RenewingLeaseManager
      Attempts to recreate the registrations asynchronously with configured delay until registration is successful. All added key-values will be registered and associated with the same lease.
      Specified by:
      recreateRegistrations in interface RenewingLeaseManager<K,V>
      Parameters:
      dataIdentifier - The identifier value used in the original lease (e.g. process name)
      Returns:
      Future that holds ReCreateRegistrationResponse which indicates if retryable error occurred and recreateRegistrations should be retried
      Throws:
      RenewingLeaseManagerException - if an exception other than IOException is encountered IOException is an expected exception which will be logged and recreateRegistration will continue to be attempted until recreation of registrations is successful
    • revoke

      public void revoke() throws RenewingLeaseManagerException
      Description copied from interface: RenewingLeaseManager
      Revoke the associated lease and stop managing it
      Specified by:
      revoke in interface RenewingLeaseManager<K,V>
      Throws:
      RenewingLeaseManagerException - if an exception other than IOException is encountered
    • register

      @NotNull protected abstract @NotNull DeephavenLease register(@NotNull K key, @NotNull V value, @Nullable @Nullable DeephavenLease lease)
      Registration logic of implementing classes should be defined here.
      Parameters:
      key - The key used to register in backing stores
      value - The value to be registered in backing store
      lease - Existing lease if one is present
      Returns:
      DeephavenLease if registration is successful
      ImplNote:
      RenewingLeaseManager.recreateRegistrations(String) may be invoked in the event of a recovery, IOException may be the root cause of any encountered errors. These should result in the method failing to register.
    • getRecreateRetryDelayInSeconds

      protected abstract int getRecreateRetryDelayInSeconds()
      Returns the implementation specific configured recreate retry delay in seconds.
    • onRevoke

      protected abstract void onRevoke(@NotNull @NotNull String dataIdentifier)
      Notifies the implementation class the lease has been revoked successfully.
      Parameters:
      dataIdentifier - The associated identifier used to create the lease (e.g. process name)