CompleteLease Class

  • java.lang.Object
    • Comparable<BaseLease>
      • BaseLease
        • com.microsoft.azure.eventprocessorhost.CompleteLease

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 Summary

Modifier and Type Field and Description
long epoch

Constructor Summary

Constructor Description
CompleteLease()

Do not use; added only for GSon deserializer

CompleteLease(CompleteLease source)

Create a Lease by duplicating the given Lease.

CompleteLease(String partitionId)

Create a CompleteLease for the given partition.

Method Summary

Modifier and Type Method and Description
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.

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.

void setEpoch(long epoch)

Set the epoch value. Used to update the lease after creating a new receiver with a higher epoch.

Inherited Members

Field Details

epoch

protected long epoch= -1

Constructor Details

CompleteLease

protected CompleteLease()

Do not use; added only for GSon deserializer

CompleteLease

public CompleteLease(CompleteLease source)

Create a Lease by duplicating the given Lease.

Parameters:

source - Lease to clone.

CompleteLease

public CompleteLease(String partitionId)

Create a CompleteLease for the given partition.

Parameters:

partitionId - Partition id for this lease.

Method Details

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

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.

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

Applies to