From b6db534a4503afbe10f98936c26047c7de4e8d21 Mon Sep 17 00:00:00 2001 From: deveshsingh Date: Wed, 7 Jun 2023 18:15:28 +0530 Subject: [PATCH 1/4] HDDS-8779. Recon - Expose flag for enable/disable of heatmap. --- .../org/apache/hadoop/hdds/recon/ReconConfigKeys.java | 3 +++ .../common/src/main/resources/ozone-default.xml | 11 +++++++++++ .../hadoop/ozone/recon/api/types/FeatureProvider.java | 6 +++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/recon/ReconConfigKeys.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/recon/ReconConfigKeys.java index 47d3b00dd565..3571d39bc8a2 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/recon/ReconConfigKeys.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/recon/ReconConfigKeys.java @@ -44,6 +44,9 @@ private ReconConfigKeys() { // Fully qualified heatmap provider implementation class name key. public static final String OZONE_RECON_HEATMAP_PROVIDER_KEY = "ozone.recon.heatmap.provider"; + public static final String OZONE_RECON_HEATMAP_ENABLE_KEY = + "ozone.recon.heatmap.enable"; + public static final boolean OZONE_RECON_HEATMAP_ENABLE_DEFAULT = false; public static final String OZONE_RECON_ADDRESS_DEFAULT = "0.0.0.0:9891"; public static final String OZONE_RECON_HTTP_ADDRESS_KEY = diff --git a/hadoop-hdds/common/src/main/resources/ozone-default.xml b/hadoop-hdds/common/src/main/resources/ozone-default.xml index f90fea4908b3..280ce927532f 100644 --- a/hadoop-hdds/common/src/main/resources/ozone-default.xml +++ b/hadoop-hdds/common/src/main/resources/ozone-default.xml @@ -3735,6 +3735,17 @@ + + ozone.recon.heatmap.enable + false + OZONE, RECON + + To enable/disable recon heatmap feature. Along with this config, user must also provide the implementation + of "org.apache.hadoop.ozone.recon.heatmap.IHeatMapProvider" interface and configure in + "ozone.recon.heatmap.provider" configuration. + + + ozone.fs.datastream.enabled false diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/FeatureProvider.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/FeatureProvider.java index 7696b3992593..c0d859b82958 100644 --- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/FeatureProvider.java +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/FeatureProvider.java @@ -27,6 +27,8 @@ import java.util.List; import java.util.stream.Collectors; +import static org.apache.hadoop.hdds.recon.ReconConfigKeys.OZONE_RECON_HEATMAP_ENABLE_DEFAULT; +import static org.apache.hadoop.hdds.recon.ReconConfigKeys.OZONE_RECON_HEATMAP_ENABLE_KEY; import static org.apache.hadoop.hdds.recon.ReconConfigKeys.OZONE_RECON_HEATMAP_PROVIDER_KEY; /** @@ -85,7 +87,9 @@ public static void initFeatureSupport( resetInitOfFeatureSupport(); String heatMapProviderCls = ozoneConfiguration.get( OZONE_RECON_HEATMAP_PROVIDER_KEY); - if (StringUtils.isEmpty(heatMapProviderCls)) { + boolean heatMapEnabled = ozoneConfiguration.getBoolean( + OZONE_RECON_HEATMAP_ENABLE_KEY, OZONE_RECON_HEATMAP_ENABLE_DEFAULT); + if (!heatMapEnabled || StringUtils.isEmpty(heatMapProviderCls)) { getFeatureSupportMap().put(Feature.HEATMAP, true); } } From b9d85a94944ce4cbe1ab3e04024a2922f58bbaad Mon Sep 17 00:00:00 2001 From: deveshsingh Date: Wed, 7 Jun 2023 18:28:30 +0530 Subject: [PATCH 2/4] HDDS-8779. Added Junit test cases. --- .../ozone/recon/api/TestFeaturesEndPoint.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestFeaturesEndPoint.java b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestFeaturesEndPoint.java index 3534da7ff601..b29e61a799fb 100644 --- a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestFeaturesEndPoint.java +++ b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestFeaturesEndPoint.java @@ -37,6 +37,7 @@ import java.util.List; +import static org.apache.hadoop.hdds.recon.ReconConfigKeys.OZONE_RECON_HEATMAP_ENABLE_KEY; import static org.apache.hadoop.hdds.recon.ReconConfigKeys.OZONE_RECON_HEATMAP_PROVIDER_KEY; import static org.apache.hadoop.ozone.recon.OMMetadataManagerTestUtils.getTestReconOmMetadataManager; import static org.apache.hadoop.ozone.recon.OMMetadataManagerTestUtils.initializeNewOmMetadataManager; @@ -89,7 +90,7 @@ public void setUp() throws Exception { } @Test - public void testGetDisabledFeaturesGreaerThanZero() { + public void testGetDisabledFeaturesGreaterThanZero() { ozoneConfiguration.set(OZONE_RECON_HEATMAP_PROVIDER_KEY, ""); FeatureProvider.initFeatureSupport(ozoneConfiguration); Response disabledFeatures = featuresEndPoint.getDisabledFeatures(); @@ -112,4 +113,32 @@ public void testNoDisabledFeatures() { Assertions.assertNotNull(allDisabledFeatures); Assertions.assertTrue(allDisabledFeatures.size() == 0); } + + @Test + public void testGetHeatMapInDisabledFeaturesListWhenHeatMapFlagIsFalse() { + ozoneConfiguration.set(OZONE_RECON_HEATMAP_PROVIDER_KEY, + "org.apache.hadoop.ozone.recon.heatmap.TestHeatMapProviderImpl"); + ozoneConfiguration.setBoolean(OZONE_RECON_HEATMAP_ENABLE_KEY, false); + FeatureProvider.initFeatureSupport(ozoneConfiguration); + Response disabledFeatures = featuresEndPoint.getDisabledFeatures(); + List allDisabledFeatures = + (List) disabledFeatures.getEntity(); + Assertions.assertNotNull(allDisabledFeatures); + Assertions.assertTrue(allDisabledFeatures.size() > 0); + Assertions.assertEquals(FeatureProvider.Feature.HEATMAP.getFeatureName(), + allDisabledFeatures.get(0).getFeatureName()); + } + + @Test + public void testGetHeatMapNotInDisabledFeaturesListWhenHeatMapFlagIsTrue() { + ozoneConfiguration.set(OZONE_RECON_HEATMAP_PROVIDER_KEY, + "org.apache.hadoop.ozone.recon.heatmap.TestHeatMapProviderImpl"); + ozoneConfiguration.setBoolean(OZONE_RECON_HEATMAP_ENABLE_KEY, true); + FeatureProvider.initFeatureSupport(ozoneConfiguration); + Response disabledFeatures = featuresEndPoint.getDisabledFeatures(); + List allDisabledFeatures = + (List) disabledFeatures.getEntity(); + Assertions.assertNotNull(allDisabledFeatures); + Assertions.assertTrue(allDisabledFeatures.size() == 0); + } } From 195670532ee0b21aa7d9a73cce4ed78be2bd30af Mon Sep 17 00:00:00 2001 From: deveshsingh Date: Wed, 7 Jun 2023 21:21:02 +0530 Subject: [PATCH 3/4] HDDS-8779. Fixed Junit test cases. --- .../org/apache/hadoop/ozone/recon/api/TestFeaturesEndPoint.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestFeaturesEndPoint.java b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestFeaturesEndPoint.java index b29e61a799fb..6790befca7fd 100644 --- a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestFeaturesEndPoint.java +++ b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestFeaturesEndPoint.java @@ -106,6 +106,7 @@ public void testGetDisabledFeaturesGreaterThanZero() { public void testNoDisabledFeatures() { ozoneConfiguration.set(OZONE_RECON_HEATMAP_PROVIDER_KEY, "org.apache.hadoop.ozone.recon.heatmap.TestHeatMapProviderImpl"); + ozoneConfiguration.setBoolean(OZONE_RECON_HEATMAP_ENABLE_KEY, true); FeatureProvider.initFeatureSupport(ozoneConfiguration); Response disabledFeatures = featuresEndPoint.getDisabledFeatures(); List allDisabledFeatures = From 8ff1c1f7f6ec44d63b7bb43dcc43a0e8d0cedb01 Mon Sep 17 00:00:00 2001 From: deveshsingh Date: Thu, 8 Jun 2023 17:55:55 +0530 Subject: [PATCH 4/4] HDDS-8779. Fixed review comment - rename hashmap. --- .../ozone/recon/api/types/FeatureProvider.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/FeatureProvider.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/FeatureProvider.java index c0d859b82958..60d701d18b82 100644 --- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/FeatureProvider.java +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/FeatureProvider.java @@ -36,7 +36,7 @@ */ @Singleton public final class FeatureProvider { - private static EnumMap featureSupportMap = + private static EnumMap featureDisableMap = new EnumMap<>(Feature.class); private FeatureProvider() { @@ -71,13 +71,13 @@ public static Feature of(String featureName) { } } - public static EnumMap getFeatureSupportMap() { - return featureSupportMap; + public static EnumMap getFeatureDisableMap() { + return featureDisableMap; } public static List getAllDisabledFeatures() { - return getFeatureSupportMap().keySet().stream().filter(feature -> - Boolean.TRUE.equals(getFeatureSupportMap().get(feature))).collect( + return getFeatureDisableMap().keySet().stream().filter(feature -> + Boolean.TRUE.equals(getFeatureDisableMap().get(feature))).collect( Collectors.toList()); } @@ -90,12 +90,12 @@ public static void initFeatureSupport( boolean heatMapEnabled = ozoneConfiguration.getBoolean( OZONE_RECON_HEATMAP_ENABLE_KEY, OZONE_RECON_HEATMAP_ENABLE_DEFAULT); if (!heatMapEnabled || StringUtils.isEmpty(heatMapProviderCls)) { - getFeatureSupportMap().put(Feature.HEATMAP, true); + getFeatureDisableMap().put(Feature.HEATMAP, true); } } private static void resetInitOfFeatureSupport() { - getFeatureSupportMap().keySet() - .forEach(feature -> getFeatureSupportMap().put(feature, false)); + getFeatureDisableMap().keySet() + .forEach(feature -> getFeatureDisableMap().put(feature, false)); } }