You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2022/04/21 12:22:27 UTC

[GitHub] [hbase] carp84 commented on a diff in pull request #4358: HBASE-26951 HMaster should exit gracefully, when stopped via hbase-daemon.sh

carp84 commented on code in PR #4358:
URL: https://github.com/apache/hbase/pull/4358#discussion_r855109431


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ShutdownHook.java:
##########
@@ -85,7 +85,7 @@ public static void install(final Configuration conf, final FileSystem fs,
     Runnable fsShutdownHook = suppressHdfsShutdownHook(fs);
     Thread t = new ShutdownHookThread(conf, stop, threadToJoin, fsShutdownHook);
     ShutdownHookManager.affixShutdownHook(t, 0);
-    LOG.debug("Installed shutdown hook thread: " + t.getName());
+    LOG.info("Installed shutdown hook thread: " + t.getName());

Review Comment:
   It seems this change is not necessary



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/HBaseServerBase.java:
##########
@@ -447,6 +451,22 @@ protected final void closeZooKeeper() {
     }
   }
 
+  /**
+   * In order to register ShutdownHook, this method is called
+   * when HMaster and HRegionServer are started.
+   * For details, please refer to HBASE-26951
+   */
+  protected void intallShutdownHook() {
+    ShutdownHook.install(conf, dataFs, this, Thread.currentThread());
+    isInstalledShutdownHook = true;

Review Comment:
   ```suggestion
       isShutdownHookInstalled = true;
   ```



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/HBaseServerBase.java:
##########
@@ -447,6 +451,22 @@ protected final void closeZooKeeper() {
     }
   }
 
+  /**
+   * In order to register ShutdownHook, this method is called
+   * when HMaster and HRegionServer are started.
+   * For details, please refer to HBASE-26951
+   */
+  protected void intallShutdownHook() {
+    ShutdownHook.install(conf, dataFs, this, Thread.currentThread());
+    isInstalledShutdownHook = true;
+  }
+
+  @RestrictedApi(explanation = "Should only be called in tests", link = "",
+    allowedOnPath = ".*/src/test/.*")
+  public boolean isInstalledShutdownHook() {

Review Comment:
   ```suggestion
     public boolean isShutdownHookInstalled() {
   ```



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/HBaseServerBase.java:
##########
@@ -447,6 +451,22 @@ protected final void closeZooKeeper() {
     }
   }
 
+  /**
+   * In order to register ShutdownHook, this method is called
+   * when HMaster and HRegionServer are started.
+   * For details, please refer to HBASE-26951
+   */
+  protected void intallShutdownHook() {
+    ShutdownHook.install(conf, dataFs, this, Thread.currentThread());
+    isInstalledShutdownHook = true;
+  }
+
+  @RestrictedApi(explanation = "Should only be called in tests", link = "",
+    allowedOnPath = ".*/src/test/.*")
+  public boolean isInstalledShutdownHook() {
+    return isInstalledShutdownHook;

Review Comment:
   ```suggestion
       return isShutdownHookInstalled;
   ```



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java:
##########
@@ -305,5 +305,10 @@ public void testBlockingHbkc1WithLockFile() throws IOException {
     // Assert lock gets put in place again.
     assertTrue(fs.exists(hbckLockPath));
   }
-}
 
+  @Test
+  public void testInstallShutdownHook() throws IOException {
+    // Test for HBASE-26951
+    assertTrue(TEST_UTIL.getHBaseCluster().getMaster().isInstalledShutdownHook());

Review Comment:
   ```suggestion
       assertTrue(TEST_UTIL.getHBaseCluster().getMaster().isShutdownHookInstalled());
   ```



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/HBaseServerBase.java:
##########
@@ -91,6 +92,9 @@
   // of HRegionServer in isolation.
   protected volatile boolean stopped = false;
 
+  // Only test for HBASE-26951
+  private boolean isInstalledShutdownHook = false;

Review Comment:
   ```suggestion
     // Only for testing
     private boolean isShutdownHookInstalled = false;
   ```



##########
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServer.java:
##########
@@ -0,0 +1,57 @@
+/**
+ * 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.regionserver;
+
+import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HBaseTestingUtil;
+import org.apache.hadoop.hbase.testclassification.MasterTests;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category({MasterTests.class, MediumTests.class})
+public class TestHRegionServer {

Review Comment:
   I'd suggest to add the test in `TestRegionServerNoMaster` instead of creating a new class.



-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org