You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2022/08/22 02:12:19 UTC

[hbase] branch branch-2.5 updated: HBASE-27129 Add a config that allows us to configure region-level storage policies (#4547)

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2.5 by this push:
     new 39848911143 HBASE-27129 Add a config that allows us to configure region-level storage policies (#4547)
39848911143 is described below

commit 398489111432885f53a21ca0861c369322f243b1
Author: tianhang <ta...@gmail.com>
AuthorDate: Mon Aug 22 10:06:14 2022 +0800

    HBASE-27129 Add a config that allows us to configure region-level storage policies (#4547)
    
    Co-authored-by: Tang Tianhang <ti...@shopee.com>
    Signed-off-by: Duo Zhang <zh...@apache.org>
    (cherry picked from commit f238a92b6dfc63dd6a14ea49a7073d6f5ee01a73)
---
 .../java/org/apache/hadoop/hbase/regionserver/HRegion.java |  6 ++++++
 .../hadoop/hbase/regionserver/HRegionFileSystem.java       | 14 ++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index 8a79de85a84..7fc33741bfe 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -250,6 +250,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
@@ -975,6 +978,9 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
       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) {
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
index 2d2965d7237..9ac55759d9b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java
@@ -225,6 +225,20 @@ public class HRegionFileSystem {
     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.