/** * Check the quota for the current (rpc-context) user. * Returns the OperationQuota used to get the available quota and * to report the data/usage of the operation. * @param region the region where the operation will be performed * @param type the operation type * @return the OperationQuota * @throws RpcThrottlingException if the operation cannot be executed due to quota exceeded. */ public OperationQuota checkQuota(final Region region, final OperationQuota.OperationType type) throws IOException, RpcThrottlingException { switch (type) { case SCAN: return checkQuota(region, 0, 0, 1); case GET: return checkQuota(region, 0, 1, 0); case MUTATE: return checkQuota(region, 1, 0, 0); } throw new RuntimeException("Invalid operation type: " + type); }
/** * Check the quota for the current (rpc-context) user. * Returns the OperationQuota used to get the available quota and * to report the data/usage of the operation. * @param region the region where the operation will be performed * @param actions the "multi" actions to perform * @return the OperationQuota * @throws RpcThrottlingException if the operation cannot be executed due to quota exceeded. */ public OperationQuota checkQuota(final Region region, final List<ClientProtos.Action> actions) throws IOException, RpcThrottlingException { int numWrites = 0; int numReads = 0; for (final ClientProtos.Action action: actions) { if (action.hasMutation()) { numWrites++; } else if (action.hasGet()) { numReads++; } } return checkQuota(region, numWrites, numReads, 0); }
quota = getRpcQuotaManager().checkQuota(region, OperationQuota.OperationType.SCAN); } catch (IOException e) { addScannerLeaseBack(lease);
try { region = getRegion(regionSpecifier); quota = getRpcQuotaManager().checkQuota(region, regionAction.getActionList()); } catch (IOException e) { failRegionAction(responseBuilder, regionActionResultBuilder, regionAction, cellScanner, e);
Result r = null; RpcCallContext context = RpcServer.getCurrentCall().orElse(null); quota = getRpcQuotaManager().checkQuota(region, OperationQuota.OperationType.GET);
type = mutation.getMutateType(); quota = getRpcQuotaManager().checkQuota(region, OperationQuota.OperationType.MUTATE); spaceQuotaEnforcement = getSpaceQuotaManager().getActiveEnforcements();