hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-15990 The priority value of subsequent coprocessors in the Coprocessor.Priority.SYSTEM list are not incremented by one (ChiaPing Tsai)
Date Thu, 09 Jun 2016 18:20:42 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 a40ec70da -> a4e2b3856


HBASE-15990 The priority value of subsequent coprocessors in the Coprocessor.Priority.SYSTEM
list are not incremented by one (ChiaPing Tsai)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a4e2b385
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a4e2b385
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a4e2b385

Branch: refs/heads/branch-1
Commit: a4e2b3856ea2db7f221330a6f6493f18ebfbc14f
Parents: a40ec70
Author: tedyu <yuzhihong@gmail.com>
Authored: Thu Jun 9 11:20:33 2016 -0700
Committer: Ted <yuzhihong@gmail.com>
Committed: Thu Jun 9 11:20:33 2016 -0700

----------------------------------------------------------------------
 .../hbase/coprocessor/CoprocessorHost.java      |  5 ++--
 .../hbase/coprocessor/TestCoprocessorHost.java  | 26 ++++++++++++++------
 2 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a4e2b385/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
index 96e027b..91b9057 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/CoprocessorHost.java
@@ -159,9 +159,10 @@ public abstract class CoprocessorHost<E extends CoprocessorEnvironment>
{
         implClass = cl.loadClass(className);
         // Add coprocessors as we go to guard against case where a coprocessor is specified
twice
         // in the configuration
-        this.coprocessors.add(loadInstance(implClass, Coprocessor.PRIORITY_SYSTEM, conf));
+        this.coprocessors.add(loadInstance(implClass, priority, conf));
         LOG.info("System coprocessor " + className + " was loaded " +
-            "successfully with priority (" + priority++ + ").");
+            "successfully with priority (" + priority + ").");
+        ++priority;
       } catch (Throwable t) {
         // We always abort if system coprocessors cannot be loaded
         abortServer(className, t);

http://git-wip-us.apache.org/repos/asf/hbase/blob/a4e2b385/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorHost.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorHost.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorHost.java
index 2faaf74..17d0b8e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorHost.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorHost.java
@@ -29,6 +29,8 @@ import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.HTableInterface;
 import org.apache.hadoop.hbase.testclassification.SmallTests;
 import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -51,9 +53,8 @@ public class TestCoprocessorHost {
       return this.aborted;
     }
   }
-
   @Test
-  public void testDoubleLoading() {
+  public void testDoubleLoadingAndPriorityValue() {
     final Configuration conf = HBaseConfiguration.create();
     CoprocessorHost<CoprocessorEnvironment> host =
         new CoprocessorHost<CoprocessorEnvironment>(new TestAbortable()) {
@@ -61,7 +62,7 @@ public class TestCoprocessorHost {
 
       @Override
       public CoprocessorEnvironment createEnvironment(Class<?> implClass,
-          final Coprocessor instance, int priority, int sequence, Configuration conf) {
+          final Coprocessor instance, final int priority, int sequence, Configuration conf)
{
         return new CoprocessorEnvironment() {
           final Coprocessor envInstance = instance;
 
@@ -82,7 +83,7 @@ public class TestCoprocessorHost {
 
           @Override
           public int getPriority() {
-            return 0;
+            return priority;
           }
 
           @Override
@@ -115,10 +116,19 @@ public class TestCoprocessorHost {
     };
     final String key = "KEY";
     final String coprocessor = "org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver";
-    // Try and load coprocessor three times.
-    conf.setStrings(key, coprocessor, coprocessor, coprocessor);
+    // Try and load a coprocessor three times
+    conf.setStrings(key, coprocessor, coprocessor, coprocessor, SimpleRegionObserverV2.class.getName());
     host.loadSystemCoprocessors(conf, key);
-    // Only one coprocessor loaded
-    Assert.assertEquals(1, host.coprocessors.size());
+    // Two coprocessors(SimpleRegionObserver and SimpleRegionObserverV2) loaded
+    Assert.assertEquals(2, host.coprocessors.size());
+    // Check the priority value
+    CoprocessorEnvironment simpleEnv = host.findCoprocessorEnvironment(SimpleRegionObserver.class.getName());
+    CoprocessorEnvironment simpleEnv_v2 = host.findCoprocessorEnvironment(SimpleRegionObserverV2.class.getName());
+    assertNotNull(simpleEnv);
+    assertNotNull(simpleEnv_v2);
+    assertEquals(Coprocessor.PRIORITY_SYSTEM, simpleEnv.getPriority());
+    assertEquals(Coprocessor.PRIORITY_SYSTEM + 1, simpleEnv_v2.getPriority());
+  }
+  public static class SimpleRegionObserverV2 extends SimpleRegionObserver {
   }
 }
\ No newline at end of file


Mime
View raw message