charlesconnell commented on code in PR #6066:
URL: https://github.com/apache/hbase/pull/6066#discussion_r1681214127


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionCoprocessorQuotaUsage.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.coprocessor;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseTestingUtil;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Connection;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.quotas.OperationQuota;
+import org.apache.hadoop.hbase.quotas.RpcThrottlingException;
+import org.apache.hadoop.hbase.testclassification.CoprocessorTests;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category({ MediumTests.class, CoprocessorTests.class })
+public class TestRegionCoprocessorQuotaUsage {
+
+  @ClassRule
+  public static final HBaseClassTestRule CLASS_RULE =
+    HBaseClassTestRule.forClass(TestRegionCoprocessorQuotaUsage.class);
+
+  private static HBaseTestingUtil UTIL = new HBaseTestingUtil();
+  private static TableName TABLE_NAME = 
TableName.valueOf("TestRegionCoprocessorQuotaUsage");
+  private static byte[] CF = Bytes.toBytes("CF");
+  private static byte[] CQ = Bytes.toBytes("CQ");
+  private static Connection CONN;
+  private static Table TABLE;
+  private static AtomicBoolean THROTTLING_OCCURRED = new AtomicBoolean(false);
+
+  public static class MyRegionObserver implements RegionObserver {
+    @Override
+    public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> c, Get 
get,
+      List<Cell> result) throws IOException {
+
+      // For the purposes of this test, we only need to catch a throttle 
happening once, then
+      // let future requests pass through so we don't make this test take any 
longer than necessary
+      if (!THROTTLING_OCCURRED.get()) {
+        try {
+          c.getEnvironment().checkBatchQuota(c.getEnvironment().getRegion(),
+            OperationQuota.OperationType.GET);
+        } catch (RpcThrottlingException e) {
+          THROTTLING_OCCURRED.set(true);
+          throw e;
+        }
+      }
+    }
+  }
+
+  public static class MyCoprocessor implements RegionCoprocessor {
+    private RegionCoprocessorEnvironment env;

Review Comment:
   indeed



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java:
##########
@@ -131,6 +138,12 @@ public RegionEnvironment(final RegionCoprocessor impl, 
final int priority, final
       this.services = services;
       this.metricRegistry =
         
MetricsCoprocessor.createRegistryForRegionCoprocessor(impl.getClass().getName());
+      // lets unit tests through

Review Comment:
   made this more clear



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to