Class BaseLease

  • All Implemented Interfaces:
    Comparable<BaseLease>
    Direct Known Subclasses:
    CompleteLease

    public class BaseLease
    extends Object
    implements Comparable<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 Detail

      • BaseLease

        protected BaseLease()
        Do not use; added only for GSon deserializer
      • 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.
      • BaseLease

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

      • 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
      • 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
      • 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
      • getIsOwned

        public boolean getIsOwned()
        Get the owned state of the lease.
        Returns:
        true if the lease is owned, or false if it is not
      • 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
      • 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object