hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anoopsamj...@apache.org
Subject hbase git commit: HBASE-19235 CoprocessorEnvironment should be exposed to CPs.
Date Wed, 15 Nov 2017 09:20:08 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 249bc09d8 -> 7d7048744


HBASE-19235 CoprocessorEnvironment should be exposed to CPs.


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

Branch: refs/heads/master
Commit: 7d704874423fbb387ef3251db220d5d2455e343d
Parents: 249bc09
Author: anoopsamjohn <anoopsamjohn@gmail.com>
Authored: Wed Nov 15 14:49:42 2017 +0530
Committer: anoopsamjohn <anoopsamjohn@gmail.com>
Committed: Wed Nov 15 14:49:42 2017 +0530

----------------------------------------------------------------------
 .../hadoop/hbase/CoprocessorEnvironment.java    | 15 ++----
 .../hbase/coprocessor/BaseEnvironment.java      |  2 -
 .../hbase/coprocessor/CoprocessorHost.java      |  6 ++-
 .../hbase/coprocessor/TestCoprocessorHost.java  | 51 ++------------------
 .../security/token/TestTokenAuthentication.java |  6 ---
 5 files changed, 10 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/7d704874/hbase-client/src/main/java/org/apache/hadoop/hbase/CoprocessorEnvironment.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/CoprocessorEnvironment.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/CoprocessorEnvironment.java
index 4022b4b..418d624 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/CoprocessorEnvironment.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/CoprocessorEnvironment.java
@@ -19,15 +19,15 @@
 
 package org.apache.hadoop.hbase;
 
-import java.io.IOException;
-
 import org.apache.hadoop.conf.Configuration;
 import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.yetus.audience.InterfaceStability;
 
 /**
  * Coprocessor environment state.
  */
-@InterfaceAudience.Private
+@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
+@InterfaceStability.Evolving
 public interface CoprocessorEnvironment<C extends Coprocessor> {
 
   /** @return the Coprocessor interface version */
@@ -52,13 +52,4 @@ public interface CoprocessorEnvironment<C extends Coprocessor> {
    * @return the classloader for the loaded coprocessor instance
    */
   ClassLoader getClassLoader();
-
-  /**
-   * After a coprocessor has been loaded in an encapsulation of an environment, CoprocessorHost
-   * calls this function to initialize the environment.
-   */
-  void startup() throws IOException;
-
-  /** Clean up the environment. Called by CoprocessorHost when it itself is shutting down.
*/
-  void shutdown();
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/7d704874/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java
index 32cef9e..ebbca65 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEnvironment.java
@@ -61,7 +61,6 @@ public class BaseEnvironment<C extends Coprocessor> implements CoprocessorEnviro
   }
 
   /** Initialize the environment */
-  @Override
   public void startup() throws IOException {
     if (state == Coprocessor.State.INSTALLED ||
         state == Coprocessor.State.STOPPED) {
@@ -82,7 +81,6 @@ public class BaseEnvironment<C extends Coprocessor> implements CoprocessorEnviro
   }
 
   /** Clean up the environment */
-  @Override
   public void shutdown() {
     if (state == Coprocessor.State.ACTIVE) {
       state = Coprocessor.State.STOPPING;

http://git-wip-us.apache.org/repos/asf/hbase/blob/7d704874/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 18210d6..61c71cb 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
@@ -260,7 +260,8 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends
Coprocess
     }
     // create the environment
     E env = createEnvironment(impl, priority, loadSequence.incrementAndGet(), conf);
-    env.startup();
+    assert env instanceof BaseEnvironment;
+    ((BaseEnvironment<C>) env).startup();
     // HBASE-4014: maintain list of loaded coprocessors for later crash analysis
     // if server (master or regionserver) aborts.
     coprocessorNames.add(implClass.getName());
@@ -283,10 +284,11 @@ public abstract class CoprocessorHost<C extends Coprocessor, E extends
Coprocess
       throws InstantiationException, IllegalAccessException;
 
   public void shutdown(E e) {
+    assert e instanceof BaseEnvironment;
     if (LOG.isDebugEnabled()) {
       LOG.debug("Stop coprocessor " + e.getInstance().getClass().getName());
     }
-    e.shutdown();
+    ((BaseEnvironment<C>) e).shutdown();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/7d704874/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 f7b8c4b..33a488f 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
@@ -17,8 +17,6 @@
  */
 package org.apache.hadoop.hbase.coprocessor;
 
-import java.io.IOException;
-
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.Abortable;
 import org.apache.hadoop.hbase.Coprocessor;
@@ -68,52 +66,9 @@ public class TestCoprocessorHost {
           final Configuration cpHostConf = conf;
 
       @Override
-      public CoprocessorEnvironment createEnvironment(final RegionCoprocessor instance,
-          final int priority, int sequence, Configuration conf) {
-        return new CoprocessorEnvironment() {
-          final Coprocessor envInstance = instance;
-
-          @Override
-          public int getVersion() {
-            return 0;
-          }
-
-          @Override
-          public String getHBaseVersion() {
-            return "0.0.0";
-          }
-
-          @Override
-          public Coprocessor getInstance() {
-            return envInstance;
-          }
-
-          @Override
-          public int getPriority() {
-            return priority;
-          }
-
-          @Override
-          public int getLoadSequence() {
-            return 0;
-          }
-
-          @Override
-          public Configuration getConfiguration() {
-            return cpHostConf;
-          }
-
-          @Override
-          public void startup() throws IOException {}
-
-          @Override
-          public void shutdown() {}
-
-          @Override
-          public ClassLoader getClassLoader() {
-            return null;
-          }
-        };
+      public CoprocessorEnvironment<RegionCoprocessor> createEnvironment(
+          final RegionCoprocessor instance, final int priority, int sequence, Configuration
conf) {
+        return new BaseEnvironment<RegionCoprocessor>(instance, priority, 0, cpHostConf);
       }
     };
     final String key = "KEY";

http://git-wip-us.apache.org/repos/asf/hbase/blob/7d704874/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
index f116b30..5a0b6bd 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
@@ -279,12 +279,6 @@ public class TestTokenAuthentication {
         }
 
         @Override
-        public void startup() throws IOException {}
-
-        @Override
-        public void shutdown() {}
-
-        @Override
         public ConcurrentMap<String, Object> getSharedData() { return null; }
 
         @Override


Mime
View raw message