atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject incubator-atlas git commit: ATLAS-1940: fix to remove duplicate type which causes Atlas server to fail during startup
Date Fri, 14 Jul 2017 22:27:00 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/0.8-incubating 9b63509dc -> 63e339a9b


ATLAS-1940: fix to remove duplicate type which causes Atlas server to fail during startup

Signed-off-by: Madhan Neethiraj <madhan@apache.org>
(cherry picked from commit de91608446514df864995d1e50a8db4276b08ad8)


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/63e339a9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/63e339a9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/63e339a9

Branch: refs/heads/0.8-incubating
Commit: 63e339a9bf563dee65c3fe07afbf200c224fca4f
Parents: 9b63509
Author: nixonrodrigues <nixon@apache.org>
Authored: Fri Jul 14 19:16:23 2017 +0530
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Fri Jul 14 15:12:45 2017 -0700

----------------------------------------------------------------------
 .../store/graph/AtlasTypeDefGraphStore.java         | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/63e339a9/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
index 17b7e17..97a578e 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
@@ -613,21 +613,37 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore,
Activ
             for (AtlasStructDef structDef : typesDef.getStructDefs()) {
                 rectifyAttributesIfNeeded(entityNames, structDef);
             }
+            removeDuplicateTypeIfAny(typesDef.getStructDefs());
         }
 
         if (CollectionUtils.isNotEmpty(typesDef.getClassificationDefs())) {
             for (AtlasClassificationDef classificationDef : typesDef.getClassificationDefs())
{
                 rectifyAttributesIfNeeded(entityNames, classificationDef);
             }
+            removeDuplicateTypeIfAny(typesDef.getClassificationDefs());
         }
 
         if (CollectionUtils.isNotEmpty(typesDef.getEntityDefs())) {
             for (AtlasEntityDef entityDef : typesDef.getEntityDefs()) {
                 rectifyAttributesIfNeeded(entityNames, entityDef);
             }
+            removeDuplicateTypeIfAny(typesDef.getEntityDefs());
         }
     }
 
+    private <T extends AtlasBaseTypeDef> void removeDuplicateTypeIfAny(List<T>
defList) {
+        final Set<String> entityDefNames = new HashSet<>();
+
+        for (int i = 0; i < defList.size(); i++) {
+            if (!entityDefNames.add((defList.get(i)).getName())) {
+                LOG.warn(" Found Duplicate Type => " + defList.get(i).getName());
+                defList.remove(i);
+                i--;
+            }
+        }
+    }
+
+
     private void rectifyAttributesIfNeeded(final Set<String> entityNames, AtlasStructDef
structDef) {
         List<AtlasAttributeDef> attributeDefs = structDef.getAttributeDefs();
 


Mime
View raw message