Java Code Examples for org.apache.hadoop.hbase.util.Threads#sleepWithoutInterrupt()
The following examples show how to use
org.apache.hadoop.hbase.util.Threads#sleepWithoutInterrupt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RSGroupInfoManagerImpl.java From hbase with Apache License 2.0 | 6 votes |
private boolean waitForGroupTableOnline() { while (isMasterRunning(masterServices)) { try { TableStateManager tsm = masterServices.getTableStateManager(); if (!tsm.isTablePresent(RSGROUP_TABLE_NAME)) { createRSGroupTable(); } // try reading from the table FutureUtils.get(conn.getTable(RSGROUP_TABLE_NAME).get(new Get(ROW_KEY))); LOG.info("RSGroup table={} is online, refreshing cached information", RSGROUP_TABLE_NAME); RSGroupInfoManagerImpl.this.refresh(true); online = true; // flush any inconsistencies between ZK and HTable RSGroupInfoManagerImpl.this.flushConfig(); // migrate after we are online. migrate(); return true; } catch (Exception e) { LOG.warn("Failed to perform check", e); // 100ms is short so let's just ignore the interrupt Threads.sleepWithoutInterrupt(100); } } return false; }
Example 2
Source File: TestLoadAndSwitchEncodeOnDisk.java From hbase with Apache License 2.0 | 5 votes |
@Override @Test public void loadTest() throws Exception { Admin admin = TEST_UTIL.getAdmin(); compression = Compression.Algorithm.GZ; // used for table setup super.loadTest(); ColumnFamilyDescriptor hcd = getColumnDesc(admin); System.err.println("\nDisabling encode-on-disk. Old column descriptor: " + hcd + "\n"); Table t = TEST_UTIL.getConnection().getTable(TABLE); assertAllOnLine(t); admin.disableTable(TABLE); admin.modifyColumnFamily(TABLE, hcd); System.err.println("\nRe-enabling table\n"); admin.enableTable(TABLE); System.err.println("\nNew column descriptor: " + getColumnDesc(admin) + "\n"); // The table may not have all regions on line yet. Assert online before // moving to major compact. assertAllOnLine(t); System.err.println("\nCompacting the table\n"); admin.majorCompact(TABLE); // Wait until compaction completes Threads.sleepWithoutInterrupt(5000); HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0); while (rs.compactSplitThread.getCompactionQueueSize() > 0) { Threads.sleep(50); } System.err.println("\nDone with the test, shutting down the cluster\n"); }
Example 3
Source File: TestProcedureRecovery.java From hbase with Apache License 2.0 | 5 votes |
@Override protected Procedure[] execute(TestProcEnv env) throws InterruptedException { env.waitOnLatch(); LOG.debug("execute procedure " + this + " step=" + step); ProcedureTestingUtility.toggleKillBeforeStoreUpdate(procExecutor); step++; Threads.sleepWithoutInterrupt(procSleepInterval); if (isAborted()) { setFailure(new RemoteProcedureException(getClass().getName(), new ProcedureAbortedException( "got an abort at " + getClass().getName() + " step=" + step))); return null; } return null; }
Example 4
Source File: CatalogJanitor.java From hbase with Apache License 2.0 | 5 votes |
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; }
Example 5
Source File: TestEndToEndSplitTransaction.java From hbase with Apache License 2.0 | 5 votes |
public static void compactAndBlockUntilDone(Admin admin, HRegionServer rs, byte[] regionName) throws IOException, InterruptedException { log("Compacting region: " + Bytes.toStringBinary(regionName)); // Wait till its online before we do compact else it comes back with NoServerForRegionException try { TEST_UTIL.waitFor(10000, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { return rs.getServerName().equals(MetaTableAccessor. getRegionLocation(admin.getConnection(), regionName).getServerName()); } }); } catch (Exception e) { throw new IOException(e); } 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; } }
Example 6
Source File: ZKUtil.java From hbase with Apache License 2.0 | 5 votes |
/** * Waits for HBase installation's base (parent) znode to become available. * @throws IOException on ZK errors */ public static void waitForBaseZNode(Configuration conf) throws IOException { LOG.info("Waiting until the base znode is available"); String parentZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT, HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT); ZooKeeper zk = new ZooKeeper(ZKConfig.getZKQuorumServersString(conf), conf.getInt(HConstants.ZK_SESSION_TIMEOUT, HConstants.DEFAULT_ZK_SESSION_TIMEOUT), EmptyWatcher.instance); final int maxTimeMs = 10000; final int maxNumAttempts = maxTimeMs / HConstants.SOCKET_RETRY_WAIT_MS; KeeperException keeperEx = null; try { try { for (int attempt = 0; attempt < maxNumAttempts; ++attempt) { try { if (zk.exists(parentZNode, false) != null) { LOG.info("Parent znode exists: {}", parentZNode); keeperEx = null; break; } } catch (KeeperException e) { keeperEx = e; } Threads.sleepWithoutInterrupt(HConstants.SOCKET_RETRY_WAIT_MS); } } finally { zk.close(); } } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } if (keeperEx != null) { throw new IOException(keeperEx); } }
Example 7
Source File: TestEntityLocks.java From hbase with Apache License 2.0 | 5 votes |
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. }
Example 8
Source File: TestAsyncTableNoncedRetry.java From hbase with Apache License 2.0 | 5 votes |
@Override public Result postAppend(ObserverContext<RegionCoprocessorEnvironment> c, Append append, Result result) throws IOException { if (CALLED.getAndIncrement() == 0) { Threads.sleepWithoutInterrupt(SLEEP_TIME); } return RegionObserver.super.postAppend(c, append, result); }
Example 9
Source File: TestAsyncTableNoncedRetry.java From hbase with Apache License 2.0 | 5 votes |
@Override public Result postIncrement(ObserverContext<RegionCoprocessorEnvironment> c, Increment increment, Result result) throws IOException { if (CALLED.getAndIncrement() == 0) { Threads.sleepWithoutInterrupt(SLEEP_TIME); } return RegionObserver.super.postIncrement(c, increment, result); }
Example 10
Source File: TestSnapshotCloneIndependence.java From hbase with Apache License 2.0 | 5 votes |
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"); }
Example 11
Source File: TestAsyncRegionLocator.java From hbase with Apache License 2.0 | 5 votes |
@Override public void preScannerOpen(ObserverContext<RegionCoprocessorEnvironment> e, Scan scan) throws IOException { if (SLEEP_MS > 0) { Threads.sleepWithoutInterrupt(SLEEP_MS); } }
Example 12
Source File: TestCompaction.java From hbase with Apache License 2.0 | 5 votes |
public BlockingCompactionContext waitForBlocking() { while (this.blocked == null || !this.blocked.isInCompact) { Threads.sleepWithoutInterrupt(50); } BlockingCompactionContext ctx = this.blocked; this.blocked = null; return ctx; }
Example 13
Source File: TestProtobufRpcServiceImpl.java From hbase with Apache License 2.0 | 4 votes |
@Override public EmptyResponseProto pause(RpcController controller, PauseRequestProto request) throws ServiceException { Threads.sleepWithoutInterrupt(request.getMs()); return EmptyResponseProto.getDefaultInstance(); }
Example 14
Source File: TestScannerHeartbeatMessages.java From hbase with Apache License 2.0 | 4 votes |
private static void columnFamilySleep() { if (sleepBetweenColumnFamilies) { Threads.sleepWithoutInterrupt(columnFamilySleepTime); } }
Example 15
Source File: TestScannerSelectionUsingTTL.java From hbase with Apache License 2.0 | 4 votes |
@Test public void testScannerSelection() throws IOException { Configuration conf = TEST_UTIL.getConfiguration(); conf.setBoolean("hbase.store.delete.expired.storefile", false); LruBlockCache cache = (LruBlockCache) BlockCacheFactory.createBlockCache(conf); TableDescriptor td = TableDescriptorBuilder.newBuilder(TABLE).setColumnFamily( ColumnFamilyDescriptorBuilder.newBuilder(FAMILY_BYTES).setMaxVersions(Integer.MAX_VALUE) .setTimeToLive(TTL_SECONDS).build()).build(); RegionInfo info = RegionInfoBuilder.newBuilder(TABLE).build(); HRegion region = HBaseTestingUtility .createRegionAndWAL(info, TEST_UTIL.getDataTestDir(info.getEncodedName()), conf, td, cache); long ts = EnvironmentEdgeManager.currentTime(); long version = 0; //make sure each new set of Put's have a new ts for (int iFile = 0; iFile < totalNumFiles; ++iFile) { if (iFile == NUM_EXPIRED_FILES) { Threads.sleepWithoutInterrupt(TTL_MS); version += TTL_MS; } for (int iRow = 0; iRow < NUM_ROWS; ++iRow) { Put put = new Put(Bytes.toBytes("row" + iRow)); for (int iCol = 0; iCol < NUM_COLS_PER_ROW; ++iCol) { put.addColumn(FAMILY_BYTES, Bytes.toBytes("col" + iCol), ts + version, Bytes.toBytes("value" + iFile + "_" + iRow + "_" + iCol)); } region.put(put); } region.flush(true); version++; } Scan scan = new Scan().readVersions(Integer.MAX_VALUE); cache.clearCache(); InternalScanner scanner = region.getScanner(scan); List<Cell> results = new ArrayList<>(); final int expectedKVsPerRow = numFreshFiles * NUM_COLS_PER_ROW; int numReturnedRows = 0; LOG.info("Scanning the entire table"); while (scanner.next(results) || results.size() > 0) { assertEquals(expectedKVsPerRow, results.size()); ++numReturnedRows; results.clear(); } assertEquals(NUM_ROWS, numReturnedRows); Set<String> accessedFiles = cache.getCachedFileNamesForTest(); LOG.debug("Files accessed during scan: " + accessedFiles); // Exercise both compaction codepaths. if (explicitCompaction) { HStore store = region.getStore(FAMILY_BYTES); store.compactRecentForTestingAssumingDefaultPolicy(totalNumFiles); } else { region.compact(false); } HBaseTestingUtility.closeRegionAndWAL(region); }
Example 16
Source File: ProcedureTestingUtility.java From hbase with Apache License 2.0 | 4 votes |
public static <TEnv> void waitProcedure(ProcedureExecutor<TEnv> procExecutor, Procedure proc) { while (proc.getState() == ProcedureState.INITIALIZING) { Threads.sleepWithoutInterrupt(250); } waitProcedure(procExecutor, proc.getProcId()); }
Example 17
Source File: TestProcedureSchedulerConcurrency.java From hbase with Apache License 2.0 | 4 votes |
private void testConcurrentWaitWake(final boolean useWakeBatch) throws Exception { final int WAIT_THRESHOLD = 2500; final int NPROCS = 20; final int NRUNS = 500; final ProcedureScheduler sched = procSched; for (long i = 0; i < NPROCS; ++i) { sched.addBack(new TestProcedureWithEvent(i)); } final Thread[] threads = new Thread[4]; final AtomicInteger waitCount = new AtomicInteger(0); final AtomicInteger wakeCount = new AtomicInteger(0); final ConcurrentSkipListSet<TestProcedureWithEvent> waitQueue = new ConcurrentSkipListSet<>(); threads[0] = new Thread() { @Override public void run() { long lastUpdate = 0; while (true) { final int oldWakeCount = wakeCount.get(); if (useWakeBatch) { ProcedureEvent[] ev = new ProcedureEvent[waitQueue.size()]; for (int i = 0; i < ev.length; ++i) { ev[i] = waitQueue.pollFirst().getEvent(); LOG.debug("WAKE BATCH " + ev[i] + " total=" + wakeCount.get()); } ProcedureEvent.wakeEvents((AbstractProcedureScheduler) sched, ev); wakeCount.addAndGet(ev.length); } else { int size = waitQueue.size(); while (size-- > 0) { ProcedureEvent ev = waitQueue.pollFirst().getEvent(); ev.wake(procSched); LOG.debug("WAKE " + ev + " total=" + wakeCount.get()); wakeCount.incrementAndGet(); } } if (wakeCount.get() != oldWakeCount) { lastUpdate = System.currentTimeMillis(); } else if (wakeCount.get() >= NRUNS && (System.currentTimeMillis() - lastUpdate) > WAIT_THRESHOLD) { break; } Threads.sleepWithoutInterrupt(25); } } }; for (int i = 1; i < threads.length; ++i) { threads[i] = new Thread() { @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; } } } }; } for (int i = 0; i < threads.length; ++i) { threads[i].start(); } for (int i = 0; i < threads.length; ++i) { threads[i].join(); } sched.clear(); }
Example 18
Source File: ProcedureTestingUtility.java From hbase with Apache License 2.0 | 4 votes |
public static <TEnv> void waitProcedure(ProcedureExecutor<TEnv> procExecutor, long procId) { while (!procExecutor.isFinished(procId) && procExecutor.isRunning()) { Threads.sleepWithoutInterrupt(250); } }
Example 19
Source File: ProtobufCoprocessorService.java From hbase with Apache License 2.0 | 4 votes |
@Override public void pause(RpcController controller, PauseRequestProto request, RpcCallback<EmptyResponseProto> done) { Threads.sleepWithoutInterrupt(request.getMs()); done.run(EmptyResponseProto.getDefaultInstance()); }
Example 20
Source File: TestThriftServer.java From hbase with Apache License 2.0 | 4 votes |
@Override public List<ByteBuffer> getTableNames() throws IOError { Threads.sleepWithoutInterrupt(3000); return super.getTableNames(); }