Move LeaderInitiators to later phase
There is a race condition when Zookeeper `LeaderInitiator` may start earlier than `CuratorFramework` it depends on. This is because both of them are configured for the same default `phase` (`0`) * Make `LeaderInitiator` and `LockRegistryLeaderInitiator` to be started in the `Integer.MAX_VALUE - 1000` phase by default - as late as possible * Make `CuratorFrameworkFactoryBean` to start in the `Integer.MIN_VALUE + 1000` phase - as early as possible * Alight lifecycle properties from the `LeaderInitiatorFactoryBean` with defaults in the `LeaderInitiator` * Simplify a `LeaderListenerParser` to rely on the `LeaderInitiatorFactoryBean` **Cherry-pick to 5.0.x**
This commit is contained in:
committed by
Gary Russell
parent
ed07777b4e
commit
15eae700a3
@@ -151,7 +151,7 @@ public class LockRegistryLeaderInitiator implements SmartLifecycle, DisposableBe
|
||||
/**
|
||||
* @see SmartLifecycle which is an extension of org.springframework.context.Phased
|
||||
*/
|
||||
private int phase;
|
||||
private int phase = Integer.MAX_VALUE - 1000;
|
||||
|
||||
/**
|
||||
* Flag that indicates whether the leadership election for this {@link #candidate} is
|
||||
|
||||
Reference in New Issue
Block a user