/** * @param enabled */ public boolean setEnabled(final boolean enabled) { boolean alreadyEnabled = this.enabled.getAndSet(enabled); // If disabling is requested on an already enabled chore, we could have an active // scan still going on, callers might not be aware of that and do further action thinkng // that no action would be from this chore. In this case, the right action is to wait for // the active scan to complete before exiting this function. if (!enabled && alreadyEnabled) { while (alreadyRunning.get()) { Threads.sleepWithoutInterrupt(100); } } return alreadyEnabled; }
@Override public void preScannerOpen(ObserverContext<RegionCoprocessorEnvironment> e, Scan scan) throws IOException { if (SLEEP_MS > 0) { Threads.sleepWithoutInterrupt(SLEEP_MS); } } }
public BlockingCompactionContext waitForBlocking() { while (this.blocked == null || !this.blocked.isInCompact) { Threads.sleepWithoutInterrupt(50); } BlockingCompactionContext ctx = this.blocked; this.blocked = null; return ctx; }
private static void columnFamilySleep() { if (sleepBetweenColumnFamilies) { Threads.sleepWithoutInterrupt(columnFamilySleepTime); } }
private static void rowSleep() { if (sleepBetweenRows) { Threads.sleepWithoutInterrupt(rowSleepTime); } }
private boolean rollWriterWithRetries() { for (int i = 0; i < rollRetries && isRunning(); ++i) { if (i > 0) Threads.sleepWithoutInterrupt(waitBeforeRoll * i); try { if (rollWriter()) { return true; } } catch (IOException e) { LOG.warn("Unable to roll the log, attempt=" + (i + 1), e); } } LOG.error(HBaseMarkers.FATAL, "Unable to roll the log"); return false; }
@Override public Object answer(InvocationOnMock invocation) { synchronized (results) { results.add(value); } Threads.sleepWithoutInterrupt(sleepInterval); return null; } }).when(callTask).run();
@Override public void run() { LOG.debug("Sleeper thread: sleeping for " + SLEEP_TIME_MS); Threads.sleepWithoutInterrupt(SLEEP_TIME_MS); LOG.debug("Sleeper thread: finished sleeping"); wasInterrupted.set(Thread.currentThread().isInterrupted()); } });
public void waitForFinish() { while (numThreadsWorking.get() != 0) { Threads.sleepWithoutInterrupt(1000); } close(); }
@Override public List<ByteBuffer> getTableNames() throws IOError { Threads.sleepWithoutInterrupt(3000); return super.getTableNames(); } }
public static <TEnv> void waitNoProcedureRunning(ProcedureExecutor<TEnv> procExecutor) { int stableRuns = 0; while (stableRuns < 10) { if (procExecutor.getActiveExecutorCount() > 0 || procExecutor.getScheduler().size() > 0) { stableRuns = 0; Threads.sleepWithoutInterrupt(100); } else { stableRuns++; Threads.sleepWithoutInterrupt(25); } } }
private boolean waitLockTimeOut(EntityLock lock, long maxWaitTimeMillis) { long startMillis = System.currentTimeMillis(); while (lock.isLocked()) { LOG.info("Sleeping..."); Threads.sleepWithoutInterrupt(100); if (!lock.isLocked()) { return true; } if (System.currentTimeMillis() - startMillis > maxWaitTimeMillis) { LOG.info("Timedout..."); return false; } } return true; // to make compiler happy. }
private static void waitOnSplit(Connection c, final Table t, int originalCount) throws Exception { for (int i = 0; i < 200; i++) { Threads.sleepWithoutInterrupt(500); try (RegionLocator locator = c.getRegionLocator(t.getName())) { if (locator.getAllRegionLocations().size() > originalCount) { return; } } } throw new Exception("Split did not increase the number of regions"); }
@Override public EmptyResponseProto pause(RpcController controller, PauseRequestProto request) throws ServiceException { Threads.sleepWithoutInterrupt(request.getMs()); return EmptyResponseProto.getDefaultInstance(); }
public static <TEnv> void waitProcedure(ProcedureExecutor<TEnv> procExecutor, long procId) { while (!procExecutor.isFinished(procId) && procExecutor.isRunning()) { Threads.sleepWithoutInterrupt(250); } }
public static <TEnv> void waitProcedure(ProcedureExecutor<TEnv> procExecutor, Procedure proc) { while (proc.getState() == ProcedureState.INITIALIZING) { Threads.sleepWithoutInterrupt(250); } waitProcedure(procExecutor, proc.getProcId()); }
private int waitThreadCount(final int expectedThreads) { while (procExecutor.isRunning()) { if (procExecutor.getWorkerThreadCount() == expectedThreads) { break; } LOG.debug("waiting for thread count=" + expectedThreads + " current=" + procExecutor.getWorkerThreadCount()); Threads.sleepWithoutInterrupt(250); } return procExecutor.getWorkerThreadCount(); }
@Override public void pause(RpcController controller, PauseRequestProto request, RpcCallback<EmptyResponseProto> done) { Threads.sleepWithoutInterrupt(request.getMs()); done.run(EmptyResponseProto.getDefaultInstance()); }
public static void flushAndBlockUntilDone(Admin admin, HRegionServer rs, byte[] regionName) throws IOException, InterruptedException { log("flushing region: " + Bytes.toStringBinary(regionName)); admin.flushRegion(regionName); log("blocking until flush is complete: " + Bytes.toStringBinary(regionName)); Threads.sleepWithoutInterrupt(500); while (rs.getOnlineRegion(regionName).getMemStoreDataSize() > 0) { Threads.sleep(50); } }
public static void compactAndBlockUntilDone(Admin admin, HRegionServer rs, byte[] regionName) throws IOException, InterruptedException { log("Compacting region: " + Bytes.toStringBinary(regionName)); admin.majorCompactRegion(regionName); log("blocking until compaction is complete: " + Bytes.toStringBinary(regionName)); Threads.sleepWithoutInterrupt(500); outer: for (;;) { for (Store store : rs.getOnlineRegion(regionName).getStores()) { if (store.getStorefilesCount() > 1) { Threads.sleep(50); continue outer; } } break; } }