Package me.ahoo.cosid.test.machine.lease
Class MixedLeaseFormatSpec
java.lang.Object
me.ahoo.cosid.test.machine.lease.MixedLeaseFormatSpec
Compatibility kit for the upgrade from 3.4: 3.4 instances (the 3.4 machine id distributor of a backend, writing the
3.4 format) and 4.0 instances (a
LeaseStoreMachineIdDistributor on the backend's MachineLeaseStore)
sharing one namespace never hold the same machine id, and each takes over the other's expired and released machine
ids.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidA 3.4 instance with a host clock behind takes a machine id that 4.0 released and writes back the very same timestamp: 4.0 must not take it from that live 3.4 owner, even though the 4.0 owner's last renewal is older than the safe guard.protected abstract voidtakeReleasedAs34WithTheSameTimestamp(String namespace, int machineId, String instanceId) Do what a 3.4 instance whose host clock is behind does when it takes a released machine id: give it toinstanceIdand write back the very same last timestamp, in the 3.4 format.protected abstract MachineIdDistributorv34()A new 3.4 distributor, with its own local state storage.protected abstract MachineIdDistributorv40()A new 4.0 distributor on the lease store, with its own local state storage.
-
Constructor Details
-
MixedLeaseFormatSpec
public MixedLeaseFormatSpec()
-
-
Method Details
-
v34
A new 3.4 distributor, with its own local state storage. -
v40
A new 4.0 distributor on the lease store, with its own local state storage. -
takeReleasedAs34WithTheSameTimestamp
protected abstract void takeReleasedAs34WithTheSameTimestamp(String namespace, int machineId, String instanceId) Do what a 3.4 instance whose host clock is behind does when it takes a released machine id: give it toinstanceIdand write back the very same last timestamp, in the 3.4 format. -
eachFormatTakesOverTheOthersExpiredLease
- Throws:
InterruptedException
-
eachFormatTakesTheOthersReleasedMachineId
@Test public void eachFormatTakesTheOthersReleasedMachineId() -
releasedThenTakenBy34WithTheSameTimestampIsNotTakenAgain
@Test public void releasedThenTakenBy34WithTheSameTimestampIsNotTakenAgain() throws InterruptedExceptionA 3.4 instance with a host clock behind takes a machine id that 4.0 released and writes back the very same timestamp: 4.0 must not take it from that live 3.4 owner, even though the 4.0 owner's last renewal is older than the safe guard.- Throws:
InterruptedException
-