vinayakphegde commented on code in PR #5793:
URL: https://github.com/apache/hbase/pull/5793#discussion_r1553288683


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DataTieringManager.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * 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.regionserver;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.OptionalLong;
+import java.util.Set;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.io.hfile.BlockCacheKey;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
[email protected]
+public class DataTieringManager {
+  private static final Logger LOG = 
LoggerFactory.getLogger(DataTieringManager.class);
+  public static final String DATATIERING_KEY = "hbase.hstore.datatiering.type";
+  public static final String DATATIERING_HOT_DATA_AGE_KEY =
+    "hbase.hstore.datatiering.hot.age.millis";
+  public static final DataTieringType DEFAULT_DATATIERING = 
DataTieringType.NONE;
+  public static final long DEFAULT_DATATIERING_HOT_DATA_AGE = 7 * 24 * 60 * 60 
* 1000; // 7 Days
+  private static DataTieringManager instance;
+  private final Map<String, HRegion> onlineRegions;
+
+  private DataTieringManager(Map<String, HRegion> onlineRegions) {
+    this.onlineRegions = onlineRegions;
+  }
+
+  public static synchronized void instantiate(Map<String, HRegion> 
onlineRegions) {
+    if (instance == null) {
+      instance = new DataTieringManager(onlineRegions);
+      LOG.info("DataTieringManager instantiated successfully.");
+    } else {
+      LOG.warn("DataTieringManager is already instantiated.");
+    }
+  }
+
+  public static synchronized DataTieringManager getInstance() {
+    if (instance == null) {
+      throw new IllegalStateException(
+        "DataTieringManager has not been instantiated. Call instantiate() 
first.");
+    }
+    return instance;
+  }
+
+  public boolean isDataTieringEnabled(BlockCacheKey key) throws 
DataTieringException {
+    Path hFilePath = key.getFilePath();
+    if (hFilePath == null) {
+      throw new DataTieringException("BlockCacheKey Doesn't Contain HFile 
Path");
+    }
+    return isDataTieringEnabled(hFilePath);
+  }
+
+  public boolean isDataTieringEnabled(Path hFilePath) throws 
DataTieringException {
+    Configuration configuration = getConfiguration(hFilePath);
+    DataTieringType dataTieringType = getDataTieringType(configuration);
+    return !dataTieringType.equals(DataTieringType.NONE);
+  }
+
+  public boolean isHotData(BlockCacheKey key) throws DataTieringException {
+    Path hFilePath = key.getFilePath();
+    if (hFilePath == null) {
+      throw new DataTieringException("BlockCacheKey Doesn't Contain HFile 
Path");
+    }
+    return isHotData(hFilePath);
+  }
+
+  public boolean isHotData(Path hFilePath) throws DataTieringException {
+    Configuration configuration = getConfiguration(hFilePath);
+    DataTieringType dataTieringType = getDataTieringType(configuration);
+
+    if (dataTieringType.equals(DataTieringType.TIME_RANGE)) {
+      long hotDataAge = getDataTieringHotDataAge(configuration);
+
+      HStoreFile hStoreFile = getHStoreFile(hFilePath);
+      if (hStoreFile == null) {
+        throw new DataTieringException(

Review Comment:
   Got it. should we change in other places as well?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to