Class CosIdGuardDistribute
java.lang.Object
me.ahoo.cosid.machine.GuardDistribute
me.ahoo.cosid.spring.boot.starter.machine.CosIdGuardDistribute
- All Implemented Interfaces:
MachineIdDistribute,org.springframework.beans.factory.DisposableBean
public class CosIdGuardDistribute
extends GuardDistribute
implements org.springframework.beans.factory.DisposableBean
The starter's
GuardDistribute: it also reverts the machine ids it distributed when the context is destroyed
without being stopped, for example when a bean fails while the context starts. Otherwise those machine ids would stay
taken for the whole safe guard duration.
Each machine id is reverted once: on a normal shutdown CosIdMachineIdLifecycle reverts them through
revert(NamespacedInstanceId), and destroy() has nothing left to do.
-
Constructor Summary
ConstructorsConstructorDescriptionCosIdGuardDistribute(MachineIdDistributor machineIdDistributor, MachineIdGuarder machineIdGuarder) -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()voidrevert(NamespacedInstanceId distributedInstance) Revert the machine id of the instance, unless it was already reverted.Methods inherited from class me.ahoo.cosid.machine.GuardDistribute
distribute, getDistributed, getLease
-
Constructor Details
-
CosIdGuardDistribute
public CosIdGuardDistribute(MachineIdDistributor machineIdDistributor, MachineIdGuarder machineIdGuarder)
-
-
Method Details
-
revert
Revert the machine id of the instance, unless it was already reverted. The lease is released first, so that no id is generated with the machine id once it can be handed to another instance. -
destroy
public void destroy()- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean
-