hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1523082 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/coprocessor/ main/java/org/apache/hadoop/hbase/master/ main/java/org/apache/hadoop/hbase/security/access/ test/java/org/apache/hadoop/hbase/coprocessor/
Date Fri, 13 Sep 2013 20:28:59 GMT
Author: stack
Date: Fri Sep 13 20:28:58 2013
New Revision: 1523082

URL: http://svn.apache.org/r1523082
Log:
HBASE-9241 Add cp hook before initialize variable set to true in master intialization

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java?rev=1523082&r1=1523081&r2=1523082&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterObserver.java
Fri Sep 13 20:28:58 2013
@@ -305,6 +305,11 @@ public class BaseMasterObserver implemen
   }
 
   @Override
+  public void preMasterInitialization(
+      ObserverContext<MasterCoprocessorEnvironment> ctx) throws IOException {
+  }
+  
+  @Override
   public void start(CoprocessorEnvironment ctx) throws IOException {
   }
 

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java?rev=1523082&r1=1523081&r2=1523082&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/MasterObserver.java
Fri Sep 13 20:28:58 2013
@@ -518,6 +518,13 @@ public interface MasterObserver extends 
       throws IOException;
 
   /**
+   * Call before the master initialization is set to true.
+   * {@link org.apache.hadoop.hbase.master.HMaster} process.
+   */
+  void preMasterInitialization(final ObserverContext<MasterCoprocessorEnvironment>
ctx)
+      throws IOException;
+
+  /**
    * Called before a new snapshot is taken.
    * Called as part of snapshot RPC call.
    * It can't bypass the default action, e.g., ctx.bypass() won't have effect.

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1523082&r1=1523081&r2=1523082&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Fri
Sep 13 20:28:58 2013
@@ -917,6 +917,14 @@ MasterServices, Server {
       startCatalogJanitorChore();
       startNamespaceJanitorChore();
     }
+    
+    if (this.cpHost != null) {
+      try {
+        this.cpHost.preMasterInitialization();
+      } catch (IOException e) {
+        LOG.error("Coprocessor preMasterInitialization() hook failed", e);
+      }
+    }
 
     status.markComplete("Initialization successful");
     LOG.info("Master has completed initialization");

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java?rev=1523082&r1=1523081&r2=1523082&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterCoprocessorHost.java
Fri Sep 13 20:28:58 2013
@@ -1073,6 +1073,23 @@ public class MasterCoprocessorHost
     }
   }
 
+  public void preMasterInitialization() throws IOException {
+    ObserverContext<MasterCoprocessorEnvironment> ctx = null;
+    for (MasterEnvironment env : coprocessors) {
+      if (env.getInstance() instanceof MasterObserver) {
+        ctx = ObserverContext.createAndPrepare(env, ctx);
+        try {
+          ((MasterObserver) env.getInstance()).preMasterInitialization(ctx);
+        } catch (Throwable e) {
+          handleCoprocessorThrowable(env, e);
+        }
+        if (ctx.shouldComplete()) {
+          break;
+        }
+      }
+    }
+  }
+
   void postStartMaster() throws IOException {
     ObserverContext<MasterCoprocessorEnvironment> ctx = null;
     for (MasterEnvironment env: coprocessors) {

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java?rev=1523082&r1=1523081&r2=1523082&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
Fri Sep 13 20:28:58 2013
@@ -780,6 +780,11 @@ public class AccessController extends Ba
   }
 
   @Override
+  public void preMasterInitialization(
+      ObserverContext<MasterCoprocessorEnvironment> ctx) throws IOException {
+  }
+
+  @Override
   public void preSnapshot(final ObserverContext<MasterCoprocessorEnvironment> ctx,
       final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor)
       throws IOException {

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java?rev=1523082&r1=1523081&r2=1523082&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
Fri Sep 13 20:28:58 2013
@@ -103,6 +103,7 @@ public class TestMasterObserver {
     private boolean postBalanceSwitchCalled;
     private boolean preShutdownCalled;
     private boolean preStopMasterCalled;
+    private boolean preMasterInitializationCalled;
     private boolean postStartMasterCalled;
     private boolean startCalled;
     private boolean stopCalled;
@@ -611,6 +612,16 @@ public class TestMasterObserver {
     }
 
     @Override
+    public void preMasterInitialization(
+        ObserverContext<MasterCoprocessorEnvironment> ctx) throws IOException {
+      preMasterInitializationCalled = true;
+    }
+    
+    public boolean wasMasterInitializationCalled(){
+      return preMasterInitializationCalled;
+    }
+    
+    @Override
     public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx)
         throws IOException {
       postStartMasterCalled = true;
@@ -965,6 +976,8 @@ public class TestMasterObserver {
 
     // check basic lifecycle
     assertTrue("MasterObserver should have been started", cp.wasStarted());
+    assertTrue("preMasterInitialization() hook should have been called",
+        cp.wasMasterInitializationCalled());
     assertTrue("postStartMaster() hook should have been called",
         cp.wasStartMasterCalled());
   }



Mime
View raw message