public void suspend(Procedure<?> proc) { event.suspend(); event.suspendIfNotReady(proc); }
public void setEventReady(ProcedureEvent<?> event, boolean isReady) { if (isReady) { event.wake(procSched); } else { event.suspend(); } }
public void suspend(Procedure<?> proc) { event.suspend(); event.suspendIfNotReady(proc); }
/** * Add the assign operation to the assignment queue. * The pending assignment operation will be processed, * and each region will be assigned by a server using the balancer. */ protected void queueAssign(final RegionStateNode regionNode) { regionNode.getProcedureEvent().suspend(); // TODO: quick-start for meta and the other sys-tables? assignQueueLock.lock(); try { pendingAssignQueue.add(regionNode); if (regionNode.isSystemTable() || pendingAssignQueue.size() == 1 || pendingAssignQueue.size() >= assignDispatchWaitQueueMaxSize) { assignQueueFullCond.signal(); } } finally { assignQueueLock.unlock(); } }
@Override protected void afterReplay(final TestProcEnv env) { if (getState() == ProcedureState.WAITING_TIMEOUT) { event.suspend(); event.suspendIfNotReady(this); } }
private void setMetaAssigned(RegionInfo metaRegionInfo, boolean assigned) { assert isMetaRegion(metaRegionInfo) : "unexpected non-meta region " + metaRegionInfo; ProcedureEvent<?> metaAssignEvent = getMetaAssignEvent(metaRegionInfo); if (assigned) { metaAssignEvent.wake(getProcedureScheduler()); } else { metaAssignEvent.suspend(); } }
@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(); }
public void stop() { if (!running.compareAndSet(true, false)) { return; } LOG.info("Stopping assignment manager"); // The AM is started before the procedure executor, // but the actual work will be loaded/submitted only once we have the executor final boolean hasProcExecutor = master.getMasterProcedureExecutor() != null; // Remove the RIT chore if (hasProcExecutor) { master.getMasterProcedureExecutor().removeChore(this.ritChore); } // Stop the Assignment Thread stopAssignmentThread(); // Stop the RegionStateStore regionStates.clear(); // Update meta events (for testing) if (hasProcExecutor) { metaLoadEvent.suspend(); for (RegionInfo hri: getMetaRegionSet()) { setMetaAssigned(hri, false); } } }
@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 public void run() { while (true) { TestProcedureWithEvent proc = (TestProcedureWithEvent)sched.poll(); if (proc == null) continue; proc.getEvent().suspend(); waitQueue.add(proc); proc.getEvent().suspendIfNotReady(proc); LOG.debug("WAIT " + proc.getEvent()); if (waitCount.incrementAndGet() >= NRUNS) { break; } } } };
event.suspend(); event.suspendIfNotReady(this); throw new ProcedureSuspendedException();
@Override protected void afterReplay(final TestProcEnv env) { if (getState() == ProcedureState.WAITING_TIMEOUT) { event.suspend(); event.suspendIfNotReady(this); } }
@Override protected void afterReplay(final TestProcEnv env) { if (getState() == ProcedureState.WAITING_TIMEOUT) { event.suspend(); event.suspendIfNotReady(this); } }
@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[] 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 public void run() { while (true) { TestProcedureWithEvent proc = (TestProcedureWithEvent)sched.poll(); if (proc == null) continue; proc.getEvent().suspend(); waitQueue.add(proc); proc.getEvent().suspendIfNotReady(proc); LOG.debug("WAIT " + proc.getEvent()); if (waitCount.incrementAndGet() >= NRUNS) { break; } } } };
@Override public void run() { while (true) { TestProcedureWithEvent proc = (TestProcedureWithEvent)sched.poll(); if (proc == null) continue; proc.getEvent().suspend(); waitQueue.add(proc); proc.getEvent().suspendIfNotReady(proc); LOG.debug("WAIT " + proc.getEvent()); if (waitCount.incrementAndGet() >= NRUNS) { break; } } } };