Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
11 changes: 11 additions & 0 deletions hadoop-hdds/common/src/main/resources/ozone-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3735,6 +3735,17 @@
</description>
</property>

<property>
<name>ozone.recon.heatmap.enable</name>
<value>false</value>
<tag>OZONE, RECON</tag>
<description>
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.
</description>
</property>

<property>
<name>ozone.fs.datastream.enabled</name>
<value>false</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@
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;

/**
* This class is responsible for maintaining Recon features metadata.
*/
@Singleton
public final class FeatureProvider {
private static EnumMap<Feature, Boolean> featureSupportMap =
private static EnumMap<Feature, Boolean> featureDisableMap =
new EnumMap<>(Feature.class);

private FeatureProvider() {
Expand Down Expand Up @@ -69,13 +71,13 @@ public static Feature of(String featureName) {
}
}

public static EnumMap<Feature, Boolean> getFeatureSupportMap() {
return featureSupportMap;
public static EnumMap<Feature, Boolean> getFeatureDisableMap() {
return featureDisableMap;
}

public static List<Feature> 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());

}
Expand All @@ -85,13 +87,15 @@ public static void initFeatureSupport(
resetInitOfFeatureSupport();
String heatMapProviderCls = ozoneConfiguration.get(
OZONE_RECON_HEATMAP_PROVIDER_KEY);
if (StringUtils.isEmpty(heatMapProviderCls)) {
getFeatureSupportMap().put(Feature.HEATMAP, true);
boolean heatMapEnabled = ozoneConfiguration.getBoolean(
OZONE_RECON_HEATMAP_ENABLE_KEY, OZONE_RECON_HEATMAP_ENABLE_DEFAULT);
if (!heatMapEnabled || StringUtils.isEmpty(heatMapProviderCls)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can rename interface as featureDisableMap, to match behaviour

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -105,6 +106,35 @@ public void testGetDisabledFeaturesGreaerThanZero() {
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<FeatureProvider.Feature> allDisabledFeatures =
(List<FeatureProvider.Feature>) disabledFeatures.getEntity();
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<FeatureProvider.Feature> allDisabledFeatures =
(List<FeatureProvider.Feature>) 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<FeatureProvider.Feature> allDisabledFeatures =
Expand Down