Package io.deephaven.kv.etcd.lease
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 mappedV- 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 Summary
ConstructorsModifierConstructorDescriptionprotectedRenewingLeaseManagerImpl(@NotNull com.fishlib.io.logger.Logger log, @NotNull String dataIdentifier) Constructor that creates newDeephavenLeaseHandlerand stores the related key-value combination provided to be used in recreation. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds associated key-value to be stored and associates them with the provided lease.@NotNull StringReturns the data identifier associated with the lease that is being managedprotected abstract intReturns the implementation specific configured recreate retry delay in seconds.protected abstract voidNotifies the implementation class the lease has been revoked successfully.recreateRegistrations(@NotNull String dataIdentifier) Attempts to recreate the registrations asynchronously with configured delay until registration is successful.protected abstract @NotNull DeephavenLeaseregister(K key, V value, @Nullable DeephavenLease lease) Registration logic of implementing classes should be defined here.voidrevoke()Revoke the associated lease and stop managing it
-
Constructor Details
-
RenewingLeaseManagerImpl
protected RenewingLeaseManagerImpl(@NotNull @NotNull com.fishlib.io.logger.Logger log, @NotNull @NotNull String dataIdentifier) Constructor that creates newDeephavenLeaseHandlerand stores the related key-value combination provided to be used in recreation.- Parameters:
log- The passed in logger for the associated service that is registeringdataIdentifier- The dataIdentifier (e.g. process name) associated with the lease.
-
-
Method Details
-
getDataIdentifier
Description copied from interface:RenewingLeaseManagerReturns the data identifier associated with the lease that is being managed- Specified by:
getDataIdentifierin interfaceRenewingLeaseManager<K,V> - Returns:
- The associated data identifier of the managed lease
-
add
Description copied from interface:RenewingLeaseManagerAdds associated key-value to be stored and associates them with the provided lease. These key-values will be used to recreate registrations.- Specified by:
addin interfaceRenewingLeaseManager<K,V> - Parameters:
key- The mapping key used to register the valuevalue- The value that should be registered under the lease- Throws:
RetryableRenewingLeaseManagerException- if underlying exception is or caused byIOExceptionRenewingLeaseManagerException- 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:RenewingLeaseManagerAttempts 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:
recreateRegistrationsin interfaceRenewingLeaseManager<K,V> - Parameters:
dataIdentifier- The identifier value used in the original lease (e.g. process name)- Returns:
Futurethat holdsReCreateRegistrationResponsewhich indicates if retryable error occurred and recreateRegistrations should be retried- Throws:
RenewingLeaseManagerException- if an exception other thanIOExceptionis encounteredIOExceptionis an expected exception which will be logged and recreateRegistration will continue to be attempted until recreation of registrations is successful
-
revoke
Description copied from interface:RenewingLeaseManagerRevoke the associated lease and stop managing it- Specified by:
revokein interfaceRenewingLeaseManager<K,V> - Throws:
RenewingLeaseManagerException- if an exception other thanIOExceptionis 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 storesvalue- The value to be registered in backing storelease- Existing lease if one is present- Returns:
DeephavenLeaseif registration is successful- ImplNote:
RenewingLeaseManager.recreateRegistrations(String)may be invoked in the event of a recovery,IOExceptionmay 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
Notifies the implementation class the lease has been revoked successfully.- Parameters:
dataIdentifier- The associated identifier used to create the lease (e.g. process name)
-