Package me.ahoo.cosid.machine.lease
Class LeaseStoreMachineIdDistributor
java.lang.Object
me.ahoo.cosid.machine.AbstractMachineIdDistributor
me.ahoo.cosid.machine.lease.LeaseStoreMachineIdDistributor
- All Implemented Interfaces:
MachineIdDistribute,MachineIdDistributor
A
MachineIdDistributor on top of a MachineLeaseStore, through
MachineLeaseManager.
It reuses everything AbstractMachineIdDistributor provides: local state, the clock-backwards watermark,
and the guarder and fail-fast lease on top. It keeps the current Lease of every instance it distributed, so
that guard and revert are compare-and-set on the version it last wrote.
- Since:
- 3.4.0
-
Field Summary
Fields inherited from class me.ahoo.cosid.machine.AbstractMachineIdDistributor
NOT_FOUND_LAST_STAMPFields inherited from interface me.ahoo.cosid.machine.MachineIdDistributor
FOREVER_SAFE_GUARD_DURATION -
Constructor Summary
ConstructorsConstructorDescriptionLeaseStoreMachineIdDistributor(MachineLeaseManager distributeLeaseManager, MachineLeaseManager leaseManager, MachineStateStorage machineStateStorage, ClockBackwardsSynchronizer clockBackwardsSynchronizer) Create a distributor whose distribution, usually once at startup, runs on its own lease manager, for example on a store with a longer timeout: the first call also pays for connecting.LeaseStoreMachineIdDistributor(MachineLeaseManager leaseManager, MachineStateStorage machineStateStorage, ClockBackwardsSynchronizer clockBackwardsSynchronizer) LeaseStoreMachineIdDistributor(MachineLeaseStore store, MachineStateStorage machineStateStorage, ClockBackwardsSynchronizer clockBackwardsSynchronizer) -
Method Summary
Modifier and TypeMethodDescriptionprotected MachineStatedistributeRemote(String namespace, int machineBit, InstanceId instanceId, Duration safeGuardDuration) protected voidguardRemote(String namespace, InstanceId instanceId, MachineState machineState, Duration safeGuardDuration) protected voidrevertRemote(String namespace, InstanceId instanceId, MachineState machineState) Methods inherited from class me.ahoo.cosid.machine.AbstractMachineIdDistributor
distribute, guard, refreshLocalState, revert
-
Constructor Details
-
LeaseStoreMachineIdDistributor
public LeaseStoreMachineIdDistributor(MachineLeaseStore store, MachineStateStorage machineStateStorage, ClockBackwardsSynchronizer clockBackwardsSynchronizer) -
LeaseStoreMachineIdDistributor
public LeaseStoreMachineIdDistributor(MachineLeaseManager leaseManager, MachineStateStorage machineStateStorage, ClockBackwardsSynchronizer clockBackwardsSynchronizer) -
LeaseStoreMachineIdDistributor
public LeaseStoreMachineIdDistributor(MachineLeaseManager distributeLeaseManager, MachineLeaseManager leaseManager, MachineStateStorage machineStateStorage, ClockBackwardsSynchronizer clockBackwardsSynchronizer) Create a distributor whose distribution, usually once at startup, runs on its own lease manager, for example on a store with a longer timeout: the first call also pays for connecting. Guard, revert and every re-claim after a lost lease, which run under a lock, useleaseManager.
-
-
Method Details
-
getDistributeLeaseManager
-
getLeaseManager
-
distributeRemote
protected MachineState distributeRemote(String namespace, int machineBit, InstanceId instanceId, Duration safeGuardDuration) - Specified by:
distributeRemotein classAbstractMachineIdDistributor
-
guardRemote
protected void guardRemote(String namespace, InstanceId instanceId, MachineState machineState, Duration safeGuardDuration) - Specified by:
guardRemotein classAbstractMachineIdDistributor
-
revertRemote
- Specified by:
revertRemotein classAbstractMachineIdDistributor
-