Commit ca22400e by Sridhar Swamy Committed by Madhan Neethiraj

ATLAS-3069: avoid repeated warnings of missing relationship-def

parent 3ed1f5a0
...@@ -182,8 +182,7 @@ public class AtlasEntityType extends AtlasStructType { ...@@ -182,8 +182,7 @@ public class AtlasEntityType extends AtlasStructType {
// validate if RelationshipDefs is defined for all entityDefs // validate if RelationshipDefs is defined for all entityDefs
if (attributeEntityType != null && !hasRelationshipAttribute(attributeName)) { if (attributeEntityType != null && !hasRelationshipAttribute(attributeName)) {
LOG.warn("No RelationshipDef defined between {} and {} on attribute: {}.{}", getTypeName(), typeRegistry.reportMissingRelationshipDef(getTypeName(), attributeEntityType.getTypeName(), attributeName);
attributeEntityType.getTypeName(), getTypeName(), attributeName);
} }
} }
......
...@@ -56,16 +56,20 @@ public class AtlasTypeRegistry { ...@@ -56,16 +56,20 @@ public class AtlasTypeRegistry {
protected RegistryData registryData; protected RegistryData registryData;
private final TypeRegistryUpdateSynchronizer updateSynchronizer; private final TypeRegistryUpdateSynchronizer updateSynchronizer;
private final Set<String> missingRelationshipDefs;
public AtlasTypeRegistry() { public AtlasTypeRegistry() {
registryData = new RegistryData(); registryData = new RegistryData();
updateSynchronizer = new TypeRegistryUpdateSynchronizer(this); updateSynchronizer = new TypeRegistryUpdateSynchronizer(this);
missingRelationshipDefs = new HashSet<>();
} }
// used only by AtlasTransientTypeRegistry // used only by AtlasTransientTypeRegistry
protected AtlasTypeRegistry(AtlasTypeRegistry other) { protected AtlasTypeRegistry(AtlasTypeRegistry other) {
registryData = new RegistryData(); registryData = new RegistryData();
updateSynchronizer = other.updateSynchronizer; updateSynchronizer = other.updateSynchronizer;
missingRelationshipDefs = other.missingRelationshipDefs;
} }
public Collection<String> getAllTypeNames() { return registryData.allTypes.getAllTypeNames(); } public Collection<String> getAllTypeNames() { return registryData.allTypes.getAllTypeNames(); }
...@@ -224,6 +228,15 @@ public class AtlasTypeRegistry { ...@@ -224,6 +228,15 @@ public class AtlasTypeRegistry {
updateSynchronizer.releaseTypeRegistryForUpdate(transientTypeRegistry, commitUpdates); updateSynchronizer.releaseTypeRegistryForUpdate(transientTypeRegistry, commitUpdates);
} }
public void reportMissingRelationshipDef(String entityType1, String entityType2, String attributeName) {
String key = entityType1 + "->" + entityType2 + ":" + attributeName;
if (!missingRelationshipDefs.contains(key)) {
LOG.warn("No RelationshipDef defined between {} and {} on attribute: {}.{}", entityType1, entityType2, entityType1, attributeName);
missingRelationshipDefs.add(key);
}
}
static class RegistryData { static class RegistryData {
final TypeCache allTypes; final TypeCache allTypes;
......
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