This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/master by this push:
     new ca22400  ATLAS-3069: avoid repeated warnings of missing 
relationship-def
ca22400 is described below

commit ca22400ebf425088097b20b33873c15a71d5f908
Author: Sridhar Swamy <srid...@cloudera.com>
AuthorDate: Fri Mar 8 15:35:49 2019 -0800

    ATLAS-3069: avoid repeated warnings of missing relationship-def
    
    Signed-off-by: Madhan Neethiraj <mad...@apache.org>
---
 .../java/org/apache/atlas/type/AtlasEntityType.java |  3 +--
 .../org/apache/atlas/type/AtlasTypeRegistry.java    | 21 +++++++++++++++++----
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java 
b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
index b5360c1..87a327a 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
@@ -182,8 +182,7 @@ public class AtlasEntityType extends AtlasStructType {
 
             // validate if RelationshipDefs is defined for all entityDefs
             if (attributeEntityType != null && 
!hasRelationshipAttribute(attributeName)) {
-                LOG.warn("No RelationshipDef defined between {} and {} on 
attribute: {}.{}", getTypeName(),
-                         attributeEntityType.getTypeName(), getTypeName(), 
attributeName);
+                typeRegistry.reportMissingRelationshipDef(getTypeName(), 
attributeEntityType.getTypeName(), attributeName);
             }
         }
 
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java 
b/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
index 21f9429..db63ed1 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
@@ -56,16 +56,20 @@ public class AtlasTypeRegistry {
 
     protected       RegistryData                   registryData;
     private   final TypeRegistryUpdateSynchronizer updateSynchronizer;
+    private   final Set<String>                    missingRelationshipDefs;
+
 
     public AtlasTypeRegistry() {
-        registryData       = new RegistryData();
-        updateSynchronizer = new TypeRegistryUpdateSynchronizer(this);
+        registryData            = new RegistryData();
+        updateSynchronizer      = new TypeRegistryUpdateSynchronizer(this);
+        missingRelationshipDefs = new HashSet<>();
     }
 
     // used only by AtlasTransientTypeRegistry
     protected AtlasTypeRegistry(AtlasTypeRegistry other) {
-        registryData       = new RegistryData();
-        updateSynchronizer = other.updateSynchronizer;
+        registryData            = new RegistryData();
+        updateSynchronizer      = other.updateSynchronizer;
+        missingRelationshipDefs = other.missingRelationshipDefs;
     }
 
     public Collection<String> getAllTypeNames() { return 
registryData.allTypes.getAllTypeNames(); }
@@ -224,6 +228,15 @@ public class AtlasTypeRegistry {
         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 {
         final TypeCache                                                       
allTypes;

Reply via email to