Package me.ahoo.cosid.machine.lease
Class Lease
java.lang.Object
me.ahoo.cosid.machine.lease.Lease
A machine id held by an instance, as stored by a
MachineLeaseStore.
A lease keeps three separate values:
watermark: the last timestamp the machine id may have been used for, which the next owner must not go back to (its clock-backwards watermark). It never decreases, and renewing does not move it.renewed at: the store time of the last claim or renewal, which decides expiry.version: an opaque token that changes on every write.MachineLeaseStore.renew(me.ahoo.cosid.machine.lease.Lease, long)andMachineLeaseStore.release(me.ahoo.cosid.machine.lease.Lease, long)only succeed with the current version, so an owner whose lease was taken over in between finds out instead of overwriting the new owner.
- Since:
- 3.4.0
-
Constructor Summary
ConstructorsConstructorDescriptionLease(String namespace, InstanceId instanceId, int machineId, long watermark, long renewedAt, long version) Create a lease. -
Method Summary
Modifier and TypeMethodDescriptionbooleanintlongThe store time of the last claim or renewal: the lease expires a safe-guard duration after it.longlongThe last timestamp the machine id may have been used for: the owner waits until its clock passes it.inthashCode()booleanisStable()toString()
-
Constructor Details
-
Lease
public Lease(String namespace, InstanceId instanceId, int machineId, long watermark, long renewedAt, long version) Create a lease.- Parameters:
watermark- the last timestamp the machine id may have been used forrenewedAt- the store time of the last claim or renewalversion- the token that changes on every write
-
-
Method Details
-
getNamespace
-
getInstanceId
-
isStable
public boolean isStable() -
getMachineId
public int getMachineId() -
getWatermark
public long getWatermark()The last timestamp the machine id may have been used for: the owner waits until its clock passes it. -
getRenewedAt
public long getRenewedAt()The store time of the last claim or renewal: the lease expires a safe-guard duration after it. -
getVersion
public long getVersion() -
toMachineState
-
equals
-
hashCode
public int hashCode() -
toString
-