atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sar...@apache.org
Subject atlas git commit: ATLAS-2114: Regression : Type Update using V1 APIs
Date Thu, 07 Sep 2017 00:52:33 GMT
Repository: atlas
Updated Branches:
  refs/heads/branch-0.8 7780b520a -> f52ad35dd


ATLAS-2114: Regression : Type Update using V1 APIs

(cherry picked from commit a5d52418d26be3de93f95f8811b9a73a74623b1e)


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

Branch: refs/heads/branch-0.8
Commit: f52ad35dd1fb6707c6b73bbfeccd8a8fcbf3ae7d
Parents: 7780b52
Author: Sarath Subramanian <ssubramanian@hortonworks.com>
Authored: Wed Sep 6 17:28:37 2017 -0700
Committer: Sarath Subramanian <ssubramanian@hortonworks.com>
Committed: Wed Sep 6 17:50:49 2017 -0700

----------------------------------------------------------------------
 .../bootstrap/AtlasTypeDefStoreInitializer.java | 30 ++++++++++++--------
 .../store/graph/AtlasTypeDefGraphStore.java     |  2 +-
 2 files changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/f52ad35d/repository/src/main/java/org/apache/atlas/repository/store/bootstrap/AtlasTypeDefStoreInitializer.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/bootstrap/AtlasTypeDefStoreInitializer.java
b/repository/src/main/java/org/apache/atlas/repository/store/bootstrap/AtlasTypeDefStoreInitializer.java
index 4530f51..3cb0f7e 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/bootstrap/AtlasTypeDefStoreInitializer.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/bootstrap/AtlasTypeDefStoreInitializer.java
@@ -111,7 +111,7 @@ public class AtlasTypeDefStoreInitializer {
                 }
 
                 AtlasTypesDef typesToCreate = getTypesToCreate(typesDef, atlasTypeRegistry);
-                AtlasTypesDef typesToUpdate = getTypesToUpdate(typesDef, atlasTypeRegistry);
+                AtlasTypesDef typesToUpdate = getTypesToUpdate(typesDef, atlasTypeRegistry,
true);
 
                 if (!typesToCreate.isEmpty() || !typesToUpdate.isEmpty()) {
                     atlasTypeDefStore.createUpdateTypesDef(typesToCreate, typesToUpdate);
@@ -167,7 +167,7 @@ public class AtlasTypeDefStoreInitializer {
         return typesToCreate;
     }
 
-    public static AtlasTypesDef getTypesToUpdate(AtlasTypesDef typesDef, AtlasTypeRegistry
typeRegistry) {
+    public static AtlasTypesDef getTypesToUpdate(AtlasTypesDef typesDef, AtlasTypeRegistry
typeRegistry, boolean checkTypeVersion) {
         AtlasTypesDef typesToUpdate = new AtlasTypesDef();
 
         if (CollectionUtils.isNotEmpty(typesDef.getStructDefs())) {
@@ -178,7 +178,7 @@ public class AtlasTypeDefStoreInitializer {
                     continue;
                 }
 
-                if (updateTypeAttributes(oldStructDef, newStructDef)) {
+                if (updateTypeAttributes(oldStructDef, newStructDef, checkTypeVersion)) {
                     typesToUpdate.getStructDefs().add(newStructDef);
                 }
             }
@@ -192,7 +192,7 @@ public class AtlasTypeDefStoreInitializer {
                     continue;
                 }
 
-                if (updateTypeAttributes(oldClassifDef, newClassifDef)) {
+                if (updateTypeAttributes(oldClassifDef, newClassifDef, checkTypeVersion))
{
                     typesToUpdate.getClassificationDefs().add(newClassifDef);
                 }
             }
@@ -206,7 +206,7 @@ public class AtlasTypeDefStoreInitializer {
                     continue;
                 }
 
-                if (updateTypeAttributes(oldEntityDef, newEntityDef)) {
+                if (updateTypeAttributes(oldEntityDef, newEntityDef, checkTypeVersion)) {
                     typesToUpdate.getEntityDefs().add(newEntityDef);
                 }
             }
@@ -220,7 +220,7 @@ public class AtlasTypeDefStoreInitializer {
                     continue;
                 }
 
-                if (isTypeUpdateApplicable(oldEnumDef, newEnumDef)) {
+                if (isTypeUpdateApplicable(oldEnumDef, newEnumDef, checkTypeVersion)) {
                     if (CollectionUtils.isNotEmpty(oldEnumDef.getElementDefs())) {
                         for (AtlasEnumElementDef oldEnumElem : oldEnumDef.getElementDefs())
{
                             if (!newEnumDef.hasElement(oldEnumElem.getValue())) {
@@ -237,8 +237,8 @@ public class AtlasTypeDefStoreInitializer {
         return typesToUpdate;
     }
 
-    private static boolean updateTypeAttributes(AtlasStructDef oldStructDef, AtlasStructDef
newStructDef) {
-        boolean ret = isTypeUpdateApplicable(oldStructDef, newStructDef);
+    private static boolean updateTypeAttributes(AtlasStructDef oldStructDef, AtlasStructDef
newStructDef, boolean checkTypeVersion) {
+        boolean ret = isTypeUpdateApplicable(oldStructDef, newStructDef, checkTypeVersion);
 
         if (ret) {
             // make sure that all attributes in oldDef are in newDef as well
@@ -254,11 +254,17 @@ public class AtlasTypeDefStoreInitializer {
         return ret;
     }
 
-    private static boolean isTypeUpdateApplicable(AtlasBaseTypeDef oldTypeDef, AtlasBaseTypeDef
newTypeDef) {
-        String oldTypeVersion = oldTypeDef.getTypeVersion();
-        String newTypeVersion = newTypeDef.getTypeVersion();
+    private static boolean isTypeUpdateApplicable(AtlasBaseTypeDef oldTypeDef, AtlasBaseTypeDef
newTypeDef, boolean checkVersion) {
+        boolean ret = true;
 
-        return ObjectUtils.compare(newTypeVersion, oldTypeVersion) > 0;
+        if (checkVersion) {
+            String oldTypeVersion = oldTypeDef.getTypeVersion();
+            String newTypeVersion = newTypeDef.getTypeVersion();
+
+            ret = ObjectUtils.compare(newTypeVersion, oldTypeVersion) > 0;
+        }
+
+        return ret;
     }
 
     private void applyTypePatches(String typesDirName) {

http://git-wip-us.apache.org/repos/asf/atlas/blob/f52ad35d/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 1f6cf0b..8aafdf4 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
@@ -315,7 +315,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore,
Activ
     @GraphTransaction
     public AtlasTypesDef createUpdateTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException
{
         AtlasTypesDef typesToCreate = getTypesToCreate(typesDef, typeRegistry);
-        AtlasTypesDef typesToUpdate = getTypesToUpdate(typesDef, typeRegistry);
+        AtlasTypesDef typesToUpdate = getTypesToUpdate(typesDef, typeRegistry, false);
 
         return createUpdateTypesDef(typesToCreate, typesToUpdate);
     }


Mime
View raw message