final void restoreLock(TEnvironment env) { if (!lockedWhenLoading) { LOG.debug("{} didn't hold the lock before restarting, skip acquiring lock.", this); return; } if (isFinished()) { LOG.debug("{} is already finished, skip acquiring lock.", this); return; } if (isBypass()) { LOG.debug("{} is already bypassed, skip acquiring lock.", this); return; } // this can happen if the parent stores the sub procedures but before it can // release its lock, the master restarts if (getState() == ProcedureState.WAITING && !holdLock(env)) { LOG.debug("{} is in WAITING STATE, and holdLock=false, skip acquiring lock.", this); lockedWhenLoading = false; return; } LOG.debug("{} held the lock before restarting, call acquireLock to restore it.", this); LockState state = acquireLock(env); assert state == LockState.LOCK_ACQUIRED; }
/** * Internal method called by the ProcedureExecutor that starts the user-level code acquireLock(). */ final LockState doAcquireLock(TEnvironment env, ProcedureStore store) { if (waitInitialized(env)) { return LockState.LOCK_EVENT_WAIT; } if (lockedWhenLoading) { // reset it so we will not consider it anymore lockedWhenLoading = false; locked = true; // Here we return without persist the locked state, as lockedWhenLoading is true means // that the locked field of the procedure stored in procedure store is true, so we do not need // to store it again. return LockState.LOCK_ACQUIRED; } LockState state = acquireLock(env); if (state == LockState.LOCK_ACQUIRED) { locked = true; // persist that we have held the lock. This must be done before we actually execute the // procedure, otherwise when restarting, we may consider the procedure does not have a lock, // but it may have already done some changes as we have already executed it, and if another // procedure gets the lock, then the semantic will be broken if the holdLock is true, as we do // not expect that another procedure can be executed in the middle. store.update(this); } return state; }
/** * Internal method called by the ProcedureExecutor that starts the user-level code acquireLock(). */ @InterfaceAudience.Private protected LockState doAcquireLock(final TEnvironment env) { return acquireLock(env); }
final void restoreLock(TEnvironment env) { if (!lockedWhenLoading) { LOG.debug("{} didn't hold the lock before restarting, skip acquiring lock.", this); return; } if (isFinished()) { LOG.debug("{} is already finished, skip acquiring lock.", this); return; } if (isBypass()) { LOG.debug("{} is already bypassed, skip acquiring lock.", this); return; } // this can happen if the parent stores the sub procedures but before it can // release its lock, the master restarts if (getState() == ProcedureState.WAITING && !holdLock(env)) { LOG.debug("{} is in WAITING STATE, and holdLock=false, skip acquiring lock.", this); lockedWhenLoading = false; return; } LOG.debug("{} held the lock before restarting, call acquireLock to restore it.", this); LockState state = acquireLock(env); assert state == LockState.LOCK_ACQUIRED; }
/** * Internal method called by the ProcedureExecutor that starts the user-level code acquireLock(). */ final LockState doAcquireLock(TEnvironment env, ProcedureStore store) { if (waitInitialized(env)) { return LockState.LOCK_EVENT_WAIT; } if (lockedWhenLoading) { // reset it so we will not consider it anymore lockedWhenLoading = false; locked = true; // Here we return without persist the locked state, as lockedWhenLoading is true means // that the locked field of the procedure stored in procedure store is true, so we do not need // to store it again. return LockState.LOCK_ACQUIRED; } LockState state = acquireLock(env); if (state == LockState.LOCK_ACQUIRED) { locked = true; // persist that we have held the lock. This must be done before we actually execute the // procedure, otherwise when restarting, we may consider the procedure does not have a lock, // but it may have already done some changes as we have already executed it, and if another // procedure gets the lock, then the semantic will be broken if the holdLock is true, as we do // not expect that another procedure can be executed in the middle. store.update(this); } return state; }
final Procedure proc = subprocStack.get(stackTail); if (!reuseLock && !proc.acquireLock(getEnvironment())) {
if (proc.acquireLock(getEnvironment())) { execProcedure(procStack, proc); proc.releaseLock(getEnvironment());