This is an automated email from the ASF dual-hosted git repository. nbonte pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new 295057f ATLAS-4150 Remove System Internal Entity Types from Metrics GET api. 295057f is described below commit 295057f78ae988d4397605c85215495773e0ba13 Author: Mandar Ambawane <mandar.ambaw...@freestoneinfotech.com> AuthorDate: Thu Jul 8 23:37:10 2021 +0530 ATLAS-4150 Remove System Internal Entity Types from Metrics GET api. Signed-off-by: Nikhil Bonte <nbo...@apache.org> (cherry picked from commit 4c7aea1a170a1173fa1bb13023c79d52f5f27799) --- .../main/java/org/apache/atlas/services/MetricsService.java | 10 +++++++--- .../java/org/apache/atlas/services/MetricsServiceTest.java | 5 ++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/services/MetricsService.java b/repository/src/main/java/org/apache/atlas/services/MetricsService.java index e721108..ceb2528 100644 --- a/repository/src/main/java/org/apache/atlas/services/MetricsService.java +++ b/repository/src/main/java/org/apache/atlas/services/MetricsService.java @@ -26,9 +26,9 @@ import org.apache.atlas.model.metrics.AtlasMetrics; import org.apache.atlas.model.typedef.AtlasClassificationDef; import org.apache.atlas.model.typedef.AtlasEntityDef; import org.apache.atlas.model.typedef.AtlasTypesDef; +import org.apache.atlas.repository.Constants; import org.apache.atlas.repository.graphdb.AtlasGraph; import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2; -import org.apache.atlas.type.AtlasClassificationType; import org.apache.atlas.type.AtlasEntityType; import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.util.AtlasMetricJVMUtil; @@ -38,7 +38,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.inject.Inject; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -245,7 +244,12 @@ public class MetricsService { Collection<AtlasEntityDef> entityDefs = typeRegistry.getAllEntityDefs(); if (CollectionUtils.isNotEmpty(entityDefs)) { - ret.getEntityDefs().addAll(entityDefs); + for(AtlasEntityDef entityDef : entityDefs) { + if(!(CollectionUtils.isNotEmpty(entityDef.getSuperTypes()) && + entityDef.getSuperTypes().contains(Constants.TYPE_NAME_INTERNAL))) { + ret.getEntityDefs().add(entityDef); + } + } } Collection<AtlasClassificationDef> classificationTypes = typeRegistry.getAllClassificationDefs(); diff --git a/repository/src/test/java/org/apache/atlas/services/MetricsServiceTest.java b/repository/src/test/java/org/apache/atlas/services/MetricsServiceTest.java index bea8eb8..0405921 100644 --- a/repository/src/test/java/org/apache/atlas/services/MetricsServiceTest.java +++ b/repository/src/test/java/org/apache/atlas/services/MetricsServiceTest.java @@ -87,7 +87,6 @@ public class MetricsServiceTest extends AtlasTestBase { private final Map<String, Long> activeEntityMetricsExpected = new HashMap<String, Long>() {{ put("hive_storagedesc", 5L); - put("__ExportImportAuditEntry", 1L); put("AtlasServer", 1L); put("hive_column_lineage", 8L); put("hive_table", 5L); @@ -153,7 +152,7 @@ public class MetricsServiceTest extends AtlasTestBase { assertNotNull(metrics); // general metrics - assertEquals(metrics.getNumericMetric(GENERAL, METRIC_ENTITY_COUNT).intValue(), 43); + assertEquals(metrics.getNumericMetric(GENERAL, METRIC_ENTITY_COUNT).intValue(), 42); assertEquals(metrics.getNumericMetric(GENERAL, METRIC_TAG_COUNT).intValue(), 1); assertTrue(metrics.getNumericMetric(GENERAL, METRIC_TYPE_UNUSED_COUNT).intValue() >= 10); assertTrue(metrics.getNumericMetric(GENERAL, METRIC_TYPE_COUNT).intValue() >= 44); @@ -164,7 +163,7 @@ public class MetricsServiceTest extends AtlasTestBase { Map deletedEntityMetricsActual = (Map) metrics.getMetric(ENTITY, METRIC_ENTITY_DELETED); assertEquals(tagMetricsActual.size(), 1); - assertEquals(activeEntityMetricsActual.size(), 8); + assertEquals(activeEntityMetricsActual.size(), 7); assertEquals(deletedEntityMetricsActual.size(), 4); assertEquals(tagMetricsActual, tagMetricsExpected);