public static void sleep(long millis) { sleep(millis, new AtomicBoolean(false)); } }
/** * Sleep a random amount of time from 100ms to 1sec */ private void sleepRandom() { UtilWaitThread.sleep(100 + (long) (1000 * Math.random()), closed); }
@Override public void run() { UtilWaitThread.sleep(100); Runtime.getRuntime().halt(status); } };
private void waitForFindersToStabilize() { ModulusParams lmp = hwf.getModulusParams(); long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < STABILIZE_TIME) { UtilWaitThread.sleep(500, stopped); ModulusParams lmp2 = hwf.getModulusParams(); if (lmp.update != lmp2.update) { startTime = System.currentTimeMillis(); lmp = lmp2; } } } }
UtilWaitThread.sleep(1000);
private synchronized void updateFinders() { String me = myESNode.getActualPath(); while (me == null) { UtilWaitThread.sleep(100); me = myESNode.getActualPath(); } me = ZKPaths.getNodeFromPath(me); List<String> children = new ArrayList<>(); for (ChildData childData : childrenCache.getCurrentData()) { children.add(ZKPaths.getNodeFromPath(childData.getPath())); } Collections.sort(children); if (!finders.equals(children)) { int index = children.indexOf(me); if (index == -1) { this.modParams = null; finders = Collections.emptyList(); log.debug("Did not find self in list of finders " + me); } else { updates++; this.modParams = new ModulusParams(children.indexOf(me), children.size(), updates); finders = children; log.debug("updated modulus params " + modParams.remainder + " " + modParams.divisor); } } }
Map<Bytes, Map<Column, Bytes>> scan() { long waitTime = SnapshotScanner.INITIAL_WAIT_TIME; long startTime = System.currentTimeMillis(); Map<Bytes, Map<Column, Bytes>> ret = new HashMap<>(); while (true) { List<Entry<Key, Value>> locks = new ArrayList<>(); scan(ret, locks); if (locks.size() > 0) { boolean resolvedAll = LockResolver.resolveLocks(env, startTs, stats, locks, startTime); if (!resolvedAll) { UtilWaitThread.sleep(waitTime); stats.incrementLockWaitTime(waitTime); waitTime = Math.min(SnapshotScanner.MAX_WAIT_TIME, waitTime * 2); } // TODO, could only rescan the row/cols that were locked instead of just the entire row // retain the rows that were locked for future scans HashSet<Bytes> lockedRows = new HashSet<>(); for (Entry<Key, Value> entry : locks) { lockedRows.add(ByteUtil.toBytes(entry.getKey().getRowData())); } unscannedRows.retainAll(lockedRows); continue; } for (Map<Column, Bytes> cols : ret.values()) { stats.incrementEntriesReturned(cols.size()); } return ret; } }
UtilWaitThread.sleep(waitTime); stats.incrementLockWaitTime(waitTime); waitTime = Math.min(MAX_WAIT_TIME, waitTime * 2);
UtilWaitThread.sleep(10000);
UtilWaitThread.sleep(1000);
TxResult status = TxResult.UNKNOWN; try { UtilWaitThread.sleep(sleepTime);