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; }
private void releaseLock(Procedure<TEnvironment> proc, boolean force) { TEnvironment env = getEnvironment(); // For how the framework works, we know that we will always have the lock // when we call releaseLock(), so we can avoid calling proc.hasLock() if (force || !proc.holdLock(env) || proc.isFinished()) { proc.doReleaseLock(env, store); } }
private void releaseLock(final Procedure proc, final boolean force) { final TEnvironment env = getEnvironment(); // For how the framework works, we know that we will always have the lock // when we call releaseLock(), so we can avoid calling proc.hasLock() if (force || !proc.holdLock(env)) { proc.doReleaseLock(env); } }
private void releaseLock(Procedure<TEnvironment> proc, boolean force) { TEnvironment env = getEnvironment(); // For how the framework works, we know that we will always have the lock // when we call releaseLock(), so we can avoid calling proc.hasLock() if (force || !proc.holdLock(env) || proc.isFinished()) { proc.doReleaseLock(env, store); } }
private LockState acquireLock(final Procedure proc) { final TEnvironment env = getEnvironment(); // hasLock() is used in conjunction with holdLock(). // This allows us to not rewrite or carry around the hasLock() flag // for every procedure. the hasLock() have meaning only if holdLock() is true. if (proc.holdLock(env) && proc.hasLock(env)) { return LockState.LOCK_ACQUIRED; } return proc.doAcquireLock(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; }
private void execCompletionCleanup(final Procedure proc) { final TEnvironment env = getEnvironment(); if (proc.holdLock(env) && proc.hasLock(env)) { releaseLock(proc, true); } try { proc.completionCleanup(env); } catch (Throwable e) { // Catch NullPointerExceptions or similar errors... LOG.error("CODE-BUG: uncatched runtime exception for procedure: " + proc, e); } }