@Override public SetQuotaResponse setQuota(RpcController c, SetQuotaRequest req) throws ServiceException { try { master.checkInitialized(); return master.getMasterQuotaManager().setQuota(req); } catch (Exception e) { throw new ServiceException(e); } }
@Override public MasterProtos.IsRpcThrottleEnabledResponse isRpcThrottleEnabled(RpcController controller, MasterProtos.IsRpcThrottleEnabledRequest request) throws ServiceException { try { master.checkInitialized(); return master.getMasterQuotaManager().isRpcThrottleEnabled(request); } catch (Exception e) { throw new ServiceException(e); } }
public QuotaObserverChore(HMaster master, MetricsMaster metrics) { this( master.getConnection(), master.getConfiguration(), master.getSpaceQuotaSnapshotNotifier(), master.getMasterQuotaManager(), master, metrics); }
@Override public SwitchRpcThrottleResponse switchRpcThrottle(RpcController controller, SwitchRpcThrottleRequest request) throws ServiceException { try { master.checkInitialized(); return master.getMasterQuotaManager().switchRpcThrottle(request); } catch (Exception e) { throw new ServiceException(e); } }
private Map<RegionInfo,Long> getReportedSizesForTable(TableName tn) { HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster(); MasterQuotaManager quotaManager = master.getMasterQuotaManager(); Map<RegionInfo,Long> filteredRegionSizes = new HashMap<>(); for (Entry<RegionInfo,Long> entry : quotaManager.snapshotRegionSizes().entrySet()) { if (entry.getKey().getTable().equals(tn)) { filteredRegionSizes.put(entry.getKey(), entry.getValue()); } } return filteredRegionSizes; }
try { master.checkInitialized(); MasterQuotaManager quotaManager = this.master.getMasterQuotaManager(); GetSpaceQuotaRegionSizesResponse.Builder builder = GetSpaceQuotaRegionSizesResponse.newBuilder();
private NamespaceAuditor getQuotaManager() { return UTIL.getHBaseCluster().getMaster() .getMasterQuotaManager().getNamespaceQuotaManager(); }
MasterQuotaManager quotaManager = master.getMasterQuotaManager(); Map<RegionInfo,Long> regionSizes = quotaManager.snapshotRegionSizes();
MasterQuotaManager quotaManager = getMasterQuotaManager(); if (quotaManager != null) { if (quotaManager.isQuotaInitialized()) {
@Override public FileArchiveNotificationResponse reportFileArchival(RpcController controller, FileArchiveNotificationRequest request) throws ServiceException { try { master.checkInitialized(); if (!QuotaUtil.isQuotaEnabled(master.getConfiguration())) { return FileArchiveNotificationResponse.newBuilder().build(); } master.getMasterQuotaManager().processFileArchivals(request, master.getConnection(), master.getConfiguration(), master.getFileSystem()); return FileArchiveNotificationResponse.newBuilder().build(); } catch (Exception e) { throw new ServiceException(e); } }
@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); }
@Override public RegionSpaceUseReportResponse reportRegionSpaceUse(RpcController controller, RegionSpaceUseReportRequest request) throws ServiceException { try { master.checkInitialized(); if (!QuotaUtil.isQuotaEnabled(master.getConfiguration())) { return RegionSpaceUseReportResponse.newBuilder().build(); } MasterQuotaManager quotaManager = this.master.getMasterQuotaManager(); final long now = EnvironmentEdgeManager.currentTime(); for (RegionSpaceUse report : request.getSpaceUseList()) { quotaManager.addRegionSize(ProtobufUtil.toRegionInfo( report.getRegionInfo()), report.getRegionSize(), now); } return RegionSpaceUseReportResponse.newBuilder().build(); } catch (Exception e) { throw new ServiceException(e); } }
final HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster(); while (master.getMasterQuotaManager() == null) { LOG.debug("MasterQuotaManager is null, waiting..."); Thread.sleep(500); final MasterQuotaManager quotaManager = master.getMasterQuotaManager();
if (quotaSnapshots.isEmpty()) { LOG.info("Found no violated quotas, sleeping and retrying. Current reports: " + master.getMasterQuotaManager().snapshotRegionSizes()); sleepWithInterrupt(DEFAULT_WAIT_MILLIS); quotaSnapshots = snapshotNotifier.copySnapshots();
while (numSnapshotsInViolation(snapshots) < 2) { LOG.debug("Saw fewer violations than desired (expected 2): " + snapshots + ". Current reports: " + master.getMasterQuotaManager().snapshotRegionSizes()); try { Thread.sleep(DEFAULT_WAIT_MILLIS);
@After public void cleanup() throws Exception, KeeperException { for (HTableDescriptor table : ADMIN.listTables()) { ADMIN.disableTable(table.getTableName()); deleteTable(table.getTableName()); } for (NamespaceDescriptor ns : ADMIN.listNamespaceDescriptors()) { if (ns.getName().startsWith(prefix)) { ADMIN.deleteNamespace(ns.getName()); } } assertTrue("Quota manager not initialized", UTIL.getHBaseCluster().getMaster() .getMasterQuotaManager().isQuotaInitialized()); }
while (numSnapshotsInViolation(snapshots) < 3) { LOG.debug("Saw fewer violations than desired (expected 3): " + snapshots + ". Current reports: " + master.getMasterQuotaManager().snapshotRegionSizes()); try { Thread.sleep(DEFAULT_WAIT_MILLIS);
@Override public SetQuotaResponse setQuota(RpcController c, SetQuotaRequest req) throws ServiceException { try { master.checkInitialized(); return master.getMasterQuotaManager().setQuota(req); } catch (Exception e) { throw new ServiceException(e); } }
private Map<RegionInfo,Long> getReportedSizesForTable(TableName tn) { HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster(); MasterQuotaManager quotaManager = master.getMasterQuotaManager(); Map<RegionInfo,Long> filteredRegionSizes = new HashMap<>(); for (Entry<RegionInfo,Long> entry : quotaManager.snapshotRegionSizes().entrySet()) { if (entry.getKey().getTable().equals(tn)) { filteredRegionSizes.put(entry.getKey(), entry.getValue()); } } return filteredRegionSizes; }
private NamespaceAuditor getQuotaManager() { return UTIL.getHBaseCluster().getMaster() .getMasterQuotaManager().getNamespaceQuotaManager(); }