Class MixedLeaseFormatSpec

java.lang.Object
me.ahoo.cosid.test.machine.lease.MixedLeaseFormatSpec

public abstract class MixedLeaseFormatSpec extends Object
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 Details

    • MixedLeaseFormatSpec

      public MixedLeaseFormatSpec()
  • Method Details

    • v34

      protected abstract MachineIdDistributor v34()
      A new 3.4 distributor, with its own local state storage.
    • v40

      protected abstract MachineIdDistributor 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 to instanceId and write back the very same last timestamp, in the 3.4 format.
    • randomDistributeAndRevertNeverShareMachineIds

      @Test public void randomDistributeAndRevertNeverShareMachineIds()
    • eachFormatTakesOverTheOthersExpiredLease

      @Test public void eachFormatTakesOverTheOthersExpiredLease() throws InterruptedException
      Throws:
      InterruptedException
    • eachFormatTakesTheOthersReleasedMachineId

      @Test public void eachFormatTakesTheOthersReleasedMachineId()
    • releasedThenTakenBy34WithTheSameTimestampIsNotTakenAgain

      @Test public void releasedThenTakenBy34WithTheSameTimestampIsNotTakenAgain() throws InterruptedException
      A 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