You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by wc...@apache.org on 2020/06/26 12:09:54 UTC

[hbase-operator-tools] branch master updated: HBASE-24626 [HBCK2] Remove reference to hase I.A. private class Commo… (#70)

This is an automated email from the ASF dual-hosted git repository.

wchevreuil 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 51fb5e8  HBASE-24626 [HBCK2] Remove reference to hase I.A. private class Commo… (#70)
51fb5e8 is described below

commit 51fb5e856654e5cf042f0fad076470e2e668f498
Author: Wellington Ramos Chevreuil <wc...@apache.org>
AuthorDate: Fri Jun 26 13:09:44 2020 +0100

    HBASE-24626 [HBCK2] Remove reference to hase I.A. private class Commo… (#70)
    
    Signed-off-by: Viraj Jasani <vj...@apache.org>
    Signed-off-by: Jan Hentschel <ja...@apache.org>
---
 .../org/apache/hbase/FsRegionsMetaRecoverer.java   |  5 +-
 .../main/java/org/apache/hbase/HBCKFsUtils.java    | 88 ++++++++++++++++++++++
 2 files changed, 90 insertions(+), 3 deletions(-)

diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/FsRegionsMetaRecoverer.java b/hbase-hbck2/src/main/java/org/apache/hbase/FsRegionsMetaRecoverer.java
index d1e7a6c..e8a9df7 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/FsRegionsMetaRecoverer.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/FsRegionsMetaRecoverer.java
@@ -42,7 +42,6 @@ import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.ConnectionFactory;
 import org.apache.hadoop.hbase.client.RegionInfo;
 import org.apache.hadoop.hbase.regionserver.HRegionFileSystem;
-import org.apache.hadoop.hbase.util.CommonFSUtils;
 import org.apache.hadoop.hbase.util.FSUtils;
 
 import org.slf4j.Logger;
@@ -64,7 +63,7 @@ public class FsRegionsMetaRecoverer implements Closeable {
 
   public FsRegionsMetaRecoverer(Configuration configuration) throws IOException {
     this.config = configuration;
-    this.fs = CommonFSUtils.getRootDirFileSystem(configuration);
+    this.fs = HBCKFsUtils.getRootDir(configuration).getFileSystem(configuration);
     this.conn = ConnectionFactory.createConnection(configuration);
   }
 
@@ -77,7 +76,7 @@ public class FsRegionsMetaRecoverer implements Closeable {
 
   private List<Path> getTableRegionsDirs(String table) throws IOException {
     String hbaseRoot = this.config.get(HConstants.HBASE_DIR);
-    Path tableDir = CommonFSUtils.getTableDir(new Path(hbaseRoot), TableName.valueOf(table));
+    Path tableDir = HBCKFsUtils.getTableDir(new Path(hbaseRoot), TableName.valueOf(table));
     return FSUtils.getRegionDirs(fs, tableDir);
   }
 
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFsUtils.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFsUtils.java
new file mode 100644
index 0000000..c8785f8
--- /dev/null
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCKFsUtils.java
@@ -0,0 +1,88 @@
+/*
+ * 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 java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.yetus.audience.InterfaceAudience;
+
+
+/**
+ * hbck's local version of the CommonFSUtils from the hbase repo
+ * A Utility class to facilitate hbck2's access to tables/namespace dir structures.
+ */
+@InterfaceAudience.Private
+public final class HBCKFsUtils {
+
+  /**
+   * Private constructor to keep this class from being instantiated.
+   */
+  private HBCKFsUtils() {
+  }
+
+  /**
+   * Returns the {@link org.apache.hadoop.fs.Path} object representing the table directory under
+   * path rootdir
+   *
+   * COPIED from CommonFSUtils.getTableDir
+   *
+   * @param rootdir qualified path of HBase root directory
+   * @param tableName name of table
+   * @return {@link org.apache.hadoop.fs.Path} for table
+   */
+  public static Path getTableDir(Path rootdir, final TableName tableName) {
+    return new Path(getNamespaceDir(rootdir, tableName.getNamespaceAsString()),
+      tableName.getQualifierAsString());
+  }
+
+  /**
+   * Returns the {@link org.apache.hadoop.fs.Path} object representing
+   * the namespace directory under path rootdir
+   *
+   * COPIED from CommonFSUtils.getNamespaceDir
+   *
+   * @param rootdir qualified path of HBase root directory
+   * @param namespace namespace name
+   * @return {@link org.apache.hadoop.fs.Path} for table
+   */
+  public static Path getNamespaceDir(Path rootdir, final String namespace) {
+    return new Path(rootdir, new Path(HConstants.BASE_NAMESPACE_DIR,
+      new Path(namespace)));
+  }
+
+  /**
+   *
+   * COPIED from CommonFSUtils.getRootDir
+   *
+   * @param c configuration
+   * @return {@link Path} to hbase root directory from
+   *     configuration as a qualified Path.
+   * @throws IOException e
+   */
+  public static Path getRootDir(final Configuration c) throws IOException {
+    Path p = new Path(c.get(HConstants.HBASE_DIR));
+    FileSystem fs = p.getFileSystem(c);
+    return p.makeQualified(fs.getUri(), fs.getWorkingDirectory());
+  }
+
+}