Class CompleteLease

  • All Implemented Interfaces:
    Comparable<BaseLease>

    public class CompleteLease
    extends BaseLease
    CompleteLease class is public so that advanced users can implement an ILeaseManager. Unless you are implementing ILeaseManager you should not have to deal with objects of this class or derived classes directly.

    CompleteLease carries around complete information about a lease. By itself, it has the epoch. Any lease manager implementation can derive from this class to add data which the lease manager needs to function -- see AzureBlobLease for an example. Having two distinct classes allows the code to clearly express which variety of lease any variable holds or a method requires, and avoids the problem of accidentally supplying a lightweight BaseLease to a method which needs the lease-manager-specific fields.

    • Field Detail

      • epoch

        protected long epoch
    • Constructor Detail

      • CompleteLease

        protected CompleteLease()
        Do not use; added only for GSon deserializer
      • CompleteLease

        public CompleteLease​(String partitionId)
        Create a CompleteLease for the given partition.
        Parameters:
        partitionId - Partition id for this lease.
      • CompleteLease

        public CompleteLease​(CompleteLease source)
        Create a Lease by duplicating the given Lease.
        Parameters:
        source - Lease to clone.
    • Method Detail

      • getEpoch

        public long getEpoch()
        Epoch is a concept used by Event Hub receivers. If a receiver is created on a partition with a higher epoch than the existing receiver, the previous receiver is forcibly disconnected. Attempting to create a receiver with a lower epoch than the existing receiver will fail. The Lease carries the epoch around so that when a host instance steals a lease, it can create a receiver with a higher epoch.
        Returns:
        the epoch of the current receiver
      • setEpoch

        public void setEpoch​(long epoch)
        Set the epoch value. Used to update the lease after creating a new receiver with a higher epoch.
        Parameters:
        epoch - updated epoch value
      • incrementEpoch

        public long incrementEpoch()
        The most common operation on the epoch value is incrementing it after stealing a lease. This convenience function replaces the get-increment-set that would otherwise be required.
        Returns:
        The new value of the epoch.