Skip to content

Commit

Permalink
HBASE-27129 Add a config that allows us to configure region-level sto…
Browse files Browse the repository at this point in the history
…rage policies (#4547)

Co-authored-by: Tang Tianhang <tianhang.tang@shopee.com>
Signed-off-by: Duo Zhang <zhangduo@apache.org>
  • Loading branch information
thangTang and Tang Tianhang committed Aug 22, 2022
1 parent 7ff927d commit f238a92
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
public static final String SPLIT_IGNORE_BLOCKING_ENABLED_KEY =
"hbase.hregion.split.ignore.blocking.enabled";

public static final String REGION_STORAGE_POLICY_KEY = "hbase.hregion.block.storage.policy";
public static final String DEFAULT_REGION_STORAGE_POLICY = "NONE";

/**
* This is for for using HRegion as a local storage, where we may put the recovered edits in a
* special place. Once this is set, we will only replay the recovered edits under this directory
Expand Down Expand Up @@ -980,6 +983,9 @@ private long initializeRegionInternals(final CancelableProgressable reporter,
coprocessorHost.preOpen();
}

String policyName = this.conf.get(REGION_STORAGE_POLICY_KEY, DEFAULT_REGION_STORAGE_POLICY);
this.fs.setStoragePolicy(policyName.trim());

// Write HRI to a file in case we need to recover hbase:meta
// Only the primary replica should write .regioninfo
if (this.getRegionInfo().getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,20 @@ public void setStoragePolicy(String familyName, String policyName) {
CommonFSUtils.setStoragePolicy(this.fs, getStoreDir(familyName), policyName);
}

/**
* Set storage policy for a whole region. <br>
* <i>"LAZY_PERSIST"</i>, <i>"ALL_SSD"</i>, <i>"ONE_SSD"</i>, <i>"HOT"</i>, <i>"WARM"</i>,
* <i>"COLD"</i> <br>
* <br>
* See {@link org.apache.hadoop.hdfs.protocol.HdfsConstants} for more details.
* @param policyName The name of the storage policy: 'HOT', 'COLD', etc. See hadoop 2.6+
* org.apache.hadoop.hdfs.protocol.HdfsConstants for possible list e.g 'COLD',
* 'WARM', 'HOT', 'ONE_SSD', 'ALL_SSD', 'LAZY_PERSIST'.
*/
public void setStoragePolicy(String policyName) {
CommonFSUtils.setStoragePolicy(this.fs, getRegionDir(), policyName);
}

/**
* Get the storage policy of the directory of CF.
* @param familyName The name of column family.
Expand Down

0 comments on commit f238a92

Please sign in to comment.