Skip to content

Commit 98ef18c

Browse files
author
Tang Tianhang
committed
HBASE-27129 Add a config that allows us to configure region-level storage policies
1 parent 5e5d18b commit 98ef18c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
255255
public static final String SPLIT_IGNORE_BLOCKING_ENABLED_KEY =
256256
"hbase.hregion.split.ignore.blocking.enabled";
257257

258+
public static final String REGION_STORAGE_POLICY_KEY = "hbase.hregion.block.storage.policy";
259+
public static final String DEFAULT_REGION_STORAGE_POLICY = "HOT";
260+
258261
/**
259262
* This is for for using HRegion as a local storage, where we may put the recovered edits in a
260263
* special place. Once this is set, we will only replay the recovered edits under this directory
@@ -986,6 +989,9 @@ private long initializeRegionInternals(final CancelableProgressable reporter,
986989
coprocessorHost.preOpen();
987990
}
988991

992+
String policyName = this.conf.get(REGION_STORAGE_POLICY_KEY, DEFAULT_REGION_STORAGE_POLICY);
993+
this.fs.setStoragePolicy(policyName.trim());
994+
989995
// Write HRI to a file in case we need to recover hbase:meta
990996
// Only the primary replica should write .regioninfo
991997
if (this.getRegionInfo().getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID) {

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,20 @@ public void setStoragePolicy(String familyName, String policyName) {
225225
CommonFSUtils.setStoragePolicy(this.fs, getStoreDir(familyName), policyName);
226226
}
227227

228+
/**
229+
* Set storage policy for a whole region.
230+
* <p>
231+
* If we're running on a version of HDFS that doesn't support the given storage policy
232+
* (or storage policies at all), then we'll issue a log message and continue.
233+
* See http://hadoop.apache.org/docs/r2.6.0/hadoop-project-dist/hadoop-hdfs/ArchivalStorage.html
234+
* for possible list e.g 'COLD', 'WARM', 'HOT', 'ONE_SSD', 'ALL_SSD', 'LAZY_PERSIST'.
235+
*
236+
* @param policyName The name of the storage policy
237+
*/
238+
public void setStoragePolicy(String policyName) {
239+
FSUtils.setStoragePolicy(this.fs, getRegionDir(), policyName);
240+
}
241+
228242
/**
229243
* Get the storage policy of the directory of CF.
230244
* @param familyName The name of column family.

0 commit comments

Comments
 (0)