meszibalu commented on a change in pull request #763: HBASE-23222 MOB 
compaction supportability improvements
URL: https://github.com/apache/hbase/pull/763#discussion_r339534396
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/mob/ManualMobMaintHFileCleaner.java
 ##########
 @@ -0,0 +1,93 @@
+/**
+ * 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.mob;
+
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentHashMap;
+
+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.HBaseInterfaceAudience;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.master.cleaner.BaseHFileCleanerDelegate;
+import org.apache.hadoop.hbase.util.FSUtils;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.zookeeper.KeeperException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@link BaseHFileCleanerDelegate} that prevents cleaning HFiles from a mob 
region
+ *
+ * keeps a map of table name strings to mob region name strings over the life 
of
+ * a JVM instance. if there's churn of unique table names we'll eat memory 
until
+ * Master restart.
+ */
[email protected](HBaseInterfaceAudience.CONFIG)
+public class ManualMobMaintHFileCleaner extends BaseHFileCleanerDelegate {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(ManualMobMaintHFileCleaner.class);
+
+  // We need to avoid making HRegionInfo objects for every table we check.
+  private static final ConcurrentMap<TableName, String> MOB_REGIONS = new 
ConcurrentHashMap<>();
+
+  @Override
+  public boolean isFileDeletable(FileStatus fStat) {
+    try {
+      // if its a directory, then it can be deleted
+      if (fStat.isDirectory()) return true;
+
+      Path file = fStat.getPath();
+
+      // we need the table and region to determine if this is from a mob region
+      // we don't need to worry about hfilelink back references, because the 
hfilelink cleaner will retain them.
+      Path family = file.getParent();
+      Path region = family.getParent();
+      Path table = region.getParent();
+
+      TableName tableName = FSUtils.getTableName(table);
+
+      String mobRegion = MOB_REGIONS.get(tableName);
+      if (mobRegion == null) {
+        String tmp = MobUtils.getMobRegionInfo(tableName).getEncodedName();
+        if (tmp == null) {
+          LOG.error("couldn't determine mob region for table {} keeping files 
just in case.", tableName);
+          return false;
+        }
+        mobRegion = MOB_REGIONS.putIfAbsent(tableName, tmp);
 
 Review comment:
   I haven't seen the javadoc :( Ok, it sounds good to me.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to