public ClusterState getState() { LockGuard stateLock = getStateLock(); return stateLock.isLocked() ? ClusterState.IN_TRANSITION : state; }
public ClusterState getState() { LockGuard stateLock = getStateLock(); return stateLock.isLocked() ? ClusterState.IN_TRANSITION : state; }
public boolean rollbackClusterState(String txnId) { clusterServiceLock.lock(); try { final LockGuard currentLock = getStateLock(); if (!currentLock.allowsUnlock(txnId)) { return false; } logger.fine("Rolling back cluster state transaction: " + txnId); stateLockRef.set(LockGuard.NOT_LOCKED); // if state allows join after rollback, then remove all members which left during transaction. if (state.isJoinAllowed()) { node.getClusterService().getMembershipManager().removeMembersDeadInNotJoinableState(); } return true; } finally { clusterServiceLock.unlock(); } }
public boolean rollbackClusterState(String txnId) { clusterServiceLock.lock(); try { final LockGuard currentLock = getStateLock(); if (!currentLock.allowsUnlock(txnId)) { return false; } logger.fine("Rolling back cluster state transaction: " + txnId); stateLockRef.set(LockGuard.NOT_LOCKED); // if state allows join after rollback, then remove all members which left during transaction. if (state.isJoinAllowed()) { node.getClusterService().getMembershipManager().removeAllMissingMembers(); } return true; } finally { clusterServiceLock.unlock(); } }
private void lockOrExtendClusterState(Address initiator, String txnId, long leaseTime) { Preconditions.checkPositive(leaseTime, "Lease time should be positive!"); LockGuard currentLock = getStateLock(); if (!currentLock.allowsLock(txnId)) { throw new TransactionException("Locking failed for " + initiator + ", tx: " + txnId + ", current state: " + toString()); } long newLeaseTime = currentLock.getRemainingTime() + leaseTime; if (newLeaseTime < 0L) { newLeaseTime = Long.MAX_VALUE; } stateLockRef.set(new LockGuard(initiator, txnId, newLeaseTime)); }
private void lockOrExtendClusterState(Address initiator, String txnId, long leaseTime) { Preconditions.checkPositive(leaseTime, "Lease time should be positive!"); LockGuard currentLock = getStateLock(); if (!currentLock.allowsLock(txnId)) { throw new TransactionException("Locking failed for " + initiator + ", tx: " + txnId + ", current state: " + toString()); } long newLeaseTime = currentLock.getRemainingTime() + leaseTime; if (newLeaseTime < 0L) { newLeaseTime = Long.MAX_VALUE; } stateLockRef.set(new LockGuard(initiator, txnId, newLeaseTime)); }
public void commitClusterState(ClusterStateChange stateChange, Address initiator, String txnId, boolean isTransient) { Preconditions.checkNotNull(stateChange); stateChange.validate(); clusterServiceLock.lock(); try { final LockGuard stateLock = getStateLock(); if (!stateLock.allowsUnlock(txnId)) { throw new TransactionException( "Cluster state change [" + state + " -> " + stateChange + "] failed for " + initiator + ", current state: " + stateToString()); } if (stateChange.isOfType(ClusterState.class)) { ClusterState newState = (ClusterState) stateChange.getNewState(); doSetClusterState(newState, isTransient); // if state is changed to allow joins, then remove all members which left while not active. if (newState.isJoinAllowed()) { node.getClusterService().getMembershipManager().removeAllMissingMembers(); } } else if (stateChange.isOfType(Version.class)) { // version is validated on cluster-state-lock, thus we can commit without checking compatibility Version newVersion = (Version) stateChange.getNewState(); logger.info("Cluster version set to " + newVersion); doSetClusterVersion(newVersion); } else { throw new IllegalArgumentException("Illegal ClusterStateChange of type " + stateChange.getType() + "."); } } finally { clusterServiceLock.unlock(); } }
public void commitClusterState(ClusterStateChange stateChange, Address initiator, String txnId, boolean isTransient) { Preconditions.checkNotNull(stateChange); stateChange.validate(); clusterServiceLock.lock(); try { final LockGuard stateLock = getStateLock(); if (!stateLock.allowsUnlock(txnId)) { throw new TransactionException( "Cluster state change [" + state + " -> " + stateChange + "] failed for " + initiator + ", current state: " + stateToString()); } if (stateChange.isOfType(ClusterState.class)) { ClusterState newState = (ClusterState) stateChange.getNewState(); doSetClusterState(newState, isTransient); // if state is changed to allow joins, then remove all members which left while not active. if (newState.isJoinAllowed()) { node.getClusterService().getMembershipManager().removeMembersDeadInNotJoinableState(); } } else if (stateChange.isOfType(Version.class)) { // version is validated on cluster-state-lock, thus we can commit without checking compatibility Version newVersion = (Version) stateChange.getNewState(); logger.info("Cluster version set to " + newVersion); doSetClusterVersion(newVersion); } else { throw new IllegalArgumentException("Illegal ClusterStateChange of type " + stateChange.getType() + "."); } } finally { clusterServiceLock.unlock(); } }