private LockState acquireLock(Procedure<TEnvironment> proc) { TEnvironment env = getEnvironment(); // if holdLock is true, then maybe we already have the lock, so just return LOCK_ACQUIRED if // hasLock is true. if (proc.hasLock()) { return LockState.LOCK_ACQUIRED; } return proc.doAcquireLock(env, store); }
private void execCompletionCleanup(Procedure<TEnvironment> proc) { final TEnvironment env = getEnvironment(); if (proc.hasLock()) { LOG.warn("Usually this should not happen, we will release the lock before if the procedure" + " is finished, even if the holdLock is true, arrive here means we have some holes where" + " we do not release the lock. And the releaseLock below may fail since the procedure may" + " have already been deleted from the procedure store."); 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); } }
private <T extends Comparable<T>> void doAdd(FairQueue<T> fairq, Queue<T> queue, Procedure<?> proc, boolean addFront) { queue.add(proc, addFront); // For the following conditions, we will put the queue back into execution // 1. The procedure has already held the lock, or the lock has been restored when restarting, // which means it can be executed immediately. // 2. The exclusive lock for this queue has not been held. // 3. The given procedure has the exclusive lock permission for this queue. Supplier<String> reason = null; if (proc.hasLock()) { reason = () -> proc + " has lock"; } else if (proc.isLockedWhenLoading()) { reason = () -> proc + " restores lock when restarting"; } else if (!queue.getLockStatus().hasExclusiveLock()) { reason = () -> "the exclusive lock is not held by anyone when adding " + proc; } else if (queue.getLockStatus().hasLockAccess(proc)) { reason = () -> proc + " has the excusive lock access"; } if (reason != null) { addToRunQueue(fairq, queue, reason); } }
Procedure procA = pExecutor.getProcedure(procId); LOG.info("submit SCP procedureA"); util.waitFor(5000, () -> procA.hasLock()); LOG.info("procedureA acquired the lock"); assertEquals(Procedure.LockState.LOCK_EVENT_WAIT,
if (proc.hasLock()) { builder.setLocked(true);
private LockState acquireLock(Procedure<TEnvironment> proc) { TEnvironment env = getEnvironment(); // if holdLock is true, then maybe we already have the lock, so just return LOCK_ACQUIRED if // hasLock is true. if (proc.hasLock()) { return LockState.LOCK_ACQUIRED; } return proc.doAcquireLock(env, store); }
private void execCompletionCleanup(Procedure<TEnvironment> proc) { final TEnvironment env = getEnvironment(); if (proc.hasLock()) { LOG.warn("Usually this should not happen, we will release the lock before if the procedure" + " is finished, even if the holdLock is true, arrive here means we have some holes where" + " we do not release the lock. And the releaseLock below may fail since the procedure may" + " have already been deleted from the procedure store."); 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); } }
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); } }
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); }
if (proc.hasLock()) { builder.setLocked(true);