Commit de916084 by nixonrodrigues Committed by Madhan Neethiraj

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

parent c3808cf1
......@@ -159,6 +159,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
return ret;
}
@Override
public AtlasRelationshipDef getRelationshipDefByName(String name) throws AtlasBaseException {
AtlasRelationshipDef ret = typeRegistry.getRelationshipDefByName(name);
......@@ -680,21 +681,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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment