ILeaseManager Interface
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
If you wish to have EventProcessorHost store leases somewhere other than Azure Storage, you can write your own lease manager using this interface.
The Azure Storage managers use the same storage for both lease and checkpoints, so both interfaces are implemented by the same class. You are free to do the same thing if you have a unified store for both types of data.
This interface does not specify initialization methods because we have no way of knowing what information your implementation will require.
public interface ILeaseManager
type ILeaseManager = interface
Public Interface ILeaseManager
Properties
LeaseDuration |
Mostly useful for testing. |
LeaseRenewInterval |
Allows a lease manager implementation to specify to PartitionManager how often it should scan leases and renew them. In order to redistribute leases in a timely fashion after a host ceases operating, we recommend a relatively short interval, such as ten seconds. Obviously it should be less than half of the lease length, to prevent accidental expiration. |
Methods
AcquireLeaseAsync(Lease) |
Acquire the lease on the desired partition for this EventProcessorHost. Note that it is legal to acquire a lease that is already owned by another host. Lease-stealing is how partitions are redistributed when additional hosts are started. |
CreateLeaseIfNotExistsAsync(String) |
Create in the store the lease info for the given partition, if it does not exist. Do nothing if it does exist in the store already. |
CreateLeaseStoreIfNotExistsAsync() |
Create the lease store if it does not exist, do nothing if it does exist. |
DeleteLeaseAsync(Lease) |
Delete the lease info for the given partition from the store. If there is no stored lease for the given partition, that is treated as success. |
DeleteLeaseStoreAsync() |
Not used by EventProcessorHost, but a convenient function to have for testing. |
GetAllLeasesAsync() |
Return the lease info for all partitions. A typical implementation could just call GetLeaseAsync() on all partitions. |
GetLeaseAsync(String) |
Return the lease info for the specified partition. Can return null if no lease has been created in the store for the specified partition. |
LeaseStoreExistsAsync() |
Does the lease store exist? |
ReleaseLeaseAsync(Lease) |
Give up a lease currently held by this host. If the lease has been stolen, or expired, releasing it is unnecessary, and will fail if attempted. |
RenewLeaseAsync(Lease) |
Renew a lease currently held by this host. If the lease has been stolen, or expired, or released, it is not possible to renew it. You will have to call getLease() and then acquireLease() again. |
UpdateLeaseAsync(Lease) |
Update the store with the information in the provided lease. It is necessary to currently hold a lease in order to update it. If the lease has been stolen, or expired, or released, it cannot be updated. Updating should renew the lease before performing the update to avoid lease expiration during the process. |
Applies to
Azure SDK for .NET