Commit a5d52418 by Sarath Subramanian

ATLAS-2114: Regression : Type Update using V1 APIs

parent 7eff37a6
......@@ -166,7 +166,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
}
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);
......@@ -233,7 +233,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
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())) {
......@@ -244,7 +244,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
continue;
}
if (updateTypeAttributes(oldStructDef, newStructDef)) {
if (updateTypeAttributes(oldStructDef, newStructDef, checkTypeVersion)) {
typesToUpdate.getStructDefs().add(newStructDef);
}
}
......@@ -258,7 +258,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
continue;
}
if (updateTypeAttributes(oldClassifDef, newClassifDef)) {
if (updateTypeAttributes(oldClassifDef, newClassifDef, checkTypeVersion)) {
typesToUpdate.getClassificationDefs().add(newClassifDef);
}
}
......@@ -272,7 +272,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
continue;
}
if (updateTypeAttributes(oldEntityDef, newEntityDef)) {
if (updateTypeAttributes(oldEntityDef, newEntityDef, checkTypeVersion)) {
typesToUpdate.getEntityDefs().add(newEntityDef);
}
}
......@@ -286,7 +286,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
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())) {
......@@ -308,7 +308,7 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
continue;
}
if (updateTypeAttributes(oldRelationshipDef, relationshipDef)) {
if (updateTypeAttributes(oldRelationshipDef, relationshipDef, checkTypeVersion)) {
typesToUpdate.getRelationshipDefs().add(relationshipDef);
}
}
......@@ -339,8 +339,8 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
LOG.info("<== AtlasTypeDefStoreInitializer.instanceIsPassive()");
}
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
......@@ -356,11 +356,17 @@ public class AtlasTypeDefStoreInitializer implements ActiveStateChangeHandler {
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) {
......
......@@ -348,7 +348,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
@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);
}
......
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