BaseLease Class

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

public class BaseLease

BaseLease 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.

This lightweight base exists to allow ILeaseManager.getAllLeases to operate as quickly as possible for some lease manager implementations, loading the entire contents of a lease form the store may be expensive. BaseLease contains only the minimum amount of information required to allow PartitionScanner to operate.

Note that a Lease object just carries information about a partition lease. The APIs to acquire/renew/release a lease are all on ILeaseManager.

Constructor Summary

Constructor Description
BaseLease()

Do not use; added only for GSon deserializer

BaseLease(BaseLease source)

Create a BaseLease by duplicating the given Lease.

BaseLease(String partitionId)

Create a BaseLease for the given partition.

BaseLease(String partitionId, String owner, boolean isOwned)

Create and populate a BaseLease for the given partition.

Method Summary

Modifier and Type Method and Description
int compareTo(BaseLease other)
boolean getIsOwned()

Get the owned state of the lease.

String getOwner()

The owner of a lease is the name of the EventProcessorHost instance which currently holds the lease.

String getPartitionId()

Returns the id of the partition that this Lease is for. Immutable so there is no corresponding setter.

boolean isOwnedBy(String possibleOwner)

Convenience function for comparing possibleOwner against this.owner

void setIsOwned(boolean newState)

Set the owned state of the lease.

void setOwner(String owner)

Set the owner string. Used when a host steals a lease.

Constructor Details

BaseLease

protected BaseLease()

Do not use; added only for GSon deserializer

BaseLease

public BaseLease(BaseLease source)

Create a BaseLease by duplicating the given Lease.

Parameters:

source - BaseLease to clone.

BaseLease

public BaseLease(String partitionId)

Create a BaseLease for the given partition.

Parameters:

partitionId - Partition id for this lease.

BaseLease

public BaseLease(String partitionId, String owner, boolean isOwned)

Create and populate a BaseLease for the given partition.

Parameters:

partitionId - Partition id for this lease.
owner - Current owner of this lease, or empty.
isOwned - True if the lease is owned, false if not.

Method Details

compareTo

public int compareTo(BaseLease other)

Parameters:

other

getIsOwned

public boolean getIsOwned()

Get the owned state of the lease.

Returns:

true if the lease is owned, or false if it is not

getOwner

public String getOwner()

The owner of a lease is the name of the EventProcessorHost instance which currently holds the lease.

Returns:

name of the owning instance

getPartitionId

public String getPartitionId()

Returns the id of the partition that this Lease is for. Immutable so there is no corresponding setter.

Returns:

partition id

isOwnedBy

public boolean isOwnedBy(String possibleOwner)

Convenience function for comparing possibleOwner against this.owner

Parameters:

possibleOwner - name to check

Returns:

true if possibleOwner is the same as this.owner, false otherwise

setIsOwned

public void setIsOwned(boolean newState)

Set the owned state of the lease.

Parameters:

newState - true if the lease is owned, or false if it is not

setOwner

public void setOwner(String owner)

Set the owner string. Used when a host steals a lease.

Parameters:

owner - name of the new owning instance

Applies to