-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-28535: Add a region-server wide key to enable data-tiering. #5856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -985,11 +985,10 @@ void freeSpace(final String why) { | |
|
|
||
| // Check the list of files to determine the cold files which can be readily evicted. | ||
| Map<String, String> coldFiles = null; | ||
| try { | ||
| DataTieringManager dataTieringManager = DataTieringManager.getInstance(); | ||
|
|
||
| DataTieringManager dataTieringManager = DataTieringManager.getInstance(); | ||
| if (dataTieringManager != null) { | ||
| coldFiles = dataTieringManager.getColdFilesList(); | ||
| } catch (IllegalStateException e) { | ||
| LOG.warn("Data Tiering Manager is not set. Ignore time-based block evictions."); | ||
| } | ||
| // Scan entire map putting bucket entry into appropriate bucket entry | ||
| // group | ||
|
|
@@ -2195,17 +2194,19 @@ public Optional<Boolean> blockFitsIntoTheCache(HFileBlock block) { | |
| @Override | ||
| public Optional<Boolean> shouldCacheFile(HFileInfo hFileInfo, Configuration conf) { | ||
| String fileName = hFileInfo.getHFileContext().getHFileName(); | ||
| try { | ||
| DataTieringManager dataTieringManager = DataTieringManager.getInstance(); | ||
| DataTieringManager dataTieringManager = DataTieringManager.getInstance(); | ||
| if (dataTieringManager != null) { | ||
| if (!dataTieringManager.isHotData(hFileInfo, conf)) { | ||
| LOG.debug("Data tiering is enabled for file: '{}' and it is not hot data", fileName); | ||
| return Optional.of(false); | ||
| } else { | ||
| LOG.debug("Data tiering is enabled for file: '{}' and it is hot data", fileName); | ||
|
||
| } | ||
| } catch (IllegalStateException e) { | ||
| LOG.error("Error while getting DataTieringManager instance: {}", e.getMessage()); | ||
| } else { | ||
| LOG.debug("Data tiering feature is not enabled. " | ||
| + " The file: '{}' will be loaded if not already loaded", fileName); | ||
|
||
| } | ||
|
|
||
| // if we don't have the file in fullyCachedFiles, we should cache it | ||
| // if we don't have the file in fullyCachedFiles, we should cache it. | ||
|
||
| return Optional.of(!fullyCachedFiles.containsKey(fileName)); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,8 @@ | |
| @InterfaceAudience.Private | ||
| public class DataTieringManager { | ||
| private static final Logger LOG = LoggerFactory.getLogger(DataTieringManager.class); | ||
| public static final String DATA_TIERING_ENABLED_KEY = "hbase.hstore.datatiering.enable"; | ||
|
||
| public static final boolean DEFAULT_DATA_TIERING_ENABLED = false; // disabled by default | ||
| 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"; | ||
|
|
@@ -61,25 +63,25 @@ private DataTieringManager(Map<String, HRegion> onlineRegions) { | |
| * Initializes the DataTieringManager instance with the provided map of online regions. | ||
| * @param onlineRegions A map containing online regions. | ||
| */ | ||
| public static synchronized void instantiate(Map<String, HRegion> onlineRegions) { | ||
| if (instance == null) { | ||
| instance = new DataTieringManager(onlineRegions); | ||
| LOG.info("DataTieringManager instantiated successfully."); | ||
| public static synchronized void instantiate(Configuration conf, | ||
|
||
| Map<String, HRegion> onlineRegions) { | ||
| if (isDataTieringFeatureEnabled(conf)) { | ||
| if (instance == null) { | ||
| instance = new DataTieringManager(onlineRegions); | ||
| LOG.info("DataTieringManager instantiated successfully."); | ||
| } else { | ||
| LOG.warn("DataTieringManager is already instantiated."); | ||
| } | ||
| } else { | ||
| LOG.warn("DataTieringManager is already instantiated."); | ||
| LOG.info("Data-Tiering feature is not enabled."); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves the instance of DataTieringManager. | ||
| * @return The instance of DataTieringManager. | ||
| * @throws IllegalStateException if DataTieringManager has not been instantiated. | ||
| */ | ||
| public static synchronized DataTieringManager getInstance() { | ||
| if (instance == null) { | ||
| throw new IllegalStateException( | ||
| "DataTieringManager has not been instantiated. Call instantiate() first."); | ||
| } | ||
| return instance; | ||
| } | ||
|
|
||
|
|
@@ -308,4 +310,9 @@ public Map<String, String> getColdFilesList() { | |
| } | ||
| return coldFiles; | ||
| } | ||
|
|
||
| public static boolean isDataTieringFeatureEnabled(Configuration conf) { | ||
| return conf.getBoolean(DataTieringManager.DATA_TIERING_ENABLED_KEY, | ||
| DataTieringManager.DEFAULT_DATA_TIERING_ENABLED); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -534,7 +534,9 @@ public HRegionServer(final Configuration conf) throws IOException { | |
| regionServerAccounting = new RegionServerAccounting(conf); | ||
|
|
||
| blockCache = BlockCacheFactory.createBlockCache(conf); | ||
| DataTieringManager.instantiate(onlineRegions); | ||
| if (DataTieringManager.isDataTieringFeatureEnabled(conf)) { | ||
| DataTieringManager.instantiate(conf, onlineRegions); | ||
| } | ||
|
||
| mobFileCache = new MobFileCache(conf); | ||
|
|
||
| rsSnapshotVerifier = new RSSnapshotVerifier(conf); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this part is needed. We decided not to use Data Tiering logic here and restrict it to Bucket Cache, which I will take care of in the refactoring JIRA. Additionally, if the concern is to avoid executing initMetaAndIndex twice, then I have modified initMetaAndIndex to only execute once.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is to avoid any changes to the old functionality. We had observed that this line does introduce some performance regression leading to a unit test failure. We keep the old behaviour to initialise the metadata at the original location when data-tiering is not enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let us please avoid spaghetti code and keep components cohesive. We shall not pollute the reader with data tiering logic. As @vinayakphegde mentioned, initiMetaAndIndex already knows it should perform init logic only once in the flow, so this call here won't add extra execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I will remove the check here. The intention was to keep the old behaviour when the feature is disabled.