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 2019/09/02 21:03:53 UTC

[GitHub] [hbase-operator-tools] ankitsinghal commented on a change in pull request #18: HBASE-22567 - HBCK2 addMissingRegionsToMeta

ankitsinghal commented on a change in pull request #18: HBASE-22567 - HBCK2 addMissingRegionsToMeta
URL: https://github.com/apache/hbase-operator-tools/pull/18#discussion_r320035461
 
 

 ##########
 File path: hbase-hbck2/src/main/java/org/apache/hbase/hbck2/meta/MetaFixer.java
 ##########
 @@ -0,0 +1,130 @@
+/**
+ * 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.hbck2.meta;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.MetaTableAccessor;
+import org.apache.hadoop.hbase.TableName;
+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.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * This class implements the inner works required for check and recover regions that wrongly
+ * went missing in META. It assumes HDFS state as the source of truth, in other words,
+ * methods provided here consider meta information found on HDFS region dirs as the valid ones.
+ */
+public class MetaFixer implements Closeable {
+  private static final String TABLE_DESC_FILE = ".tabledesc";
+  private static final Logger LOG = LogManager.getLogger(MetaFixer.class);
+  private final FileSystem fs;
+  private final Connection conn;
+  private final Configuration config;
+
+  public MetaFixer(Configuration configuration) throws IOException {
+    this.config = configuration;
+    this.fs = FileSystem.get(configuration);
+    this.conn = ConnectionFactory.createConnection(configuration);
+  }
+
+  /*Initially defined for test only purposes */
+  MetaFixer(Configuration configuration, Connection connection, FileSystem fileSystem){
+    this.config = configuration;
+    this.conn = connection;
+    this.fs = fileSystem;
+  }
+
+  private FileStatus[] getTableRegionsDirs(String table) throws Exception {
+    String hbaseRoot = this.config.get("hbase.rootdir");
+    String tableRootDir = hbaseRoot + "/" + HConstants.BASE_NAMESPACE_DIR + "/" +
 
 Review comment:
   please use FSUtils.getTableDir

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services