/** * Returns a {@link Predicate} for checking that table is enabled */ public Waiter.Predicate<IOException> predicateTableAvailable(final TableName tableName) { return new ExplainingPredicate<IOException>() { @Override public String explainFailure() throws IOException { return explainTableAvailability(tableName); } @Override public boolean evaluate() throws IOException { boolean tableAvailable = getHBaseAdmin().isTableAvailable(tableName); if (tableAvailable) { try { Canary.sniff(getHBaseAdmin(), tableName); } catch (Exception e) { throw new IOException("Canary sniff failed for table " + tableName, e); } } return tableAvailable; } }; }
public void waitTableEnabled(Admin admin, byte[] table, long timeoutMillis) throws InterruptedException, IOException { TableName tableName = TableName.valueOf(table); long startWait = System.currentTimeMillis(); waitTableAvailable(admin, table, timeoutMillis); while (!admin.isTableEnabled(tableName)) { assertTrue("Timed out waiting for table to become available and enabled " + Bytes.toStringBinary(table), System.currentTimeMillis() - startWait < timeoutMillis); Thread.sleep(200); } // Finally make sure all regions are fully open and online out on the cluster. Regions may be // in the hbase:meta table and almost open on all regionservers but there setting the region // online in the regionserver is the very last thing done and can take a little while to happen. // Below we do a get. The get will retry if a NotServeringRegionException or a // RegionOpeningException. It is crass but when done all will be online. try { Canary.sniff(admin, tableName); } catch (Exception e) { throw new IOException(e); } }
public void waitTableEnabled(HBaseAdmin admin, byte[] table, long timeoutMillis) throws InterruptedException, IOException { long startWait = System.currentTimeMillis(); waitTableAvailable(admin, table, timeoutMillis); long remainder = System.currentTimeMillis() - startWait; while (!admin.isTableEnabled(table)) { assertTrue("Timed out waiting for table to become available and enabled " + Bytes.toStringBinary(table), System.currentTimeMillis() - remainder < timeoutMillis); Thread.sleep(200); } // Finally make sure all regions are fully open and online out on the cluster. Regions may be // in the hbase:meta table and almost open on all regionservers but there setting the region // online in the regionserver is the very last thing done and can take a little while to happen. // Below we do a get. The get will retry if a NotServeringRegionException or a // RegionOpeningException. It is crass but when done all will be online. try { Canary.sniff(admin, TableName.valueOf(table)); } catch (Exception e) { throw new IOException(e); } }
public void waitTableAvailable(HBaseAdmin admin, byte[] table, long timeoutMillis) throws InterruptedException, IOException { long startWait = System.currentTimeMillis(); while (!admin.isTableAvailable(table)) { assertTrue("Timed out waiting for table to become available " + Bytes.toStringBinary(table), System.currentTimeMillis() - startWait < timeoutMillis); Thread.sleep(200); } // Finally make sure all regions are fully open and online out on the cluster. Regions may be // in the hbase:meta table and almost open on all regionservers but there setting the region // online in the regionserver is the very last thing done and can take a little while to happen. // Below we do a get. The get will retry if a NotServeringRegionException or a // RegionOpeningException. It is crass but when done all will be online. try { Canary.sniff(admin, TableName.valueOf(table)); } catch (Exception e) { throw new IOException(e); } }