You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ps...@apache.org on 2021/04/23 07:49:43 UTC
[hbase-operator-tools] branch master updated: HBASE-25659 [hbck2]
Add hbase-operator-tools command for scheduleSCPsForUnknownServers (#84)
This is an automated email from the ASF dual-hosted git repository.
psomogyi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase-operator-tools.git
The following commit(s) were added to refs/heads/master by this push:
new 55bca70 HBASE-25659 [hbck2] Add hbase-operator-tools command for scheduleSCPsForUnknownServers (#84)
55bca70 is described below
commit 55bca70c660a1181bedefb7f74365e5cf6a2b3cf
Author: Peter Somogyi <ps...@apache.org>
AuthorDate: Fri Apr 23 09:49:34 2021 +0200
HBASE-25659 [hbck2] Add hbase-operator-tools command for scheduleSCPsForUnknownServers (#84)
Signed-off-by: Wellington Ramos Chevreuil <wc...@apache.org>
---
.../src/main/java/org/apache/hbase/HBCK2.java | 32 ++++++++++-
.../java/org/apache/hbase/TestRecoverUnknown.java | 66 ++++++++++++++++++++++
pom.xml | 2 +-
3 files changed, 98 insertions(+), 2 deletions(-)
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
index 87b20b4..932f39a 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
@@ -99,6 +99,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
private static final String VERSION = "version";
private static final String SET_REGION_STATE = "setRegionState";
private static final String SCHEDULE_RECOVERIES = "scheduleRecoveries";
+ private static final String RECOVER_UNKNOWN = "recoverUnknown";
private static final String GENERATE_TABLE_INFO = "generateMissingTableDescriptorFile";
private static final String FIX_META = "fixMeta";
// TODO update this map in case of the name of a method changes in Hbck interface
@@ -109,7 +110,9 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
put(SET_TABLE_STATE, Arrays.asList("setTableStateInMeta"));
put(BYPASS, Arrays.asList("bypassProcedure"));
put(SCHEDULE_RECOVERIES, Arrays.asList("scheduleServerCrashProcedure",
- "scheduleServerCrashProcedures")); }});
+ "scheduleServerCrashProcedures"));
+ put(RECOVER_UNKNOWN, Arrays.asList("scheduleSCPsForUnknownServers"));
+ }});
private static final String ADD_MISSING_REGIONS_IN_META_FOR_TABLES =
"addFsRegionsMissingInMeta";
@@ -384,6 +387,10 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
return hbck.scheduleServerCrashProcedure(serverNames);
}
+ List<Long> recoverUnknown(Hbck hbck) throws IOException {
+ return hbck.scheduleSCPsForUnknownServers();
+ }
+
private HBaseProtos.ServerName parseServerName(String serverName) {
ServerName sn = ServerName.parseServerName(serverName);
return HBaseProtos.ServerName.newBuilder().setHostName(sn.getHostname()).
@@ -430,6 +437,8 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
writer.println();
usageScheduleRecoveries(writer);
writer.println();
+ usageRecoverUnknown(writer);
+ writer.println();
usageUnassigns(writer);
writer.println();
writer.close();
@@ -659,6 +668,16 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
writer.println(" Command support added in hbase versions 2.0.3, 2.1.2, 2.2.0 or newer.");
}
+ private static void usageRecoverUnknown(PrintWriter writer) {
+ writer.println(" " + RECOVER_UNKNOWN);
+ writer.println(" Schedule ServerCrashProcedure(SCP) for RegionServers that are reported");
+ writer.println(" as unknown.");
+ writer.println(" Returns the pid(s) of the created ServerCrashProcedure(s) or -1 if");
+ writer.println(" no procedure created (see master logs for why not).");
+ writer.println(" Command support added in hbase versions 2.2.7, 2.3.5, 2.4.3,");
+ writer.println(" 2.5.0 or newer.");
+ }
+
private static void usageUnassigns(PrintWriter writer) {
writer.println(" " + UNASSIGNS + " <ENCODED_REGIONNAME>...");
writer.println(" Options:");
@@ -894,6 +913,17 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
}
break;
+ case RECOVER_UNKNOWN:
+ if (commands.length > 1) {
+ showErrorMessage(command + " doesn't take any arguments");
+ return EXIT_FAILURE;
+ }
+ try (ClusterConnection connection = connect(); Hbck hbck = connection.getHbck()) {
+ checkFunctionSupported(connection, command);
+ System.out.println(toString(recoverUnknown(hbck)));
+ }
+ break;
+
case FIX_META:
if (commands.length > 1) {
showErrorMessage(command + " doesn't take any arguments");
diff --git a/hbase-hbck2/src/test/java/org/apache/hbase/TestRecoverUnknown.java b/hbase-hbck2/src/test/java/org/apache/hbase/TestRecoverUnknown.java
new file mode 100644
index 0000000..debfba1
--- /dev/null
+++ b/hbase-hbck2/src/test/java/org/apache/hbase/TestRecoverUnknown.java
@@ -0,0 +1,66 @@
+/*
+ * 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.hbase;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.client.ClusterConnection;
+import org.apache.hadoop.hbase.client.Hbck;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+
+
+public class TestRecoverUnknown {
+ private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+ private HBCK2 hbck2;
+
+ @Rule
+ public TestName name = new TestName();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ TEST_UTIL.startMiniCluster(2);
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ TEST_UTIL.shutdownMiniCluster();
+ }
+
+ @Before
+ public void before() {
+ this.hbck2 = new HBCK2(TEST_UTIL.getConfiguration());
+ }
+
+ @Test
+ public void testKnownServersNotRecovered() throws IOException {
+ try (ClusterConnection connection = this.hbck2.connect(); Hbck hbck = connection.getHbck()) {
+ List<Long> pids = this.hbck2.recoverUnknown(hbck);
+ assertEquals(0, pids.size());
+ }
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 3b5a64b..529c828 100644
--- a/pom.xml
+++ b/pom.xml
@@ -128,7 +128,7 @@
<compileSource>1.8</compileSource>
<java.min.version>${compileSource}</java.min.version>
<maven.min.version>3.3.3</maven.min.version>
- <hbase.version>2.1.6</hbase.version>
+ <hbase.version>2.2.7</hbase.version>
<surefire.provider>surefire-junit47</surefire.provider>
<test.output.tofile>true</test.output.tofile>
<checkstyle.version>8.18</checkstyle.version>