HBASE-19642 Fix locking for peer modification procedure
This commit is contained in:
parent
ac07e07988
commit
b40c426806
|
@ -46,6 +46,8 @@ public abstract class ModifyPeerProcedure
|
|||
|
||||
protected String peerId;
|
||||
|
||||
private volatile boolean locked;
|
||||
|
||||
// used to keep compatible with old client where we can only returns after updateStorage.
|
||||
protected ProcedurePrepareLatch latch;
|
||||
|
||||
|
@ -145,16 +147,29 @@ public abstract class ModifyPeerProcedure
|
|||
|
||||
@Override
|
||||
protected LockState acquireLock(MasterProcedureEnv env) {
|
||||
return env.getProcedureScheduler().waitPeerExclusiveLock(this, peerId)
|
||||
? LockState.LOCK_EVENT_WAIT
|
||||
: LockState.LOCK_ACQUIRED;
|
||||
if (env.getProcedureScheduler().waitPeerExclusiveLock(this, peerId)) {
|
||||
return LockState.LOCK_EVENT_WAIT;
|
||||
}
|
||||
locked = true;
|
||||
return LockState.LOCK_ACQUIRED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void releaseLock(MasterProcedureEnv env) {
|
||||
locked = false;
|
||||
env.getProcedureScheduler().wakePeerExclusiveLock(this, peerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean holdLock(MasterProcedureEnv env) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasLock(MasterProcedureEnv env) {
|
||||
return locked;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rollbackState(MasterProcedureEnv env, PeerModificationState state)
|
||||
throws IOException, InterruptedException {
|
||||
|
|
Loading…
Reference in New Issue