@Override protected Procedure[] execute(final TestProcEnv env) throws ProcedureSuspendedException { // Always suspend the procedure throw new ProcedureSuspendedException(); } }
@Override protected Procedure[] execute(final MasterProcedureEnv env) throws ProcedureSuspendedException { // Always suspend the procedure throw new ProcedureSuspendedException(); }
/** * try to acquire an worker from online servers which is executring * @param procedure split WAL task * @return an available region server which could execute this task * @throws ProcedureSuspendedException if there is no available worker, * it will throw this exception to let the procedure wait */ public ServerName acquireSplitWALWorker(Procedure<?> procedure) throws ProcedureSuspendedException { Optional<ServerName> worker = splitWorkerAssigner.acquire(); LOG.debug("acquired a worker {} to split a WAL", worker); if (worker.isPresent()) { return worker.get(); } splitWorkerAssigner.suspend(procedure); throw new ProcedureSuspendedException(); }
/** * Get a worker for replaying remote wal for a give peer. If no worker available, i.e, all the * region servers have been used by others, a {@link ProcedureSuspendedException} will be thrown * to suspend the procedure. And it will be woken up later when there are available workers, * either by others release a worker, or there is a new region server joins the cluster. */ public ServerName acquirePeerWorker(String peerId, Procedure<?> proc) throws ProcedureSuspendedException { UsedReplayWorkersForPeer usedWorkers = usedWorkersByPeer.get(peerId); synchronized (usedWorkers) { Optional<ServerName> worker = usedWorkers.acquire(serverManager); if (worker.isPresent()) { return worker.get(); } // no worker available right now, suspend the procedure usedWorkers.suspend(proc); } throw new ProcedureSuspendedException(); }
@Override protected Procedure<Void>[] execute(Void env) throws ProcedureSuspendedException { // Always suspend the procedure LOG.info("suspend here"); latch.countDown(); throw new ProcedureSuspendedException(); } }
protected final ProcedureSuspendedException suspend(long backoff) throws ProcedureSuspendedException { attempts++; setTimeout(Math.toIntExact(backoff)); setState(ProcedureProtos.ProcedureState.WAITING_TIMEOUT); skipPersistence(); throw new ProcedureSuspendedException(); }
protected final ProcedureSuspendedException suspend(long backoff) throws ProcedureSuspendedException { attempts++; setTimeout(Math.toIntExact(backoff)); setState(ProcedureProtos.ProcedureState.WAITING_TIMEOUT); skipPersistence(); throw new ProcedureSuspendedException(); } }
@Override protected Procedure<MasterProcedureEnv>[] execute(final MasterProcedureEnv env) throws ProcedureSuspendedException { // Local master locks don't store any state, so on recovery, simply finish this procedure // immediately. if (recoveredMasterLock) return null; if (lockAcquireLatch != null) { lockAcquireLatch.countDown(); } if (unlock.get() || hasHeartbeatExpired()) { locked.set(false); LOG.debug((unlock.get()? "UNLOCKED " : "TIMED OUT ") + toString()); return null; } synchronized (event) { event.suspend(); event.suspendIfNotReady(this); setState(ProcedureProtos.ProcedureState.WAITING_TIMEOUT); } throw new ProcedureSuspendedException(); }
@Override protected Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException { if (dispatched) { if (succ) { return null; } dispatched = false; } try { env.getRemoteDispatcher().addOperationToNode(targetServer, this); } catch (FailedRemoteDispatchException frde) { LOG.warn("Can not add remote operation for switching rpc throttle to {} on {}", rpcThrottleEnabled, targetServer); return null; } dispatched = true; event = new ProcedureEvent<>(this); event.suspendIfNotReady(this); throw new ProcedureSuspendedException(); }
@Override protected Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException { if (dispatched) { if (success) { return null; } dispatched = false; } try { env.getRemoteDispatcher().addOperationToNode(worker, this); } catch (NoNodeDispatchException | NullTargetServerDispatchException | NoServerDispatchException e) { // When send to a wrong target server, it need construct a new SplitWALRemoteProcedure. // Thus return null for this procedure and let SplitWALProcedure to handle this. LOG.warn("dispatch WAL {} to {} failed, will retry on another server", walPath, worker, e); return null; } dispatched = true; event = new ProcedureEvent<>(this); event.suspendIfNotReady(this); throw new ProcedureSuspendedException(); }
@Override protected synchronized Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException { if (dispatched) { if (succ) { return null; } // retry dispatched = false; } try { env.getRemoteDispatcher().addOperationToNode(targetServer, this); } catch (FailedRemoteDispatchException frde) { LOG.info("Can not add remote operation for refreshing peer {} for {} to {}, " + "this is usually because the server is already dead, " + "give up and mark the procedure as complete", peerId, type, targetServer, frde); return null; } dispatched = true; event = new ProcedureEvent<>(this); event.suspendIfNotReady(this); throw new ProcedureSuspendedException(); }
@Override protected Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException { if (dispatched) { if (succ) { return null; } // retry dispatched = false; } // Dispatch task to target server try { env.getRemoteDispatcher().addOperationToNode(targetServer, this); } catch (FailedRemoteDispatchException e) { LOG.warn("Can not add remote operation for replay wals {} on {} for peer id={}, " + "this usually because the server is already dead", wals, targetServer, peerId); // Return directly and the parent procedure will assign a new worker to replay wals return null; } dispatched = true; event = new ProcedureEvent<>(this); event.suspendIfNotReady(this); throw new ProcedureSuspendedException(); }
@Override protected Procedure[] execute(final TestProcEnv env) throws ProcedureYieldException, ProcedureSuspendedException { LOG.info("EXECUTE " + this + " suspend " + (lock != null)); timestamps.add(env.nextTimestamp()); if (triggerRollback) { setFailure(getClass().getSimpleName(), new Exception("injected failure")); } else if (throwYield) { throw new ProcedureYieldException(); } else if (throwSuspend) { throw new ProcedureSuspendedException(); } return null; }
@Override protected Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException { if (ARRIVE != null) { ARRIVE.countDown(); ARRIVE = null; } if (FINISH_PROC) { return null; } setTimeout(1000); setState(ProcedureState.WAITING_TIMEOUT); throw new ProcedureSuspendedException(); }
@Override protected Procedure[] execute(final TestProcEnv env) throws ProcedureSuspendedException { LOG.info("EXECUTE " + this + " ntimeouts=" + ntimeouts); if (ntimeouts.get() > maxTimeouts) { setAbortFailure("test", "give up after " + ntimeouts.get()); return null; } event.suspend(); if (event.suspendIfNotReady(this)) { setState(ProcedureState.WAITING_TIMEOUT); throw new ProcedureSuspendedException(); } return null; }
@Override protected Procedure<Void>[] execute(Void env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException { EXCHANGER.exchange(Boolean.TRUE); setState(ProcedureState.WAITING_TIMEOUT); setTimeout(Integer.MAX_VALUE); throw new ProcedureSuspendedException(); } }
@Override protected Procedure[] execute(final TestProcEnv env) throws ProcedureSuspendedException { // Always suspend the procedure setTimeout(50000); setState(ProcedureProtos.ProcedureState.WAITING_TIMEOUT); skipPersistence(); throw new ProcedureSuspendedException(); }
event.suspend(); event.suspendIfNotReady(this); throw new ProcedureSuspendedException(); } finally { regionNode.unlock();
private void queueAssign(MasterProcedureEnv env, RegionStateNode regionNode) throws ProcedureSuspendedException { // Here the assumption is that, the region must be in CLOSED state, so the region location // will be null. And if we fail to open the region and retry here, the forceNewPlan will be // true, and also we will set the region location to null. boolean retain = false; if (!forceNewPlan) { if (assignCandidate != null) { retain = assignCandidate.equals(regionNode.getLastHost()); regionNode.setRegionLocation(assignCandidate); } else if (regionNode.getLastHost() != null) { retain = true; LOG.info("Setting lastHost as the region location {}", regionNode.getLastHost()); regionNode.setRegionLocation(regionNode.getLastHost()); } } LOG.info("Starting {}; {}; forceNewPlan={}, retain={}", this, regionNode.toShortString(), forceNewPlan, retain); env.getAssignmentManager().queueAssign(regionNode); setNextState(RegionStateTransitionState.REGION_STATE_TRANSITION_OPEN); if (regionNode.getProcedureEvent().suspendIfNotReady(this)) { throw new ProcedureSuspendedException(); } }
@Override protected Procedure<ProcEnv>[] execute(ProcEnv env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException { if (STEP == 0) { STEP = 1; setTimeout(60 * 60 * 1000); setState(ProcedureProtos.ProcedureState.WAITING_TIMEOUT); skipPersistence(); throw new ProcedureSuspendedException(); } else if (STEP == 1) { STEP = 2; if (hasTimeout()) { setFailure("Should not persist the timeout value", new IOException("Should not persist the timeout value")); return null; } setTimeout(2 * 1000); setState(ProcedureProtos.ProcedureState.WAITING_TIMEOUT); // used to confirm that we reset the persist flag before execution throw new ProcedureSuspendedException(); } else { if (!hasTimeout()) { setFailure("Should have persisted the timeout value", new IOException("Should have persisted the timeout value")); } return null; } }