-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBASE-23222 MOB compaction supportability improvements
* better logging on MOB compaction process * HFileCleanerDelegate to optionally halt removal of mob hfiles * use archiving when removing committed mob file after bulkload ref failure closes #763 Signed-off-by: Wellington Chevreuil <[email protected]> Signed-off-by: Balazs Meszaros <[email protected]>
- Loading branch information
Showing
5 changed files
with
180 additions
and
16 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
hbase-server/src/main/java/org/apache/hadoop/hbase/mob/ManualMobMaintHFileCleaner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/** | ||
* 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.ConcurrentHashMap; | ||
import java.util.concurrent.ConcurrentMap; | ||
|
||
import org.apache.hadoop.fs.FileStatus; | ||
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.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. | ||
*/ | ||
@InterfaceAudience.LimitedPrivate(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); | ||
// a return of null means that tmp is now in the map for future lookups. | ||
if (mobRegion == null) { | ||
mobRegion = tmp; | ||
} | ||
LOG.debug("Had to calculate name of mob region for table {} and it is {}", tableName, | ||
mobRegion); | ||
} | ||
|
||
boolean ret = !mobRegion.equals(region.getName()); | ||
if (LOG.isDebugEnabled() && !ret) { | ||
LOG.debug("Keeping file '{}' because it is from mob dir", fStat.getPath()); | ||
} | ||
return ret; | ||
} catch (RuntimeException e) { | ||
LOG.error("Failed to determine mob status of '{}', keeping it just in case.", fStat.getPath(), | ||
e); | ||
return false; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters