Java Code Examples for org.apache.hadoop.hbase.master.HMaster#getMasterQuotaManager()
The following examples show how to use
org.apache.hadoop.hbase.master.HMaster#getMasterQuotaManager() .
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: TestQuotaStatusRPCs.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testRegionSizesFromMaster() throws Exception { final long tableSize = 1024L * 10L; // 10KB final int numRegions = 10; final TableName tn = helper.createTableWithRegions(numRegions); // Will write at least `tableSize` data helper.writeData(tn, tableSize); final HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster(); final MasterQuotaManager quotaManager = master.getMasterQuotaManager(); // Make sure the master has all of the reports Waiter.waitFor(TEST_UTIL.getConfiguration(), 30 * 1000, new Predicate<Exception>() { @Override public boolean evaluate() throws Exception { Map<RegionInfo,Long> regionSizes = quotaManager.snapshotRegionSizes(); LOG.trace("Region sizes=" + regionSizes); return numRegions == countRegionsForTable(tn, regionSizes) && tableSize <= getTableSize(tn, regionSizes); } }); Map<TableName, Long> sizes = TEST_UTIL.getAdmin().getSpaceQuotaTableSizes(); Long size = sizes.get(tn); assertNotNull("No reported size for " + tn, size); assertTrue("Reported table size was " + size, size.longValue() >= tableSize); }
Example 2
Source File: TestSpaceQuotaOnBulkLoad.java From hbase with Apache License 2.0 | 5 votes |
private Map<RegionInfo, Long> getReportedSizesForTable(TableName tn) { HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster(); MasterQuotaManager quotaManager = master.getMasterQuotaManager(); Map<RegionInfo, Long> filteredRegionSizes = new HashMap<>(); for (Map.Entry<RegionInfo, Long> entry : quotaManager.snapshotRegionSizes().entrySet()) { if (entry.getKey().getTable().equals(tn)) { filteredRegionSizes.put(entry.getKey(), entry.getValue()); } } return filteredRegionSizes; }
Example 3
Source File: TestRegionSizeUse.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testBasicRegionSizeReports() throws Exception { final long bytesWritten = 5L * 1024L * 1024L; // 5MB final TableName tn = writeData(bytesWritten); LOG.debug("Data was written to HBase"); final Admin admin = TEST_UTIL.getAdmin(); // Push the data to disk. admin.flush(tn); LOG.debug("Data flushed to disk"); // Get the final region distribution final List<RegionInfo> regions = TEST_UTIL.getAdmin().getRegions(tn); HMaster master = cluster.getMaster(); MasterQuotaManager quotaManager = master.getMasterQuotaManager(); Map<RegionInfo,Long> regionSizes = quotaManager.snapshotRegionSizes(); // Wait until we get all of the region reports for our table // The table may split, so make sure we have at least as many as expected right after we // finished writing the data. int observedRegions = numRegionsForTable(tn, regionSizes); while (observedRegions < regions.size()) { LOG.debug("Expecting more regions. Saw " + observedRegions + " region sizes reported, expected at least " + regions.size()); Thread.sleep(1000); regionSizes = quotaManager.snapshotRegionSizes(); observedRegions = numRegionsForTable(tn, regionSizes); } LOG.debug("Observed region sizes by the HMaster: " + regionSizes); long totalRegionSize = 0L; for (Long regionSize : regionSizes.values()) { totalRegionSize += regionSize; } assertTrue("Expected region size report to exceed " + bytesWritten + ", but was " + totalRegionSize + ". RegionSizes=" + regionSizes, bytesWritten < totalRegionSize); }
Example 4
Source File: QuotaObserverChore.java From hbase with Apache License 2.0 | 4 votes |
public QuotaObserverChore(HMaster master, MetricsMaster metrics) { this( master.getConnection(), master.getConfiguration(), master.getSpaceQuotaSnapshotNotifier(), master.getMasterQuotaManager(), master, metrics); }