@Override public String toString() { return "exclusiveLockOwner=" + (hasExclusiveLock() ? getExclusiveLockProcIdOwner() : "NONE") + ", sharedLockCount=" + getSharedLockCount() + ", waitingProcCount=" + queue.size(); } }
/** * Remove a chore procedure from the executor * @param chore the chore to remove * @return whether the chore is removed, or it will be removed later */ public boolean removeChore(ProcedureInMemoryChore<TEnvironment> chore) { chore.setState(ProcedureState.SUCCESS); return timeoutExecutor.remove(chore); }
private void testTimeoutEventProcedureDoubleExecution(final boolean killIfSuspended) throws Exception { TestTimeoutEventProcedure proc = new TestTimeoutEventProcedure(1000, 3); ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExecutor, true); ProcedureTestingUtility.setKillIfSuspended(procExecutor, killIfSuspended); long procId = procExecutor.submitProcedure(proc); ProcedureTestingUtility.testRecoveryAndDoubleExecution(procExecutor, procId, true); ProcedureTestingUtility.assertIsAbortException(procExecutor.getResult(proc.getProcId())); }
public static Throwable getExceptionCause(final Procedure<?> procInfo) { assert procInfo.isFailed(); Throwable cause = procInfo.getException().getCause(); return cause == null ? procInfo.getException() : cause; }
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(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); }
public int wakeWaitingProcedures(ProcedureScheduler scheduler) { int count = queue.size(); // wakeProcedure adds to the front of queue, so we start from last in the waitQueue' queue, so // that the procedure which was added first goes in the front for the scheduler queue. scheduler.addFront(queue.descendingIterator()); queue.clear(); return count; }
public boolean isExpired(long now, long evictTtl, long evictAckTtl) { return (hasClientAckTime() && (now - getClientAckTime()) >= evictAckTtl) || (now - procedure.getLastUpdate()) >= evictTtl; } }
/** * Return the id of the procedure which holds the exclusive lock, if exists. Or a negative value * which means no one holds the exclusive lock. * <p/> * Notice that, in HBase, we assume that the procedure id is positive, or at least non-negative. */ default long getExclusiveLockProcIdOwner() { Procedure<?> proc = getExclusiveLockOwnerProcedure(); return proc != null ? proc.getProcId() : -1L; }
@Override protected synchronized boolean setTimeoutFailure(TestProcEnv env) { setState(ProcedureProtos.ProcedureState.RUNNABLE); procExecutor.getScheduler().addFront(this); return false; // 'false' means that this procedure handled the timeout } }
@Override protected void afterReplay(final TestProcEnv env) { if (getState() == ProcedureState.WAITING_TIMEOUT) { event.suspend(); event.suspendIfNotReady(this); } }
@Override protected synchronized boolean setTimeoutFailure(ProcEnv env) { setState(ProcedureProtos.ProcedureState.RUNNABLE); env.getProcedureExecutor().getProcedureScheduler().addFront(this); return false; }
@Override protected Procedure[] execute(final TestProcEnv env) throws ProcedureSuspendedException { // Always suspend the procedure setTimeout(50000); setState(ProcedureProtos.ProcedureState.WAITING_TIMEOUT); skipPersistence(); throw new ProcedureSuspendedException(); }
@Override protected Procedure[] execute(TestProcEnv env) throws InterruptedException { super.execute(env); return isFailed() ? null : new Procedure[] { new Step2Procedure() }; } }
@Override public Procedure[] execute(TestProcEnv env) throws InterruptedException { super.execute(env); return isFailed() ? null : new Procedure[] { new Step1Procedure() }; }
public static <TEnv> void waitAllProcedures(ProcedureExecutor<TEnv> procExecutor) { for (long procId : procExecutor.getActiveProcIds()) { waitProcedure(procExecutor, procId); } }
@Override public Procedure[] execute(TestProcEnv env) { if (env.toggleKillBeforeStoreUpdate) { ProcedureTestingUtility.toggleKillBeforeStoreUpdate(procExecutor); } if (env.toggleKillAfterStoreUpdate) { ProcedureTestingUtility.toggleKillAfterStoreUpdate(procExecutor); } return new Procedure[] { new TestChildProcedure(), new TestChildProcedure() }; }
@SuppressWarnings("unchecked") @Override protected Procedure<Void>[] execute(Void env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException { return new Procedure[] { new NoopProcedure<>(), new WaitingProcedure() }; } }
@Override protected Procedure<Void>[] execute(Void env) { setFailure("faulty-rollback-test", new TestProcedureException("test faulty rollback")); return null; }