-
- private final Semaphore roleChangeGuard = new Semaphore(1, true);
-
- private final LifecycleConductor conductor;
-
- public RoleContextImpl(final NodeId nodeId, final EntityOwnershipService entityOwnershipService, final Entity entity, final Entity txEntity, final LifecycleConductor lifecycleConductor) {
- this.entityOwnershipService = entityOwnershipService;
- this.entity = entity;
- this.txEntity = txEntity;
- this.nodeId = nodeId;
- this.conductor = lifecycleConductor;
- }
-
- @Override
- public boolean initialization() {
- LOG.info("Initialization main candidate for node {}", nodeId);
- return registerCandidate(this.entity);
- }
-
- @Override
- public void unregisterAllCandidates() {
- LOG.info("Role context closed, unregistering all candidates for ownership for node {}", nodeId);
- if (isMainCandidateRegistered()) {
- unregisterCandidate(this.entity);
- }
- if (isTxCandidateRegistered()) {
- unregisterCandidate(this.txEntity);
- }
+ private final HashedWheelTimer hashedWheelTimer;
+ private final DeviceInfo deviceInfo;
+ private CONTEXT_STATE state;
+ private final RoleManager myManager;
+ private ClusterInitializationPhaseHandler clusterInitializationPhaseHandler;
+ private final LifecycleService lifecycleService;
+
+ RoleContextImpl(final DeviceInfo deviceInfo,
+ final HashedWheelTimer hashedWheelTimer,
+ final RoleManager myManager,
+ final LifecycleService lifecycleService) {
+ this.deviceInfo = deviceInfo;
+ this.state = CONTEXT_STATE.WORKING;
+ this.myManager = myManager;
+ this.hashedWheelTimer = hashedWheelTimer;
+ this.lifecycleService = lifecycleService;