Skip to content

Commit

Permalink
HBASE-28346: Expose checkQuota to Coprocessor Endpoints (apache#6066)…
Browse files Browse the repository at this point in the history
… (addendum)

Add default implementations of the new methods so that a custom implementation of
RegionCoprocessorEnvironment will not fail to compile after upgrade.
  • Loading branch information
ndimiduk committed Oct 7, 2024
1 parent 5e2bb4b commit e431d84
Showing 1 changed file with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,23 @@ public interface RegionCoprocessorEnvironment extends CoprocessorEnvironment<Reg
/**
* Returns an RpcQuotaManager that can be used to apply quota checks against the workloads
* generated by the coprocessor.
* <p>
* Introduced in 2.6.1. Any custom implementations of this class should implement this method in
* order to take advantage of the new behavior.
* </p>
* @return the RpcQuotaManager
*/
RpcQuotaManager getRpcQuotaManager();
default RpcQuotaManager getRpcQuotaManager() {
throw new UnsupportedOperationException("Not implemented");
}

/**
* 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.
* <p>
* Introduced in 2.6.1. Any custom implementations of this class should implement this method in
* order to take advantage of the new behavior.
* </p>
* @param scan the scan to be estimated against the quota
* @param maxBlockBytesScanned the maximum bytes scanned in a single RPC call by the
* scanner
Expand All @@ -150,33 +160,47 @@ public interface RegionCoprocessorEnvironment extends CoprocessorEnvironment<Reg
* @return the OperationQuota
* @throws RpcThrottlingException if the operation cannot be executed due to quota exceeded.
*/
OperationQuota checkScanQuota(Scan scan, long maxBlockBytesScanned,
long prevBlockBytesScannedDifference) throws IOException, RpcThrottlingException;
default OperationQuota checkScanQuota(Scan scan, long maxBlockBytesScanned,
long prevBlockBytesScannedDifference) throws IOException, RpcThrottlingException {
throw new UnsupportedOperationException("Not implemented");
}

/**
* 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. This method does not support
* scans because estimating a scan's workload is more complicated than estimating the workload of
* a get/put.
* <p>
* Introduced in 2.6.1. Any custom implementations of this class should implement this method in
* order to take advantage of the new behavior.
* </p>
* @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.
*/
OperationQuota checkBatchQuota(final Region region, final OperationQuota.OperationType type)
throws IOException, RpcThrottlingException;
default OperationQuota checkBatchQuota(final Region region,
final OperationQuota.OperationType type) throws IOException, RpcThrottlingException {
throw new UnsupportedOperationException("Not implemented");
}

/**
* 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. This method does not support
* scans because estimating a scan's workload is more complicated than estimating the workload of
* a get/put.
* <p>
* Introduced in 2.6.1. Any custom implementations of this class should implement this method in
* order to take advantage of the new behavior.
* </p>
* @param region the region where the operation will be performed
* @param numWrites number of writes to count against quota
* @param numReads number of reads to count against quota
* @return the OperationQuota
* @throws RpcThrottlingException if the operation cannot be executed due to quota exceeded.
*/
OperationQuota checkBatchQuota(final Region region, int numWrites, int numReads)
throws IOException, RpcThrottlingException;
default OperationQuota checkBatchQuota(final Region region, int numWrites, int numReads)
throws IOException, RpcThrottlingException {
throw new UnsupportedOperationException("Not implemented");
}
}

0 comments on commit e431d84

Please sign in to comment.