Skip to content

Commit fc93fba

Browse files
thangTangTang Tianhang
authored andcommitted
HBASE-27129 Add a config that allows us to configure region-level storage policies (#4547)
Co-authored-by: Tang Tianhang <[email protected]> Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit f238a92)
1 parent f509e43 commit fc93fba

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
@@ -251,6 +251,9 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
251251
public static final String SPLIT_IGNORE_BLOCKING_ENABLED_KEY =
252252
"hbase.hregion.split.ignore.blocking.enabled";
253253

254+
public static final String REGION_STORAGE_POLICY_KEY = "hbase.hregion.block.storage.policy";
255+
public static final String DEFAULT_REGION_STORAGE_POLICY = "NONE";
256+
254257
/**
255258
* This is for for using HRegion as a local storage, where we may put the recovered edits in a
256259
* special place. Once this is set, we will only replay the recovered edits under this directory
@@ -976,6 +979,9 @@ private long initializeRegionInternals(final CancelableProgressable reporter,
976979
coprocessorHost.preOpen();
977980
}
978981

982+
String policyName = this.conf.get(REGION_STORAGE_POLICY_KEY, DEFAULT_REGION_STORAGE_POLICY);
983+
this.fs.setStoragePolicy(policyName.trim());
984+
979985
// Write HRI to a file in case we need to recover hbase:meta
980986
// Only the primary replica should write .regioninfo
981987
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. <br>
230+
* <i>"LAZY_PERSIST"</i>, <i>"ALL_SSD"</i>, <i>"ONE_SSD"</i>, <i>"HOT"</i>, <i>"WARM"</i>,
231+
* <i>"COLD"</i> <br>
232+
* <br>
233+
* See {@link org.apache.hadoop.hdfs.protocol.HdfsConstants} for more details.
234+
* @param policyName The name of the storage policy: 'HOT', 'COLD', etc. See hadoop 2.6+
235+
* org.apache.hadoop.hdfs.protocol.HdfsConstants for possible list e.g 'COLD',
236+
* 'WARM', 'HOT', 'ONE_SSD', 'ALL_SSD', 'LAZY_PERSIST'.
237+
*/
238+
public void setStoragePolicy(String policyName) {
239+
CommonFSUtils.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)