You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2016/10/19 01:34:05 UTC

[1/2] incubator-atlas git commit: ATLAS-1230: updated AtlasTypeRegistry to support batch, atomic type updates

Repository: incubator-atlas
Updated Branches:
  refs/heads/master 4d9cf4564 -> eb6e656be


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/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 14cc7c4..12047bf 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
@@ -20,7 +20,6 @@ package org.apache.atlas.repository.store.graph;
 import org.apache.atlas.GraphTransaction;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.SearchFilter;
-import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
 import org.apache.atlas.model.typedef.AtlasClassificationDef;
 import org.apache.atlas.model.typedef.AtlasClassificationDef.AtlasClassificationDefs;
 import org.apache.atlas.model.typedef.AtlasEntityDef;
@@ -33,7 +32,7 @@ import org.apache.atlas.model.typedef.AtlasTypesDef;
 import org.apache.atlas.repository.util.FilterUtil;
 import org.apache.atlas.store.AtlasTypeDefStore;
 import org.apache.atlas.type.AtlasTypeRegistry;
-import org.apache.atlas.util.TypeDefSorter;
+import org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.Predicate;
 import org.slf4j.Logger;
@@ -41,7 +40,6 @@ import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 
 
@@ -52,60 +50,58 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
 
     private static final Logger LOG = LoggerFactory.getLogger(AtlasTypeDefGraphStore.class);
 
-    private AtlasTypeRegistry           typeRegistry;
-    private AtlasEnumDefStore           enumDefStore;
-    private AtlasStructDefStore         structDefStore;
-    private AtlasClassificationDefStore classificationDefStore;
-    private AtlasEntityDefStore         entityDefStore;
+    private final AtlasTypeRegistry typeRegistry;
 
-    protected AtlasTypeDefGraphStore() {
+    protected AtlasTypeDefGraphStore(AtlasTypeRegistry typeRegistry) {
+        this.typeRegistry = typeRegistry;
     }
 
-    protected void init(AtlasEnumDefStore           enumDefStore,
-                        AtlasStructDefStore         structDefStore,
-                        AtlasClassificationDefStore classificationDefStore,
-                        AtlasEntityDefStore         entityDefStore) throws AtlasBaseException {
-        AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry();
+    protected abstract AtlasEnumDefStore getEnumDefStore(AtlasTypeRegistry typeRegistry);
 
-        typeRegistry.addTypesWithNoRefResolve(enumDefStore.getAll());
-        typeRegistry.addTypesWithNoRefResolve(structDefStore.getAll());
-        typeRegistry.addTypesWithNoRefResolve(classificationDefStore.getAll());
-        typeRegistry.addTypesWithNoRefResolve(entityDefStore.getAll());
+    protected abstract AtlasStructDefStore getStructDefStore(AtlasTypeRegistry typeRegistry);
 
-        typeRegistry.resolveReferences();
+    protected abstract AtlasClassificationDefStore getClassificationDefStore(AtlasTypeRegistry typeRegistry);
 
-        this.enumDefStore           = enumDefStore;
-        this.structDefStore         = structDefStore;
-        this.classificationDefStore = classificationDefStore;
-        this.entityDefStore         = entityDefStore;
-        this.typeRegistry           = typeRegistry;
-    }
-
-    public AtlasTypeRegistry getTypeRegistry() {
-        return typeRegistry;
-    }
+    protected abstract AtlasEntityDefStore getEntityDefStore(AtlasTypeRegistry typeRegistry);
 
     @Override
     public void init() throws AtlasBaseException {
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        AtlasTypesDef typesDef = new AtlasTypesDef(getEnumDefStore(ttr).getAll(),
+                                                   getStructDefStore(ttr).getAll(),
+                                                   getClassificationDefStore(ttr).getAll(),
+                                                   getEntityDefStore(ttr).getAll());
 
+        ttr.addTypes(typesDef);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
     }
 
     @Override
     @GraphTransaction
     public AtlasEnumDef createEnumDef(AtlasEnumDef enumDef) throws AtlasBaseException {
-        AtlasEnumDef ret = enumDefStore.create(enumDef);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.addType(enumDef);
+
+        AtlasEnumDef ret = getEnumDefStore(ttr).create(enumDef);
 
-        typeRegistry.addType(ret);
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
 
     @Override
     @GraphTransaction
-    public List<AtlasEnumDef> createEnumDefs(List<AtlasEnumDef> atlasEnumDefs) throws AtlasBaseException {
-        List<AtlasEnumDef> ret = enumDefStore.create(atlasEnumDefs);
+    public List<AtlasEnumDef> createEnumDefs(List<AtlasEnumDef> enumDefs) throws AtlasBaseException {
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
 
-        typeRegistry.addTypes(ret);
+        ttr.addTypes(enumDefs);
+
+        List<AtlasEnumDef> ret = getEnumDefStore(ttr).create(enumDefs);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -143,9 +139,13 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public AtlasEnumDef updateEnumDefByName(String name, AtlasEnumDef enumDef) throws AtlasBaseException {
-        AtlasEnumDef ret = enumDefStore.updateByName(name, enumDef);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.updateTypeByName(name, enumDef);
+
+        AtlasEnumDef ret = getEnumDefStore(ttr).updateByName(name, enumDef);
 
-        typeRegistry.updateTypeByName(name, ret);
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -153,9 +153,13 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public AtlasEnumDef updateEnumDefByGuid(String guid, AtlasEnumDef enumDef) throws AtlasBaseException {
-        AtlasEnumDef ret = enumDefStore.updateByGuid(guid, enumDef);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
 
-        typeRegistry.updateTypeByGuid(guid, ret);
+        ttr.updateTypeByGuid(guid, enumDef);
+
+        AtlasEnumDef ret = getEnumDefStore(ttr).updateByGuid(guid, enumDef);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -163,31 +167,43 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public void deleteEnumDefByName(String name) throws AtlasBaseException {
-        enumDefStore.deleteByName(name);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.removeTypeByName(name);
 
-        typeRegistry.removeTypeByName(name);
+        getEnumDefStore(ttr).deleteByName(name);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
     }
 
     @Override
     @GraphTransaction
     public void deleteEnumDefByGuid(String guid) throws AtlasBaseException {
-        enumDefStore.deleteByGuid(guid);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.removeTypeByGuid(guid);
 
-        typeRegistry.removeTypeByGuid(guid);
+        getEnumDefStore(ttr).deleteByGuid(guid);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
     }
 
     @Override
     @GraphTransaction
     public AtlasEnumDefs searchEnumDefs(SearchFilter filter) throws AtlasBaseException {
-        return enumDefStore.search(filter);
+        return getEnumDefStore(typeRegistry).search(filter);
     }
 
     @Override
     @GraphTransaction
     public AtlasStructDef createStructDef(AtlasStructDef structDef) throws AtlasBaseException {
-        AtlasStructDef ret = structDefStore.create(structDef);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.addType(structDef);
 
-        typeRegistry.addType(structDef);
+        AtlasStructDef ret = getStructDefStore(ttr).create(structDef);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -195,9 +211,13 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public List<AtlasStructDef> createStructDefs(List<AtlasStructDef> structDefs) throws AtlasBaseException {
-        List<AtlasStructDef> ret = structDefStore.create(structDefs);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.addTypes(structDefs);
+
+        List<AtlasStructDef> ret = getStructDefStore(ttr).create(structDefs);
 
-        typeRegistry.addTypes(ret);
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -235,9 +255,13 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public AtlasStructDef updateStructDefByName(String name, AtlasStructDef structDef) throws AtlasBaseException {
-        AtlasStructDef ret = structDefStore.updateByName(name, structDef);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
 
-        typeRegistry.updateTypeByName(name, ret);
+        ttr.updateTypeByName(name, structDef);
+
+        AtlasStructDef ret = getStructDefStore(ttr).updateByName(name, structDef);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -245,9 +269,13 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public AtlasStructDef updateStructDefByGuid(String guid, AtlasStructDef structDef) throws AtlasBaseException {
-        AtlasStructDef ret = structDefStore.updateByGuid(guid, structDef);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.updateTypeByGuid(guid, structDef);
+
+        AtlasStructDef ret = getStructDefStore(ttr).updateByGuid(guid, structDef);
 
-        typeRegistry.updateTypeByGuid(guid, ret);
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -255,32 +283,44 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public void deleteStructDefByName(String name) throws AtlasBaseException {
-        structDefStore.deleteByName(name);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
 
-        typeRegistry.removeTypeByName(name);
+        ttr.removeTypeByName(name);
+
+        getStructDefStore(ttr).deleteByName(name);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
     }
 
     @Override
     @GraphTransaction
     public void deleteStructDefByGuid(String guid) throws AtlasBaseException {
-        structDefStore.deleteByGuid(guid);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.removeTypeByGuid(guid);
 
-        typeRegistry.removeTypeByGuid(guid);
+        getStructDefStore(ttr).deleteByGuid(guid);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
     }
 
     @Override
     @GraphTransaction
     public AtlasStructDefs searchStructDefs(SearchFilter filter) throws AtlasBaseException {
-        return structDefStore.search(filter);
+        return getStructDefStore(typeRegistry).search(filter);
     }
 
     @Override
     @GraphTransaction
     public AtlasClassificationDef createClassificationDef(AtlasClassificationDef classificationDef)
         throws AtlasBaseException {
-        AtlasClassificationDef ret = classificationDefStore.create(classificationDef);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.addType(classificationDef);
 
-        typeRegistry.addType(classificationDef);
+        AtlasClassificationDef ret = getClassificationDefStore(ttr).create(classificationDef);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -289,9 +329,13 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @GraphTransaction
     public List<AtlasClassificationDef> createClassificationDefs(List<AtlasClassificationDef> classificationDefs)
         throws AtlasBaseException {
-        List<AtlasClassificationDef> ret = classificationDefStore.create(classificationDefs);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.addTypes(classificationDefs);
 
-        typeRegistry.addTypes(ret);
+        List<AtlasClassificationDef> ret = getClassificationDefStore(ttr).create(classificationDefs);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -330,9 +374,13 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @GraphTransaction
     public AtlasClassificationDef updateClassificationDefByName(String name, AtlasClassificationDef classificationDef)
         throws AtlasBaseException {
-        AtlasClassificationDef ret = classificationDefStore.updateByName(name, classificationDef);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.updateTypeByName(name, classificationDef);
+
+        AtlasClassificationDef ret = getClassificationDefStore(ttr).updateByName(name, classificationDef);
 
-        typeRegistry.updateTypeByName(name, ret);
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -341,9 +389,13 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @GraphTransaction
     public AtlasClassificationDef updateClassificationDefByGuid(String guid, AtlasClassificationDef classificationDef)
         throws AtlasBaseException {
-        AtlasClassificationDef ret = classificationDefStore.updateByGuid(guid, classificationDef);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
 
-        typeRegistry.updateTypeByGuid(guid, ret);
+        ttr.updateTypeByGuid(guid, classificationDef);
+
+        AtlasClassificationDef ret = getClassificationDefStore(ttr).updateByGuid(guid, classificationDef);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -351,31 +403,43 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public void deleteClassificationDefByName(String name) throws AtlasBaseException {
-        classificationDefStore.deleteByName(name);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.removeTypeByName(name);
+
+        getClassificationDefStore(ttr).deleteByName(name);
 
-        typeRegistry.removeTypeByName(name);
+        typeRegistry.commitTransientTypeRegistry(ttr);
     }
 
     @Override
     @GraphTransaction
     public void deleteClassificationDefByGuid(String guid) throws AtlasBaseException {
-        classificationDefStore.deleteByGuid(guid);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
 
-        typeRegistry.removeTypeByGuid(guid);
+        ttr.removeTypeByGuid(guid);
+
+        getClassificationDefStore(ttr).deleteByGuid(guid);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
     }
 
     @Override
     @GraphTransaction
     public AtlasClassificationDefs searchClassificationDefs(SearchFilter filter) throws AtlasBaseException {
-        return classificationDefStore.search(filter);
+        return getClassificationDefStore(typeRegistry).search(filter);
     }
 
     @Override
     @GraphTransaction
     public AtlasEntityDef createEntityDef(AtlasEntityDef entityDef) throws AtlasBaseException {
-        AtlasEntityDef ret = entityDefStore.create(entityDef);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.addType(entityDef);
 
-        typeRegistry.addType(ret);
+        AtlasEntityDef ret = getEntityDefStore(ttr).create(entityDef);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -383,9 +447,13 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public List<AtlasEntityDef> createEntityDefs(List<AtlasEntityDef> entityDefs) throws AtlasBaseException {
-        List<AtlasEntityDef> ret = entityDefStore.create(entityDefs);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.addTypes(entityDefs);
 
-        typeRegistry.addTypes(ret);
+        List<AtlasEntityDef> ret = getEntityDefStore(ttr).create(entityDefs);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -423,9 +491,13 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public AtlasEntityDef updateEntityDefByName(String name, AtlasEntityDef entityDef) throws AtlasBaseException {
-        AtlasEntityDef ret = entityDefStore.updateByName(name, entityDef);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.updateTypeByName(name, entityDef);
 
-        typeRegistry.updateTypeByName(name, ret);
+        AtlasEntityDef ret = getEntityDefStore(ttr).updateByName(name, entityDef);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -433,9 +505,13 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public AtlasEntityDef updateEntityDefByGuid(String guid, AtlasEntityDef entityDef) throws AtlasBaseException {
-        AtlasEntityDef ret = entityDefStore.updateByGuid(guid, entityDef);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.updateTypeByGuid(guid, entityDef);
+
+        AtlasEntityDef ret = getEntityDefStore(ttr).updateByGuid(guid, entityDef);
 
-        typeRegistry.updateTypeByGuid(guid, ret);
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         return ret;
     }
@@ -443,44 +519,50 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @Override
     @GraphTransaction
     public void deleteEntityDefByName(String name) throws AtlasBaseException {
-        entityDefStore.deleteByName(name);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
 
-        typeRegistry.removeTypeByName(name);
+        ttr.removeTypeByName(name);
+
+        getEntityDefStore(ttr).deleteByName(name);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
     }
 
     @Override
     @GraphTransaction
     public void deleteEntityDefByGuid(String guid) throws AtlasBaseException {
-        entityDefStore.deleteByGuid(guid);
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.removeTypeByGuid(guid);
 
-        typeRegistry.removeTypeByGuid(guid);
+        getEntityDefStore(ttr).deleteByGuid(guid);
+
+        typeRegistry.commitTransientTypeRegistry(ttr);
     }
 
     @Override
     @GraphTransaction
     public AtlasEntityDefs searchEntityDefs(SearchFilter filter) throws AtlasBaseException {
-        return entityDefStore.search(filter);
+        return getEntityDefStore(typeRegistry).search(filter);
     }
 
     @Override
     @GraphTransaction
     public AtlasTypesDef createTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException {
         LOG.info("Creating EnumDefs");
-        List<AtlasEnumDef>           enumDefs     = enumDefStore.create(typesDef.getEnumDefs());
-        List<AtlasStructDef>         structDefs   = structDefStore.create(typesDef.getStructDefs());
-        List<AtlasClassificationDef> classifiDefs = classificationDefStore.create(typesDef.getClassificationDefs());
-        List<AtlasEntityDef>         entityDefs   = entityDefStore.create(typesDef.getEntityDefs());
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
 
-        // typeRegistry should be updated only after resovleReferences() returns success; until then use a temp registry
-        typeRegistry.addTypes(enumDefs);
-        typeRegistry.addTypes(structDefs);
-        typeRegistry.addTypes(classifiDefs);
-        typeRegistry.addTypes(entityDefs);
+        ttr.addTypes(typesDef);
 
-        typeRegistry.resolveReferences();
+        List<AtlasEnumDef>           enumDefs     = getEnumDefStore(ttr).create(typesDef.getEnumDefs());
+        List<AtlasStructDef>         structDefs   = getStructDefStore(ttr).create(typesDef.getStructDefs());
+        List<AtlasClassificationDef> classifiDefs = getClassificationDefStore(ttr).create(typesDef.getClassificationDefs());
+        List<AtlasEntityDef>         entityDefs   = getEntityDefStore(ttr).create(typesDef.getEntityDefs());
 
         AtlasTypesDef ret = new AtlasTypesDef(enumDefs, structDefs, classifiDefs, entityDefs);
 
+        typeRegistry.commitTransientTypeRegistry(ttr);
+
         return ret;
     }
 
@@ -488,18 +570,16 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
     @GraphTransaction
     public AtlasTypesDef updateTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException {
         LOG.info("Updating EnumDefs");
-        List<AtlasEnumDef>           enumDefs     = enumDefStore.update(typesDef.getEnumDefs());
-        List<AtlasStructDef>         structDefs   = structDefStore.update(typesDef.getStructDefs());
-        List<AtlasClassificationDef> classifiDefs = classificationDefStore.update(typesDef.getClassificationDefs());
-        List<AtlasEntityDef>         entityDefs   = entityDefStore.update(typesDef.getEntityDefs());
+        AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+        ttr.updateTypes(typesDef);
 
-        // typeRegistry should be updated only after resovleReferences() returns success; until then use a temp registry
-        typeRegistry.updateTypes(enumDefs);
-        typeRegistry.updateTypes(structDefs);
-        typeRegistry.updateTypes(classifiDefs);
-        typeRegistry.updateTypes(entityDefs);
+        List<AtlasEnumDef>           enumDefs     = getEnumDefStore(ttr).update(typesDef.getEnumDefs());
+        List<AtlasStructDef>         structDefs   = getStructDefStore(ttr).update(typesDef.getStructDefs());
+        List<AtlasClassificationDef> classifiDefs = getClassificationDefStore(ttr).update(typesDef.getClassificationDefs());
+        List<AtlasEntityDef>         entityDefs   = getEntityDefStore(ttr).update(typesDef.getEntityDefs());
 
-        typeRegistry.resolveReferences();
+        typeRegistry.commitTransientTypeRegistry(ttr);
 
         AtlasTypesDef ret = new AtlasTypesDef(enumDefs, structDefs, classifiDefs, entityDefs);
 
@@ -513,7 +593,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
         AtlasTypesDef typesDef = new AtlasTypesDef();
         Predicate searchPredicates = FilterUtil.getPredicateFromSearchFilter(searchFilter);
         try {
-            List<AtlasEnumDef> enumDefs = enumDefStore.getAll();
+            List<AtlasEnumDef> enumDefs = getEnumDefStore(typeRegistry).getAll();
             CollectionUtils.filter(enumDefs, searchPredicates);
             typesDef.setEnumDefs(enumDefs);
         } catch (AtlasBaseException ex) {
@@ -521,7 +601,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
         }
 
         try {
-            List<AtlasStructDef> structDefs = structDefStore.getAll();
+            List<AtlasStructDef> structDefs = getStructDefStore(typeRegistry).getAll();
             CollectionUtils.filter(structDefs, searchPredicates);
             typesDef.setStructDefs(structDefs);
         } catch (AtlasBaseException ex) {
@@ -529,7 +609,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
         }
 
         try {
-            List<AtlasClassificationDef> classificationDefs = classificationDefStore.getAll();
+            List<AtlasClassificationDef> classificationDefs = getClassificationDefStore(typeRegistry).getAll();
             CollectionUtils.filter(classificationDefs, searchPredicates);
             typesDef.setClassificationDefs(classificationDefs);
         } catch (AtlasBaseException ex) {
@@ -537,7 +617,7 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
         }
 
         try {
-            List<AtlasEntityDef> entityDefs = entityDefStore.getAll();
+            List<AtlasEntityDef> entityDefs = getEntityDefStore(typeRegistry).getAll();
             CollectionUtils.filter(entityDefs, searchPredicates);
             typesDef.setEntityDefs(entityDefs);
         } catch (AtlasBaseException ex) {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasAbstractDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasAbstractDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasAbstractDefStoreV1.java
new file mode 100644
index 0000000..8144ddf
--- /dev/null
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasAbstractDefStoreV1.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.repository.store.graph.v1;
+
+import org.apache.atlas.type.AtlasTypeRegistry;
+
+/**
+ * Abstract typedef-store for v1 format.
+ */
+public abstract class AtlasAbstractDefStoreV1 {
+    protected final AtlasTypeDefGraphStoreV1 typeDefStore;
+    protected final AtlasTypeRegistry        typeRegistry;
+
+    public AtlasAbstractDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) {
+        this.typeDefStore = typeDefStore;
+        this.typeRegistry = typeRegistry;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
index bdd65d3..7b6e08a 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasClassificationDefStoreV1.java
@@ -26,6 +26,9 @@ import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.graphdb.AtlasVertex;
 import org.apache.atlas.repository.store.graph.AtlasClassificationDefStore;
 import org.apache.atlas.repository.util.FilterUtil;
+import org.apache.atlas.type.AtlasClassificationType;
+import org.apache.atlas.type.AtlasType;
+import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
 import org.apache.commons.collections.CollectionUtils;
 import org.slf4j.Logger;
@@ -33,21 +36,16 @@ import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 
 /**
  * ClassificationDef store in v1 format.
  */
-public class AtlasClassificationDefStoreV1 implements AtlasClassificationDefStore {
+public class AtlasClassificationDefStoreV1 extends AtlasAbstractDefStoreV1 implements AtlasClassificationDefStore {
     private static final Logger LOG = LoggerFactory.getLogger(AtlasClassificationDefStoreV1.class);
 
-    private final AtlasTypeDefGraphStoreV1 typeDefStore;
-
-    public AtlasClassificationDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore) {
-        super();
-
-        this.typeDefStore = typeDefStore;
+    public AtlasClassificationDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) {
+        super(typeDefStore, typeRegistry);
     }
 
     @Override
@@ -80,20 +78,17 @@ public class AtlasClassificationDefStoreV1 implements AtlasClassificationDefStor
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasClassificationDefStoreV1.create({})", classificationDefs);
         }
-        List<AtlasClassificationDef> classificationDefList = new LinkedList<>();
-        for (AtlasClassificationDef structDef : classificationDefs) {
-            try {
-                AtlasClassificationDef atlasClassificationDef = create(structDef);
-                classificationDefList.add(atlasClassificationDef);
-            } catch (AtlasBaseException baseException) {
-                LOG.error("Failed to create {}", structDef);
-                LOG.error("Exception: {}", baseException);
-            }
+
+        List<AtlasClassificationDef> ret = new ArrayList<>();
+
+        for (AtlasClassificationDef classificationDef : classificationDefs) {
+            ret.add(create(classificationDef));
         }
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasClassificationDefStoreV1.create({}, {})", classificationDefs, classificationDefList);
+            LOG.debug("<== AtlasClassificationDefStoreV1.create({}, {})", classificationDefs, ret);
         }
-        return classificationDefList;
+        return ret;
     }
 
     @Override
@@ -102,17 +97,17 @@ public class AtlasClassificationDefStoreV1 implements AtlasClassificationDefStor
             LOG.debug("==> AtlasClassificationDefStoreV1.getAll()");
         }
 
-        List<AtlasClassificationDef> classificationDefs = new LinkedList<>();
-        Iterator<AtlasVertex> verticesByCategory = typeDefStore.findTypeVerticesByCategory(TypeCategory.TRAIT);
-        while (verticesByCategory.hasNext()) {
-            AtlasClassificationDef classificationDef = toClassificationDef(verticesByCategory.next());
-            classificationDefs.add(classificationDef);
+        List<AtlasClassificationDef> ret = new ArrayList<>();
+
+        Iterator<AtlasVertex> vertices = typeDefStore.findTypeVerticesByCategory(TypeCategory.TRAIT);
+        while (vertices.hasNext()) {
+            ret.add(toClassificationDef(vertices.next()));
         }
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasClassificationDefStoreV1.getAll()");
+            LOG.debug("<== AtlasClassificationDefStoreV1.getAll(): count={}", ret.size());
         }
-        return classificationDefs;
+        return ret;
     }
 
     @Override
@@ -211,22 +206,17 @@ public class AtlasClassificationDefStoreV1 implements AtlasClassificationDefStor
             LOG.debug("==> AtlasClassificationDefStoreV1.update({})", classificationDefs);
         }
 
-        List<AtlasClassificationDef> updatedClassificationDefs = new ArrayList<>();
+        List<AtlasClassificationDef> ret = new ArrayList<>();
 
         for (AtlasClassificationDef classificationDef : classificationDefs) {
-            try {
-                AtlasClassificationDef updatedDef = updateByName(classificationDef.getName(), classificationDef);
-                updatedClassificationDefs.add(updatedDef);
-            } catch (AtlasBaseException ex) {
-                LOG.error("Failed to update {}", classificationDef);
-            }
+            ret.add(updateByName(classificationDef.getName(), classificationDef));
         }
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasClassificationDefStoreV1.update({}): {}", classificationDefs, updatedClassificationDefs);
+            LOG.debug("<== AtlasClassificationDefStoreV1.update({}): {}", classificationDefs, ret);
         }
 
-        return updatedClassificationDefs;
+        return ret;
     }
 
     @Override
@@ -255,11 +245,7 @@ public class AtlasClassificationDefStoreV1 implements AtlasClassificationDefStor
         }
 
         for (String name : names) {
-            try {
-                deleteByName(name);
-            } catch (AtlasBaseException ex) {
-                LOG.error("Failed to delete {}", name);
-            }
+            deleteByName(name);
         }
 
         if (LOG.isDebugEnabled()) {
@@ -293,11 +279,7 @@ public class AtlasClassificationDefStoreV1 implements AtlasClassificationDefStor
         }
 
         for (String guid : guids) {
-            try {
-                deleteByGuid(guid);
-            } catch (AtlasBaseException ex) {
-                LOG.error("Failed to delete {}", guid);
-            }
+            deleteByGuid(guid);
         }
 
         if (LOG.isDebugEnabled()) {
@@ -313,22 +295,18 @@ public class AtlasClassificationDefStoreV1 implements AtlasClassificationDefStor
         }
 
         List<AtlasClassificationDef> classificationDefs = new ArrayList<AtlasClassificationDef>();
-
-        Iterator<AtlasVertex> vertices = typeDefStore.findTypeVerticesByCategory(TypeCategory.TRAIT);
+        Iterator<AtlasVertex>        vertices           = typeDefStore.findTypeVerticesByCategory(TypeCategory.TRAIT);
 
         while(vertices.hasNext()) {
-            AtlasVertex       vertex  = vertices.next();
+            AtlasVertex            vertex            = vertices.next();
             AtlasClassificationDef classificationDef = toClassificationDef(vertex);
 
             if (classificationDef != null) {
-                classificationDefs.add(classificationDef); // TODO: add only if this passes filter
+                classificationDefs.add(classificationDef);
             }
         }
 
-        if (CollectionUtils.isNotEmpty(classificationDefs)) {
-            CollectionUtils.filter(classificationDefs, FilterUtil.getPredicateFromSearchFilter(filter));
-        }
-
+        CollectionUtils.filter(classificationDefs, FilterUtil.getPredicateFromSearchFilter(filter));
 
         AtlasClassificationDefs ret = new AtlasClassificationDefs(classificationDefs);
 
@@ -339,8 +317,15 @@ public class AtlasClassificationDefStoreV1 implements AtlasClassificationDefStor
         return ret;
     }
 
-    private void toVertex(AtlasClassificationDef classificationDef, AtlasVertex vertex) {
-        AtlasStructDefStoreV1.toVertex(classificationDef, vertex, typeDefStore);
+    private void toVertex(AtlasClassificationDef classificationDef, AtlasVertex vertex) throws AtlasBaseException {
+        AtlasType type = typeRegistry.getType(classificationDef.getName());
+
+        if (type.getTypeCategory() != AtlasType.TypeCategory.CLASSIFICATION) {
+            throw new AtlasBaseException(classificationDef.getName() + ": not a classification type");
+        }
+
+        AtlasStructDefStoreV1.toVertex(classificationDef, (AtlasClassificationType)type,
+                                       vertex, typeDefStore, typeRegistry);
 
         typeDefStore.createSuperTypeEdges(vertex, classificationDef.getSuperTypes());
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
index 191ca56..308a529 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityDefStoreV1.java
@@ -21,11 +21,13 @@ import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.SearchFilter;
 import org.apache.atlas.model.typedef.AtlasEntityDef;
 import org.apache.atlas.model.typedef.AtlasEntityDef.AtlasEntityDefs;
-import org.apache.atlas.model.typedef.AtlasStructDef;
 import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.graphdb.AtlasVertex;
 import org.apache.atlas.repository.store.graph.AtlasEntityDefStore;
 import org.apache.atlas.repository.util.FilterUtil;
+import org.apache.atlas.type.AtlasEntityType;
+import org.apache.atlas.type.AtlasType;
+import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
 import org.apache.commons.collections.CollectionUtils;
 import org.slf4j.Logger;
@@ -33,21 +35,16 @@ import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 
 /**
  * EntityDef store in v1 format.
  */
-public class AtlasEntityDefStoreV1 implements AtlasEntityDefStore {
+public class AtlasEntityDefStoreV1 extends AtlasAbstractDefStoreV1 implements AtlasEntityDefStore {
     private static final Logger LOG = LoggerFactory.getLogger(AtlasEntityDefStoreV1.class);
 
-    private final AtlasTypeDefGraphStoreV1 typeDefStore;
-
-    public AtlasEntityDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore) {
-        super();
-
-        this.typeDefStore = typeDefStore;
+    public AtlasEntityDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) {
+        super(typeDefStore, typeRegistry);
     }
 
     @Override
@@ -80,20 +77,15 @@ public class AtlasEntityDefStoreV1 implements AtlasEntityDefStore {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasEntityDefStoreV1.create({})", entityDefs);
         }
-        List<AtlasEntityDef> entityDefList = new LinkedList<>();
-        for (AtlasEntityDef structDef : entityDefs) {
-            try {
-                AtlasEntityDef atlasEntityDef = create(structDef);
-                entityDefList.add(atlasEntityDef);
-            } catch (AtlasBaseException baseException) {
-                LOG.error("Failed to create {}", structDef);
-                LOG.error("Exception: {}", baseException);
-            }
+        List<AtlasEntityDef> ret = new ArrayList<>();
+
+        for (AtlasEntityDef entityDef : entityDefs) {
+            ret.add(create(entityDef));
         }
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEntityDefStoreV1.create({}, {})", entityDefs, entityDefList);
+            LOG.debug("<== AtlasEntityDefStoreV1.create({}, {})", entityDefs, ret);
         }
-        return entityDefList;
+        return ret;
     }
 
     @Override
@@ -102,17 +94,18 @@ public class AtlasEntityDefStoreV1 implements AtlasEntityDefStore {
             LOG.debug("==> AtlasEntityDefStoreV1.getAll()");
         }
 
-        List<AtlasEntityDef> entityDefs = new LinkedList<>();
-        Iterator<AtlasVertex> verticesByCategory = typeDefStore.findTypeVerticesByCategory(TypeCategory.CLASS);
-        while (verticesByCategory.hasNext()) {
-            AtlasEntityDef atlasEntityDef = toEntityDef(verticesByCategory.next());
-            entityDefs.add(atlasEntityDef);
+        List<AtlasEntityDef>  ret      = new ArrayList<>();
+        Iterator<AtlasVertex> vertices = typeDefStore.findTypeVerticesByCategory(TypeCategory.CLASS);
+
+        while (vertices.hasNext()) {
+            ret.add(toEntityDef(vertices.next()));
         }
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEntityDefStoreV1.getAll()");
+            LOG.debug("<== AtlasEntityDefStoreV1.getAll(): count={}", ret.size());
         }
-        return entityDefs;
+
+        return ret;
     }
 
     @Override
@@ -211,22 +204,17 @@ public class AtlasEntityDefStoreV1 implements AtlasEntityDefStore {
             LOG.debug("==> AtlasEntityDefStoreV1.update({})", entityDefs);
         }
 
-        List<AtlasEntityDef> updatedEntityDefs = new ArrayList<>();
+        List<AtlasEntityDef> ret = new ArrayList<>();
 
         for (AtlasEntityDef entityDef : entityDefs) {
-            try {
-                AtlasEntityDef atlasEntityDef = updateByName(entityDef.getName(), entityDef);
-                updatedEntityDefs.add(atlasEntityDef);
-            } catch (AtlasBaseException ex) {
-                LOG.error("Failed to update {}", entityDef);
-            }
+            ret.add(updateByName(entityDef.getName(), entityDef));
         }
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEntityDefStoreV1.update({}): {}", entityDefs, updatedEntityDefs);
+            LOG.debug("<== AtlasEntityDefStoreV1.update({}): {}", entityDefs, ret);
         }
 
-        return updatedEntityDefs;
+        return ret;
     }
 
     @Override
@@ -254,12 +242,8 @@ public class AtlasEntityDefStoreV1 implements AtlasEntityDefStore {
             LOG.debug("==> AtlasEntityDefStoreV1.deleteByNames({})", names);
         }
 
-        List<AtlasStructDef> updatedDefs = new ArrayList<>();
-
         for (String name : names) {
-            try {
-                deleteByName(name);
-            } catch (AtlasBaseException ex) {}
+            deleteByName(name);
         }
 
         if (LOG.isDebugEnabled()) {
@@ -292,12 +276,8 @@ public class AtlasEntityDefStoreV1 implements AtlasEntityDefStore {
             LOG.debug("==> AtlasEntityDefStoreV1.deleteByGuids({})", guids);
         }
 
-        List<AtlasStructDef> updatedDefs = new ArrayList<>();
-
         for (String guid : guids) {
-            try {
-                deleteByGuid(guid);
-            } catch (AtlasBaseException ex) {}
+            deleteByGuid(guid);
         }
 
         if (LOG.isDebugEnabled()) {
@@ -311,12 +291,11 @@ public class AtlasEntityDefStoreV1 implements AtlasEntityDefStore {
             LOG.debug("==> AtlasEntityDefStoreV1.search({})", filter);
         }
 
-        List<AtlasEntityDef> entityDefs = new ArrayList<AtlasEntityDef>();
-
-        Iterator<AtlasVertex> vertices = typeDefStore.findTypeVerticesByCategory(TypeCategory.CLASS);
+        List<AtlasEntityDef>  entityDefs = new ArrayList<AtlasEntityDef>();
+        Iterator<AtlasVertex> vertices   = typeDefStore.findTypeVerticesByCategory(TypeCategory.CLASS);
 
         while(vertices.hasNext()) {
-            AtlasVertex       vertex  = vertices.next();
+            AtlasVertex    vertex    = vertices.next();
             AtlasEntityDef entityDef = toEntityDef(vertex);
 
             if (entityDef != null) {
@@ -324,10 +303,7 @@ public class AtlasEntityDefStoreV1 implements AtlasEntityDefStore {
             }
         }
 
-        if (CollectionUtils.isNotEmpty(entityDefs)) {
-            CollectionUtils.filter(entityDefs, FilterUtil.getPredicateFromSearchFilter(filter));
-        }
-
+        CollectionUtils.filter(entityDefs, FilterUtil.getPredicateFromSearchFilter(filter));
 
         AtlasEntityDefs ret = new AtlasEntityDefs(entityDefs);
 
@@ -338,8 +314,14 @@ public class AtlasEntityDefStoreV1 implements AtlasEntityDefStore {
         return ret;
     }
 
-    private void toVertex(AtlasEntityDef entityDef, AtlasVertex vertex) {
-        AtlasStructDefStoreV1.toVertex(entityDef, vertex, typeDefStore);
+    private void toVertex(AtlasEntityDef entityDef, AtlasVertex vertex) throws AtlasBaseException {
+        AtlasType type = typeRegistry.getType(entityDef.getName());
+
+        if (type.getTypeCategory() != AtlasType.TypeCategory.ENTITY) {
+            throw new AtlasBaseException(entityDef.getName() + ": not a entity type");
+        }
+
+        AtlasStructDefStoreV1.toVertex(entityDef, (AtlasEntityType)type, vertex, typeDefStore, typeRegistry);
 
         typeDefStore.createSuperTypeEdges(vertex, entityDef.getSuperTypes());
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
index 67ff1a0..5c55d42 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEnumDefStoreV1.java
@@ -26,6 +26,7 @@ import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.graphdb.AtlasVertex;
 import org.apache.atlas.repository.store.graph.AtlasEnumDefStore;
 import org.apache.atlas.repository.util.FilterUtil;
+import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -34,21 +35,16 @@ import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 
 /**
  * EnumDef store in v1 format.
  */
-public class AtlasEnumDefStoreV1 implements AtlasEnumDefStore {
+public class AtlasEnumDefStoreV1 extends AtlasAbstractDefStoreV1 implements AtlasEnumDefStore {
     private static final Logger LOG = LoggerFactory.getLogger(AtlasEnumDefStoreV1.class);
 
-    private final AtlasTypeDefGraphStoreV1 typeDefStore;
-
-    public AtlasEnumDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore) {
-        super();
-
-        this.typeDefStore = typeDefStore;
+    public AtlasEnumDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) {
+        super(typeDefStore, typeRegistry);
     }
 
     @Override
@@ -77,24 +73,22 @@ public class AtlasEnumDefStoreV1 implements AtlasEnumDefStore {
     }
 
     @Override
-    public List<AtlasEnumDef> create(List<AtlasEnumDef> atlasEnumDefs) throws AtlasBaseException {
+    public List<AtlasEnumDef> create(List<AtlasEnumDef> enumDefs) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasEnumDefStoreV1.create({})", atlasEnumDefs);
-        }
-        List<AtlasEnumDef> enumDefList = new LinkedList<>();
-        for (AtlasEnumDef enumDef : atlasEnumDefs) {
-            try {
-                AtlasEnumDef atlasEnumDef = create(enumDef);
-                enumDefList.add(atlasEnumDef);
-            } catch (AtlasBaseException baseException) {
-                LOG.error("Failed to create {}", enumDef);
-                LOG.error("Exception: {}", baseException);
-            }
+            LOG.debug("==> AtlasEnumDefStoreV1.create({})", enumDefs);
+        }
+
+        List<AtlasEnumDef> ret = new ArrayList<>();
+
+        for (AtlasEnumDef enumDef : enumDefs) {
+            ret.add(create(enumDef));
         }
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEnumDefStoreV1.create({}, {})", atlasEnumDefs, enumDefList);
+            LOG.debug("<== AtlasEnumDefStoreV1.create({}): {}", enumDefs, ret);
         }
-        return enumDefList;
+
+        return ret;
     }
 
     @Override
@@ -103,17 +97,18 @@ public class AtlasEnumDefStoreV1 implements AtlasEnumDefStore {
             LOG.debug("==> AtlasEnumDefStoreV1.getAll()");
         }
 
-        List<AtlasEnumDef> enumDefs = new LinkedList<>();
-        Iterator<AtlasVertex> verticesByCategory = typeDefStore.findTypeVerticesByCategory(TypeCategory.ENUM);
-        while (verticesByCategory.hasNext()) {
-            AtlasEnumDef enumDef = toEnumDef(verticesByCategory.next());
-            enumDefs.add(enumDef);
+        List<AtlasEnumDef> ret = new ArrayList<>();
+
+        Iterator<AtlasVertex> vertices = typeDefStore.findTypeVerticesByCategory(TypeCategory.ENUM);
+        while (vertices.hasNext()) {
+            ret.add(toEnumDef(vertices.next()));
         }
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEnumDefStoreV1.getAll()");
+            LOG.debug("<== AtlasEnumDefStoreV1.getAll(): count={}", ret.size());
         }
-        return enumDefs;
+
+        return ret;
     }
 
     @Override
@@ -212,22 +207,17 @@ public class AtlasEnumDefStoreV1 implements AtlasEnumDefStore {
             LOG.debug("==> AtlasEnumDefStoreV1.update({})", enumDefs);
         }
 
-        List<AtlasEnumDef> updatedEnumDefs = new ArrayList<>();
+        List<AtlasEnumDef> ret = new ArrayList<>();
 
         for (AtlasEnumDef enumDef : enumDefs) {
-            try {
-                AtlasEnumDef updatedDef = updateByName(enumDef.getName(), enumDef);
-                updatedEnumDefs.add(updatedDef);
-            } catch (AtlasBaseException ex) {
-                LOG.error("Failed to update {}", enumDef);
-            }
+            ret.add(updateByName(enumDef.getName(), enumDef));
         }
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasEnumDefStoreV1.update({}): {}", enumDefs, updatedEnumDefs);
+            LOG.debug("<== AtlasEnumDefStoreV1.update({}): {}", enumDefs, ret);
         }
 
-        return updatedEnumDefs;
+        return ret;
     }
 
     @Override
@@ -256,11 +246,7 @@ public class AtlasEnumDefStoreV1 implements AtlasEnumDefStore {
         }
 
         for (String name : names) {
-            try {
-                deleteByName(name);
-            } catch (AtlasBaseException ex) {
-                LOG.error("Failed to delete {}", name);
-            }
+            deleteByName(name);
         }
 
         if (LOG.isDebugEnabled()) {
@@ -294,11 +280,7 @@ public class AtlasEnumDefStoreV1 implements AtlasEnumDefStore {
         }
 
         for (String guid : guids) {
-            try {
-                deleteByGuid(guid);
-            } catch (AtlasBaseException ex) {
-                LOG.error("Failed to delete {}", guid);
-            }
+            deleteByGuid(guid);
         }
 
         if (LOG.isDebugEnabled()) {
@@ -312,12 +294,11 @@ public class AtlasEnumDefStoreV1 implements AtlasEnumDefStore {
             LOG.debug("==> AtlasEnumDefStoreV1.search({})", filter);
         }
 
-        List<AtlasEnumDef> enumDefs = new ArrayList<AtlasEnumDef>();
-
+        List<AtlasEnumDef>    enumDefs = new ArrayList<AtlasEnumDef>();
         Iterator<AtlasVertex> vertices = typeDefStore.findTypeVerticesByCategory(TypeCategory.ENUM);
 
         while(vertices.hasNext()) {
-            AtlasVertex       vertex  = vertices.next();
+            AtlasVertex  vertex  = vertices.next();
             AtlasEnumDef enumDef = toEnumDef(vertex);
 
             if (enumDef != null) {
@@ -325,9 +306,7 @@ public class AtlasEnumDefStoreV1 implements AtlasEnumDefStore {
             }
         }
 
-        if (CollectionUtils.isNotEmpty(enumDefs)) {
-            CollectionUtils.filter(enumDefs, FilterUtil.getPredicateFromSearchFilter(filter));
-        }
+        CollectionUtils.filter(enumDefs, FilterUtil.getPredicateFromSearchFilter(filter));
 
         AtlasEnumDefs ret = new AtlasEnumDefs(enumDefs);
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
index b26fc13..eeb08d0 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasStructDefStoreV1.java
@@ -41,6 +41,7 @@ import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.type.AtlasTypeUtil;
 import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.compress.archivers.dump.DumpArchiveEntry;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -48,7 +49,6 @@ import org.slf4j.LoggerFactory;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -56,15 +56,11 @@ import java.util.Set;
 /**
  * StructDef store in v1 format.
  */
-public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
+public class AtlasStructDefStoreV1 extends AtlasAbstractDefStoreV1 implements AtlasStructDefStore {
     private static final Logger LOG = LoggerFactory.getLogger(AtlasStructDefStoreV1.class);
 
-    private final AtlasTypeDefGraphStoreV1 typeDefStore;
-
-    public AtlasStructDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore) {
-        super();
-
-        this.typeDefStore = typeDefStore;
+    public AtlasStructDefStoreV1(AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) {
+        super(typeDefStore, typeRegistry);
     }
 
     @Override
@@ -79,9 +75,15 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
             throw new AtlasBaseException(structDef.getName() + ": type already exists");
         }
 
+        AtlasType type = typeRegistry.getType(structDef.getName());
+
+        if (type.getTypeCategory() != AtlasType.TypeCategory.STRUCT) {
+            throw new AtlasBaseException(structDef.getName() + ": not a struct type");
+        }
+
         vertex = typeDefStore.createTypeVertex(structDef);
 
-        toVertex(structDef, vertex, typeDefStore);
+        toVertex(structDef, (AtlasStructType)type, vertex, typeDefStore, typeRegistry);
 
         AtlasStructDef ret = toStructDef(vertex);
 
@@ -97,20 +99,17 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasStructDefStoreV1.create({})", structDefs);
         }
-        List<AtlasStructDef> structDefList = new LinkedList<>();
+        List<AtlasStructDef> ret = new ArrayList<>();
+
         for (AtlasStructDef structDef : structDefs) {
-            try {
-                AtlasStructDef atlasStructDef = create(structDef);
-                structDefList.add(atlasStructDef);
-            } catch (AtlasBaseException baseException) {
-                LOG.error("Failed to create {}", structDef);
-                LOG.error("Exception: {}", baseException);
-            }
+            ret.add(create(structDef));
         }
+
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasStructDefStoreV1.create({}, {})", structDefs, structDefList);
+            LOG.debug("<== AtlasStructDefStoreV1.create({}, {})", structDefs, ret);
         }
-        return structDefList;
+
+        return ret;
     }
 
     @Override
@@ -119,17 +118,17 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
             LOG.debug("==> AtlasStructDefStoreV1.getAll()");
         }
 
-        List<AtlasStructDef> structDefs = new LinkedList<>();
-        Iterator<AtlasVertex> verticesByCategory = typeDefStore.findTypeVerticesByCategory(TypeCategory.STRUCT);
-        while (verticesByCategory.hasNext()) {
-            AtlasStructDef atlasStructDef = toStructDef(verticesByCategory.next());
-            structDefs.add(atlasStructDef);
+        List<AtlasStructDef> ret = new ArrayList<>();
+
+        Iterator<AtlasVertex> vertices = typeDefStore.findTypeVerticesByCategory(TypeCategory.STRUCT);
+        while (vertices.hasNext()) {
+            ret.add(toStructDef(vertices.next()));
         }
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasStructDefStoreV1.getAll()");
+            LOG.debug("<== AtlasStructDefStoreV1.getAll(): count={}", ret.size());
         }
-        return structDefs;
+        return ret;
     }
 
     @Override
@@ -188,7 +187,13 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
             throw new AtlasBaseException("no structDef exists with name " + name);
         }
 
-        toVertex(structDef, vertex);
+        AtlasType type = typeRegistry.getType(structDef.getName());
+
+        if (type.getTypeCategory() != AtlasType.TypeCategory.STRUCT) {
+            throw new AtlasBaseException(structDef.getName() + ": not a struct type");
+        }
+
+        toVertex(structDef, (AtlasStructType)type, vertex);
 
         AtlasStructDef ret = toStructDef(vertex);
 
@@ -211,7 +216,13 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
             throw new AtlasBaseException("no structDef exists with guid " + guid);
         }
 
-        toVertex(structDef, vertex);
+        AtlasType type = typeRegistry.getType(structDef.getName());
+
+        if (type.getTypeCategory() != AtlasType.TypeCategory.STRUCT) {
+            throw new AtlasBaseException(structDef.getName() + ": not a struct type");
+        }
+
+        toVertex(structDef, (AtlasStructType)type, vertex);
 
         AtlasStructDef ret = toStructDef(vertex);
 
@@ -228,20 +239,17 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
             LOG.debug("==> AtlasStructDefStoreV1.update({})", structDefs);
         }
 
-        List<AtlasStructDef> updatedDefs = new ArrayList<>();
+        List<AtlasStructDef> ret = new ArrayList<>();
 
         for (AtlasStructDef structDef : structDefs) {
-            try {
-                AtlasStructDef updatedDef = updateByName(structDef.getName(), structDef);
-                updatedDefs.add(updatedDef);
-            } catch (AtlasBaseException ex) {}
+            ret.add(updateByName(structDef.getName(), structDef));
         }
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasStructDefStoreV1.update({}): {}", structDefs, updatedDefs);
+            LOG.debug("<== AtlasStructDefStoreV1.update({}): {}", structDefs, ret);
         }
 
-        return updatedDefs;
+        return ret;
     }
 
     @Override
@@ -269,12 +277,8 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
             LOG.debug("==> AtlasStructDefStoreV1.deleteByNames({})", names);
         }
 
-        List<AtlasStructDef> updatedDefs = new ArrayList<>();
-
         for (String name : names) {
-            try {
-                deleteByName(name);
-            } catch (AtlasBaseException ex) {}
+            deleteByName(name);
         }
 
         if (LOG.isDebugEnabled()) {
@@ -307,12 +311,8 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
             LOG.debug("==> AtlasStructDefStoreV1.deleteByGuids({})", guids);
         }
 
-        List<AtlasStructDef> updatedDefs = new ArrayList<>();
-
         for (String guid : guids) {
-            try {
-                deleteByGuid(guid);
-            } catch (AtlasBaseException ex) {}
+            deleteByGuid(guid);
         }
 
         if (LOG.isDebugEnabled()) {
@@ -326,22 +326,19 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
             LOG.debug("==> AtlasStructDefStoreV1.search({})", filter);
         }
 
-        List<AtlasStructDef> structDefs = new ArrayList<AtlasStructDef>();
-
-        Iterator<AtlasVertex> vertices = typeDefStore.findTypeVerticesByCategory(TypeCategory.STRUCT);
+        List<AtlasStructDef>  structDefs = new ArrayList<AtlasStructDef>();
+        Iterator<AtlasVertex> vertices   = typeDefStore.findTypeVerticesByCategory(TypeCategory.STRUCT);
 
-        while(vertices.hasNext()) {
-            AtlasVertex       AtlasVertex  = vertices.next();
-            AtlasStructDef structDef = toStructDef(AtlasVertex);
+        while (vertices.hasNext()) {
+            AtlasVertex    vertex    = vertices.next();
+            AtlasStructDef structDef = toStructDef(vertex);
 
             if (structDef != null) {
                 structDefs.add(structDef);
             }
         }
 
-        if (CollectionUtils.isNotEmpty(structDefs)) {
-            CollectionUtils.filter(structDefs, FilterUtil.getPredicateFromSearchFilter(filter));
-        }
+        CollectionUtils.filter(structDefs, FilterUtil.getPredicateFromSearchFilter(filter));
 
         AtlasStructDefs ret = new AtlasStructDefs(structDefs);
 
@@ -352,8 +349,8 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
         return ret;
     }
 
-    private void toVertex(AtlasStructDef structDef, AtlasVertex vertex) {
-        toVertex(structDef, vertex, typeDefStore);
+    private void toVertex(AtlasStructDef structDef, AtlasStructType structType, AtlasVertex vertex) {
+        toVertex(structDef, structType, vertex, typeDefStore, typeRegistry);
     }
 
     private AtlasStructDef toStructDef(AtlasVertex vertex) throws AtlasBaseException {
@@ -366,15 +363,14 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
         return ret;
     }
 
-    public static void toVertex(AtlasStructDef structDef, AtlasVertex vertex, AtlasTypeDefGraphStoreV1 typeDefStore) {
-        AtlasTypeRegistry typeRegistry = typeDefStore.getTypeRegistry();
-        AtlasStructType   structType   = (AtlasStructType)typeRegistry.getType(structDef.getName());
-        List<String>      attrNames    = new ArrayList<>(structDef.getAttributeDefs().size());
+    public static void toVertex(AtlasStructDef structDef, AtlasStructType structType, AtlasVertex vertex,
+                                AtlasTypeDefGraphStoreV1 typeDefStore, AtlasTypeRegistry typeRegistry) {
+        List<String> attrNames = new ArrayList<>(structDef.getAttributeDefs().size());
 
         for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) {
             String propertyKey = AtlasGraphUtilsV1.getPropertyKey(structDef, attributeDef.getName());
 
-            AtlasGraphUtilsV1.setProperty(vertex, propertyKey, toJsonFromAttributeDef(attributeDef, structType, typeRegistry));
+            AtlasGraphUtilsV1.setProperty(vertex, propertyKey, toJsonFromAttributeDef(attributeDef, structType));
 
             attrNames.add(attributeDef.getName());
             addReferencesForAttribute(vertex, attributeDef, typeDefStore);
@@ -382,8 +378,7 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
         AtlasGraphUtilsV1.setProperty(vertex, AtlasGraphUtilsV1.getPropertyKey(structDef), attrNames);
     }
 
-    public static AtlasStructDef toStructDef(AtlasVertex              vertex,
-                                             AtlasStructDef           structDef,
+    public static AtlasStructDef toStructDef(AtlasVertex vertex, AtlasStructDef structDef,
                                              AtlasTypeDefGraphStoreV1 typeDefStore) throws AtlasBaseException {
         AtlasStructDef ret = (structDef != null) ? structDef :new AtlasStructDef();
 
@@ -406,8 +401,7 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
         return ret;
     }
 
-    private static void addReferencesForAttribute(AtlasVertex              vertex,
-                                                  AtlasAttributeDef        attributeDef,
+    private static void addReferencesForAttribute(AtlasVertex vertex, AtlasAttributeDef attributeDef,
                                                   AtlasTypeDefGraphStoreV1 typeDefStore) {
         Set<String> referencedTypeNames = AtlasTypeUtil.getReferencedTypeNames(attributeDef.getTypeName());
 
@@ -415,36 +409,34 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
 
         for (String referencedTypeName : referencedTypeNames) {
             if (!AtlasTypeUtil.isBuiltInType(referencedTypeName)) {
-                AtlasVertex referencedTypeAtlasVertex = typeDefStore.findTypeVertexByName(referencedTypeName);
+                AtlasVertex referencedTypeVertex = typeDefStore.findTypeVertexByName(referencedTypeName);
 
-                if (referencedTypeAtlasVertex == null) {
-                    // create atlasVertex?
+                if (referencedTypeVertex == null) {
+                    // create vertex?
                 }
 
-                if (referencedTypeAtlasVertex != null) {
+                if (referencedTypeVertex != null) {
                     String label = AtlasGraphUtilsV1.getEdgeLabel(typeName, attributeDef.getName());
 
-                    typeDefStore.getOrCreateEdge(vertex, referencedTypeAtlasVertex, label);
+                    typeDefStore.getOrCreateEdge(vertex, referencedTypeVertex, label);
                 }
             }
         }
     }
 
-    private static String toJsonFromAttributeDef(AtlasAttributeDef attributeDef,
-                                                 AtlasStructType   structType,
-                                                 AtlasTypeRegistry typeRegistry) {
+    private static String toJsonFromAttributeDef(AtlasAttributeDef attributeDef, AtlasStructType structType) {
         boolean isForeignKey      = structType.isForeignKeyAttribute(attributeDef.getName());
         boolean isMappedFromRef   = structType.isMappedFromRefAttribute(attributeDef.getName());
         String  reverseAttribName = null;
 
         if (isForeignKey) { // check if the referenced entity has foreignKeyRef to this attribute
-            AtlasType attribType = typeRegistry.getType(attributeDef.getTypeName());
+            AtlasType attribType = structType.getAttributeType(attributeDef.getTypeName());
 
-            if (attribType instanceof AtlasArrayType) {
+            if (attribType.getTypeCategory() == AtlasType.TypeCategory.ARRAY) {
                 attribType = ((AtlasArrayType)attribType).getElementType();
             }
 
-            if (attribType instanceof AtlasEntityType) {
+            if (attribType.getTypeCategory() == AtlasType.TypeCategory.ENTITY) {
                 reverseAttribName = ((AtlasStructType)attribType).getMappedFromRefAttribute(structType.getTypeName(),
                                                                                             attributeDef.getName());
             }
@@ -491,73 +483,67 @@ public class AtlasStructDefStoreV1 implements AtlasStructDefStore {
             }
         }
 
-        if (! AtlasTypeUtil.isBuiltInType(attrTypeName)) {
+        if (!AtlasTypeUtil.isBuiltInType(attrTypeName)) {
             AtlasVertex attributeType = typeDefStore.findTypeVertexByName(attrTypeName);
 
             // check for isComposite/reverseAttributeName for entity types
             if (attributeType != null && typeDefStore.isTypeVertex(attributeType, TypeCategory.CLASS)) {
-                String reverseAttribName = (String) attribInfo.get("reverseAttributeName");
-                Boolean isComposite      = (Boolean) attribInfo.get("isComposite");
+                String  reverseAttribName = (String) attribInfo.get("reverseAttributeName");
+                Boolean isComposite       = (Boolean) attribInfo.get("isComposite");
 
-                // find the attribute that refers to this attribute
                 if (StringUtils.isNotBlank(reverseAttribName) || isComposite) {
                     if (AtlasTypeUtil.isMapType(attrTypeName)) {
                         throw new AtlasBaseException(structDef.getName() + "." + ret.getName()
                                                      + ": constraints not supported on map type " + attrTypeName);
                     }
 
-                    if (attributeType != null) {
-                        String refAttributeName = null;
-
-                        List<String> attrNames = attributeType.getProperty(
+                    String       refAttributeName = null;
+                    List<String> attrNames        = attributeType.getProperty(
                                                             AtlasGraphUtilsV1.getPropertyKey(attrTypeName), List.class);
 
-                        if (CollectionUtils.isNotEmpty(attrNames)) {
-                            for (String attrName : attrNames) {
-                                String attribJson = attributeType.getProperty(
+                    if (CollectionUtils.isNotEmpty(attrNames)) {
+                        for (String attrName : attrNames) {
+                            String attribJson = attributeType.getProperty(
                                                 AtlasGraphUtilsV1.getPropertyKey(attrTypeName, attrName), String.class);
 
-                                Map    refAttrInfo            = AtlasType.fromJson(attribJson, Map.class);
-                                String refAttribType          = (String) refAttrInfo.get("dataType");
-                                String refAttribRevAttribName = (String) refAttrInfo.get("reverseAttributeName");
+                            Map    refAttrInfo            = AtlasType.fromJson(attribJson, Map.class);
+                            String refAttribType          = (String) refAttrInfo.get("dataType");
+                            String refAttribRevAttribName = (String) refAttrInfo.get("reverseAttributeName");
 
-                                if (StringUtils.equals(refAttribType, structDef.getName()) &&
-                                        StringUtils.equals(refAttribRevAttribName, ret.getName())) {
-                                    refAttributeName = (String) refAttrInfo.get("name");
+                            if (StringUtils.equals(refAttribType, structDef.getName()) &&
+                                StringUtils.equals(refAttribRevAttribName, ret.getName())) {
+                                refAttributeName = (String) refAttrInfo.get("name");
 
-                                    break;
-                                }
+                                break;
                             }
                         }
+                    }
 
-                        if (isComposite) {
-                            if (StringUtils.isNotBlank(refAttributeName)) { // ex: hive_table.columns, hive_column.table
-                                Map<String, Object> params = new HashMap<String, Object>();
-                                params.put(AtlasConstraintDef.CONSTRAINT_PARAM_REF_ATTRIBUTE, refAttributeName);
+                    if (isComposite) {
+                        if (StringUtils.isNotBlank(refAttributeName)) { // ex: hive_table.columns, hive_column.table
+                            Map<String, Object> params = new HashMap<String, Object>();
+                            params.put(AtlasConstraintDef.CONSTRAINT_PARAM_REF_ATTRIBUTE, refAttributeName);
 
-                                ret.addConstraint(new AtlasConstraintDef(CONSTRAINT_TYPE_MAPPED_FROM_REF, params));
-                            } else { // ex: hive_table.partitionKeys, with no reverseAttribute-reference
-                                ret.addConstraint(new AtlasConstraintDef(CONSTRAINT_TYPE_FOREIGN_KEY));
-                            }
+                            ret.addConstraint(new AtlasConstraintDef(CONSTRAINT_TYPE_MAPPED_FROM_REF, params));
+                        } else { // ex: hive_table.partitionKeys, with no reverseAttribute-reference
+                            ret.addConstraint(new AtlasConstraintDef(CONSTRAINT_TYPE_FOREIGN_KEY));
                         }
+                    }
 
-                        if (StringUtils.isNotBlank(reverseAttribName)) { // ex: hive_column.table
-                            Map<String, Object> params = new HashMap<>();
-                            params.put(CONSTRAINT_PARAM_ON_DELETE, CONSTRAINT_PARAM_VAL_CASCADE);
+                    if (StringUtils.isNotBlank(reverseAttribName)) { // ex: hive_column.table
+                        Map<String, Object> params = new HashMap<>();
+                        params.put(CONSTRAINT_PARAM_ON_DELETE, CONSTRAINT_PARAM_VAL_CASCADE);
 
-                            ret.addConstraint(new AtlasConstraintDef(CONSTRAINT_TYPE_FOREIGN_KEY, params));
-                        }
+                        ret.addConstraint(new AtlasConstraintDef(CONSTRAINT_TYPE_FOREIGN_KEY, params));
                     }
                 }
             }
         }
 
-
-        Map     multiplicity      = AtlasType.fromJson((String) attribInfo.get("multiplicity"), Map.class);
-        Number  minCount          = (Number) multiplicity.get("lower");
-        Number  maxCount          = (Number) multiplicity.get("upper");
-        Boolean isUnique          = (Boolean) multiplicity.get("isUnique");
-
+        Map     multiplicity = AtlasType.fromJson((String) attribInfo.get("multiplicity"), Map.class);
+        Number  minCount     = (Number) multiplicity.get("lower");
+        Number  maxCount     = (Number) multiplicity.get("upper");
+        Boolean isUnique     = (Boolean) multiplicity.get("isUnique");
 
         if (minCount == null || minCount.intValue() == 0) {
             ret.setOptional(true);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
index 4b50aac..6634707 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasTypeDefGraphStoreV1.java
@@ -19,6 +19,7 @@ package org.apache.atlas.repository.store.graph.v1;
 
 import com.google.common.base.Preconditions;
 
+import com.google.inject.Inject;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
 import org.apache.atlas.model.typedef.AtlasClassificationDef;
@@ -31,7 +32,12 @@ import org.apache.atlas.repository.graphdb.AtlasEdge;
 import org.apache.atlas.repository.graphdb.AtlasEdgeDirection;
 import org.apache.atlas.repository.graphdb.AtlasGraph;
 import org.apache.atlas.repository.graphdb.AtlasVertex;
+import org.apache.atlas.repository.store.graph.AtlasClassificationDefStore;
+import org.apache.atlas.repository.store.graph.AtlasEntityDefStore;
+import org.apache.atlas.repository.store.graph.AtlasEnumDefStore;
+import org.apache.atlas.repository.store.graph.AtlasStructDefStore;
 import org.apache.atlas.repository.store.graph.AtlasTypeDefGraphStore;
+import org.apache.atlas.type.AtlasTypeRegistry;
 import org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -57,8 +63,9 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
 
     protected final AtlasGraph atlasGraph = AtlasGraphProvider.getGraphInstance();
 
-    public AtlasTypeDefGraphStoreV1() {
-        super();
+    @Inject
+    public AtlasTypeDefGraphStoreV1(AtlasTypeRegistry typeRegistry) {
+        super(typeRegistry);
 
         LOG.info("==> AtlasTypeDefGraphStoreV1()");
 
@@ -72,16 +79,31 @@ public class AtlasTypeDefGraphStoreV1 extends AtlasTypeDefGraphStore {
     }
 
     @Override
+    protected AtlasEnumDefStore getEnumDefStore(AtlasTypeRegistry typeRegistry) {
+        return new AtlasEnumDefStoreV1(this, typeRegistry);
+    }
+
+    @Override
+    protected AtlasStructDefStore getStructDefStore(AtlasTypeRegistry typeRegistry) {
+        return new AtlasStructDefStoreV1(this, typeRegistry);
+    }
+
+    @Override
+    protected AtlasClassificationDefStore getClassificationDefStore(AtlasTypeRegistry typeRegistry) {
+        return new AtlasClassificationDefStoreV1(this, typeRegistry);
+    }
+
+    @Override
+    protected AtlasEntityDefStore getEntityDefStore(AtlasTypeRegistry typeRegistry) {
+        return new AtlasEntityDefStoreV1(this, typeRegistry);
+    }
+
+    @Override
     public void init() throws AtlasBaseException {
         LOG.info("==> AtlasTypeDefGraphStoreV1.init()");
 
         super.init();
 
-        super.init(new AtlasEnumDefStoreV1(this),
-                   new AtlasStructDefStoreV1(this),
-                   new AtlasClassificationDefStoreV1(this),
-                   new AtlasEntityDefStoreV1(this));
-
         LOG.info("<== AtlasTypeDefGraphStoreV1.init()");
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
index 889c3dd..0658361 100644
--- a/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
+++ b/webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
@@ -64,7 +64,7 @@ public class TypesREST {
     private HttpServletRequest httpServletRequest;
 
     @Inject
-    public TypesREST(AtlasTypeDefStore typeDefStore, AtlasTypeRegistry atlasTypeRegistry) {
+    public TypesREST(AtlasTypeDefStore typeDefStore) {
         LOG.info("new TypesREST");
         this.typeDefStore = typeDefStore;
     }


[2/2] incubator-atlas git commit: ATLAS-1230: updated AtlasTypeRegistry to support batch, atomic type updates

Posted by ma...@apache.org.
ATLAS-1230: updated AtlasTypeRegistry to support batch, atomic type updates

Signed-off-by: Suma Shivaprasad <su...@gmail.com>


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

Branch: refs/heads/master
Commit: eb6e656be868fba22aaa330d98137be78e30bdcb
Parents: 4d9cf45
Author: Madhan Neethiraj <ma...@apache.org>
Authored: Tue Oct 18 15:27:46 2016 -0700
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Tue Oct 18 18:33:36 2016 -0700

----------------------------------------------------------------------
 .../org/apache/atlas/type/AtlasArrayType.java   |  10 -
 .../atlas/type/AtlasClassificationType.java     |  11 +-
 .../org/apache/atlas/type/AtlasEntityType.java  |  11 +-
 .../org/apache/atlas/type/AtlasMapType.java     |  19 -
 .../org/apache/atlas/type/AtlasStructType.java  |  13 +-
 .../apache/atlas/type/AtlasTypeRegistry.java    | 847 +++++++++++--------
 .../org/apache/atlas/model/ModelTestUtil.java   |  55 +-
 .../model/instance/TestAtlasClassification.java |   7 +-
 .../atlas/model/instance/TestAtlasEntity.java   |   7 +-
 .../atlas/model/typedef/TestAtlasEntityDef.java |   7 +-
 .../apache/atlas/type/TestAtlasEntityType.java  |  33 +-
 release-log.txt                                 |   1 +
 .../store/graph/AtlasTypeDefGraphStore.java     | 292 ++++---
 .../store/graph/v1/AtlasAbstractDefStoreV1.java |  33 +
 .../graph/v1/AtlasClassificationDefStoreV1.java |  95 +--
 .../store/graph/v1/AtlasEntityDefStoreV1.java   |  94 +-
 .../store/graph/v1/AtlasEnumDefStoreV1.java     |  87 +-
 .../store/graph/v1/AtlasStructDefStoreV1.java   | 214 +++--
 .../graph/v1/AtlasTypeDefGraphStoreV1.java      |  36 +-
 .../org/apache/atlas/web/rest/TypesREST.java    |   2 +-
 20 files changed, 1038 insertions(+), 836 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/intg/src/main/java/org/apache/atlas/type/AtlasArrayType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasArrayType.java b/intg/src/main/java/org/apache/atlas/type/AtlasArrayType.java
index 21a4037..e8092a5 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasArrayType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasArrayType.java
@@ -103,16 +103,6 @@ public class AtlasArrayType extends AtlasType {
     @Override
     public void resolveReferences(AtlasTypeRegistry typeRegistry) throws AtlasBaseException {
         elementType = typeRegistry.getType(elementTypeName);
-
-        if (elementType == null) {
-            String msg = elementTypeName + ": unknown element-type for array";
-
-            LOG.error(msg);
-
-            throw new AtlasBaseException(msg);
-        }
-
-        elementType.resolveReferences(typeRegistry);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java b/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
index d962bbe..6299265 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
@@ -70,7 +70,7 @@ public class AtlasClassificationType extends AtlasStructType {
         for (String superTypeName : classificationDef.getSuperTypes()) {
             AtlasType superType = typeRegistry.getType(superTypeName);
 
-            if (superType != null && superType instanceof AtlasClassificationType) {
+            if (superType instanceof AtlasClassificationType) {
                 AtlasClassificationType superClassificationType = (AtlasClassificationType)superType;
 
                 superClassificationType.resolveReferences(typeRegistry);
@@ -82,13 +82,8 @@ public class AtlasClassificationType extends AtlasStructType {
                     allS.addAll(superClassificationType.getAllSuperTypes());
                 }
             } else {
-                String msg = superTypeName + ((superType == null) ? ": unknown" : ": incompatible");
-
-                msg += (" supertype in classification " + classificationDef.getName());
-
-                LOG.error(msg);
-
-                throw new AtlasBaseException(msg);
+                throw new AtlasBaseException(superTypeName + ": incompatible supertype in classification "
+                                             + classificationDef.getName());
             }
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
----------------------------------------------------------------------
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 7017d65..9ae61a7 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
@@ -68,7 +68,7 @@ public class AtlasEntityType extends AtlasStructType {
         for (String superTypeName : entityDef.getSuperTypes()) {
             AtlasType superType = typeRegistry.getType(superTypeName);
 
-            if (superType != null && superType instanceof AtlasEntityType) {
+            if (superType instanceof AtlasEntityType) {
                 AtlasEntityType superEntityType = (AtlasEntityType)superType;
 
                 superEntityType.resolveReferences(typeRegistry);
@@ -80,13 +80,8 @@ public class AtlasEntityType extends AtlasStructType {
                     allS.addAll(superEntityType.getAllSuperTypes());
                 }
             } else {
-                String msg = superTypeName + ((superType == null) ? ": unknown" : ": incompatible");
-
-                msg += (" supertype in entity " + entityDef.getName());
-
-                LOG.error(msg);
-
-                throw new AtlasBaseException(msg);
+                throw new AtlasBaseException(superTypeName + ": incompatible supertype in entity "
+                                             + entityDef.getName());
             }
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/intg/src/main/java/org/apache/atlas/type/AtlasMapType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasMapType.java b/intg/src/main/java/org/apache/atlas/type/AtlasMapType.java
index f2ab08b..0ebfa26 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasMapType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasMapType.java
@@ -88,25 +88,6 @@ public class AtlasMapType extends AtlasType {
     public void resolveReferences(AtlasTypeRegistry typeRegistry) throws AtlasBaseException {
         this.keyType   = typeRegistry.getType(keyTypeName);
         this.valueType = typeRegistry.getType(valueTypeName);
-
-        if (keyType == null) {
-            String msg = keyTypeName + ": unknown key-type for map";
-
-            LOG.error(msg);
-
-            throw new AtlasBaseException(msg);
-        }
-
-        if (valueType == null) {
-            String msg = valueTypeName + ": unknown value-type for map";
-
-            LOG.error(msg);
-
-            throw new AtlasBaseException(msg);
-        }
-
-        keyType.resolveReferences(typeRegistry);
-        valueType.resolveReferences(typeRegistry);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java b/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
index 5c32db2..4e741e5 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
@@ -103,11 +103,6 @@ public class AtlasStructType extends AtlasType {
         for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) {
             AtlasType attrType = typeRegistry.getType(attributeDef.getTypeName());
 
-            if (attrType == null) {
-                throw new AtlasBaseException(attributeDef.getTypeName() + ": unknown type for attribute "
-                                             + structDef.getName() + "." + attributeDef.getName());
-            }
-
             resolveConstraints(attributeDef, attrType);
 
             Cardinality cardinality = attributeDef.getCardinality();
@@ -407,8 +402,8 @@ public class AtlasStructType extends AtlasType {
 
         if (StringUtils.isBlank(refAttribName)) {
             throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": "
-                        + CONSTRAINT_TYPE_MAPPED_FROM_REF + " invalid constraint. missing parameter "
-                        + CONSTRAINT_PARAM_REF_ATTRIBUTE);
+                        + " invalid constraint. missing parameter " + CONSTRAINT_PARAM_REF_ATTRIBUTE
+                        + " in " + CONSTRAINT_TYPE_MAPPED_FROM_REF + ". params=" + constraintDef.getParams());
         }
 
         AtlasStructType   structType = (AtlasStructType)attribType;
@@ -421,8 +416,8 @@ public class AtlasStructType extends AtlasType {
         }
 
         if (!StringUtils.equals(getTypeName(), refAttrib.getTypeName())) {
-            throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": invalid constraint. Datatype of"
-                    + CONSTRAINT_PARAM_REF_ATTRIBUTE + " " + structType.getTypeName() + "." + refAttribName
+            throw new AtlasBaseException(getTypeName() + "." + attribDef.getName() + ": invalid constraint. Datatype"
+                    + " of " + CONSTRAINT_PARAM_REF_ATTRIBUTE + " " + structType.getTypeName() + "." + refAttribName
                     + " should be " + getTypeName() + ", but found " + refAttrib.getTypeName());
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
----------------------------------------------------------------------
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 c3f17f4..f31ee50 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
@@ -17,12 +17,15 @@
  */
 package org.apache.atlas.type;
 
+import com.sun.jersey.spi.resource.Singleton;
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
 import org.apache.atlas.model.typedef.AtlasClassificationDef;
-import org.apache.atlas.model.typedef.AtlasEnumDef;
 import org.apache.atlas.model.typedef.AtlasEntityDef;
+import org.apache.atlas.model.typedef.AtlasEnumDef;
 import org.apache.atlas.model.typedef.AtlasStructDef;
+import org.apache.atlas.model.typedef.AtlasTypesDef;
+
 import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_ARRAY_PREFIX;
 import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_ARRAY_SUFFIX;
 import static org.apache.atlas.model.typedef.AtlasBaseTypeDef.ATLAS_TYPE_MAP_PREFIX;
@@ -37,532 +40,652 @@ import org.slf4j.LoggerFactory;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * registry for all types defined in Atlas.
  */
+@Singleton
 public class AtlasTypeRegistry {
     private static final Logger LOG = LoggerFactory.getLogger(AtlasStructType.class);
 
-    private final Map<String, AtlasType>               allTypes;
-    private final TypeDefCache<AtlasEnumDef>           enumDefs;
-    private final TypeDefCache<AtlasStructDef>         structDefs;
-    private final TypeDefCache<AtlasClassificationDef> classificationDefs;
-    private final TypeDefCache<AtlasEntityDef>         entityDefs;
+    protected RegistryData registryData;
 
     public AtlasTypeRegistry() {
-        allTypes           = new ConcurrentHashMap<>();
-        enumDefs           = new TypeDefCache<>(this);
-        structDefs         = new TypeDefCache<>(this);
-        classificationDefs = new TypeDefCache<>(this);
-        entityDefs         = new TypeDefCache<>(this);
-
-        registerType(new AtlasBuiltInTypes.AtlasBooleanType());
-        registerType(new AtlasBuiltInTypes.AtlasByteType());
-        registerType(new AtlasBuiltInTypes.AtlasShortType());
-        registerType(new AtlasBuiltInTypes.AtlasIntType());
-        registerType(new AtlasBuiltInTypes.AtlasLongType());
-        registerType(new AtlasBuiltInTypes.AtlasFloatType());
-        registerType(new AtlasBuiltInTypes.AtlasDoubleType());
-        registerType(new AtlasBuiltInTypes.AtlasBigIntegerType());
-        registerType(new AtlasBuiltInTypes.AtlasBigDecimalType());
-        registerType(new AtlasBuiltInTypes.AtlasDateType());
-        registerType(new AtlasBuiltInTypes.AtlasStringType());
-        registerType(new AtlasBuiltInTypes.AtlasObjectIdType());
-    }
-
-    public Collection<String> getAllTypeNames() { return Collections.unmodifiableSet(allTypes.keySet()); }
-
-    public AtlasType getType(String typeName) {
+        registryData = new RegistryData();
+    }
+
+    protected AtlasTypeRegistry(AtlasTypeRegistry other) {
+        registryData = new RegistryData(other.registryData);
+    }
+
+    public Collection<String> getAllTypeNames() { return registryData.allTypes.getAllTypeNames(); }
+
+    public AtlasType getType(String typeName) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("==> AtlasTypeRegistry.getType({})", typeName);
         }
 
-        AtlasType ret = allTypes.get(typeName);
+        AtlasType ret = registryData.allTypes.getTypeByName(typeName);
 
         if (ret == null) {
-            try {
-                if (typeName.startsWith(ATLAS_TYPE_ARRAY_PREFIX) && typeName.endsWith(ATLAS_TYPE_ARRAY_SUFFIX)) {
-                    int startIdx = ATLAS_TYPE_ARRAY_PREFIX.length();
-                    int endIdx = typeName.length() - ATLAS_TYPE_ARRAY_SUFFIX.length();
-                    String elementTypeName = typeName.substring(startIdx, endIdx);
-
-                    ret = new AtlasArrayType(elementTypeName, this);
-                } else if (typeName.startsWith(ATLAS_TYPE_MAP_PREFIX) && typeName.endsWith(ATLAS_TYPE_MAP_SUFFIX)) {
-                    int startIdx = ATLAS_TYPE_MAP_PREFIX.length();
-                    int endIdx = typeName.length() - ATLAS_TYPE_MAP_SUFFIX.length();
-                    String[] keyValueTypes = typeName.substring(startIdx, endIdx).split(ATLAS_TYPE_MAP_KEY_VAL_SEP, 2);
-                    String keyTypeName = keyValueTypes.length > 0 ? keyValueTypes[0] : null;
-                    String valueTypeName = keyValueTypes.length > 1 ? keyValueTypes[1] : null;
-
-                    ret = new AtlasMapType(keyTypeName, valueTypeName, this);
-                }
-            } catch(AtlasBaseException excp) {
-                LOG.warn("failed to instantiate type for " + typeName, excp);
+            if (typeName.startsWith(ATLAS_TYPE_ARRAY_PREFIX) && typeName.endsWith(ATLAS_TYPE_ARRAY_SUFFIX)) {
+                int    startIdx        = ATLAS_TYPE_ARRAY_PREFIX.length();
+                int    endIdx          = typeName.length() - ATLAS_TYPE_ARRAY_SUFFIX.length();
+                String elementTypeName = typeName.substring(startIdx, endIdx);
+
+                ret = new AtlasArrayType(elementTypeName, this);
+            } else if (typeName.startsWith(ATLAS_TYPE_MAP_PREFIX) && typeName.endsWith(ATLAS_TYPE_MAP_SUFFIX)) {
+                int      startIdx      = ATLAS_TYPE_MAP_PREFIX.length();
+                int      endIdx        = typeName.length() - ATLAS_TYPE_MAP_SUFFIX.length();
+                String[] keyValueTypes = typeName.substring(startIdx, endIdx).split(ATLAS_TYPE_MAP_KEY_VAL_SEP, 2);
+                String   keyTypeName   = keyValueTypes.length > 0 ? keyValueTypes[0] : null;
+                String   valueTypeName = keyValueTypes.length > 1 ? keyValueTypes[1] : null;
+
+                ret = new AtlasMapType(keyTypeName, valueTypeName, this);
+            } else {
+                throw new AtlasBaseException(typeName + ": unknown typename");
             }
         }
 
         if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.getType({})", typeName);
+            LOG.debug("<== AtlasTypeRegistry.getType({}): {}", typeName, ret);
         }
 
         return ret;
     }
 
-
-    public void addType(AtlasBaseTypeDef typeDef) throws AtlasBaseException {
+    public AtlasType getTypeByGuid(String guid) {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.addType({})", typeDef);
+            LOG.debug("==> AtlasTypeRegistry.getTypeByGuid({})", guid);
         }
 
-        if (typeDef == null) {
-            // ignore
-        } else if (typeDef.getClass().equals(AtlasEnumDef.class)) {
-            AtlasEnumDef enumDef = (AtlasEnumDef)typeDef;
+        AtlasType ret = registryData.allTypes.getTypeByGuid(guid);
 
-            enumDefs.addType(enumDef, new AtlasEnumType(enumDef));
-        } else if (typeDef.getClass().equals(AtlasStructDef.class)) {
-            AtlasStructDef structDef = (AtlasStructDef)typeDef;
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("<== AtlasTypeRegistry.getTypeByGuid({}): {}", guid, ret);
+        }
 
-            structDefs.addType(structDef, new AtlasStructType(structDef, this));
-        } else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
-            AtlasClassificationDef classificationDef = (AtlasClassificationDef)typeDef;
+        return ret;
+    }
 
-            classificationDefs.addType(classificationDef, new AtlasClassificationType(classificationDef, this));
-        } else if (typeDef.getClass().equals(AtlasEntityDef.class)) {
-            AtlasEntityDef entityDef = (AtlasEntityDef)typeDef;
 
-            entityDefs.addType(entityDef, new AtlasEntityType(entityDef, this));
-        }
+    public Collection<AtlasEnumDef> getAllEnumDefs() { return registryData.enumDefs.getAll(); }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.addType({})", typeDef);
-        }
+    public AtlasEnumDef getEnumDefByGuid(String guid) {
+        return registryData.enumDefs.getTypeDefByGuid(guid);
     }
 
-    public void addTypeWithNoRefResolve(AtlasBaseTypeDef typeDef) {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.addTypeWithNoRefResolve({})", typeDef);
-        }
+    public AtlasEnumDef getEnumDefByName(String name) {
+        return registryData.enumDefs.getTypeDefByName(name);
+    }
 
-        if (typeDef == null) {
-            // ignore
-        } else if (typeDef.getClass().equals(AtlasEnumDef.class)) {
-            AtlasEnumDef enumDef = (AtlasEnumDef)typeDef;
 
-            enumDefs.addType(enumDef, new AtlasEnumType(enumDef));
-        } else if (typeDef.getClass().equals(AtlasStructDef.class)) {
-            AtlasStructDef structDef = (AtlasStructDef)typeDef;
+    public Collection<AtlasStructDef> getAllStructDefs() { return registryData.structDefs.getAll(); }
 
-            structDefs.addType(structDef, new AtlasStructType(structDef));
-        } else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
-            AtlasClassificationDef classificationDef = (AtlasClassificationDef)typeDef;
+    public AtlasStructDef getStructDefByGuid(String guid) {
+        return registryData.structDefs.getTypeDefByGuid(guid);
+    }
 
-            classificationDefs.addType(classificationDef, new AtlasClassificationType(classificationDef));
-        } else if (typeDef.getClass().equals(AtlasEntityDef.class)) {
-            AtlasEntityDef entityDef = (AtlasEntityDef)typeDef;
+    public AtlasStructDef getStructDefByName(String name) { return registryData.structDefs.getTypeDefByName(name); }
 
-            entityDefs.addType(entityDef, new AtlasEntityType(entityDef));
-        }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.addTypeWithNoRefResolve({})", typeDef);
-        }
+    public Collection<AtlasClassificationDef> getAllClassificationDefs() {
+        return registryData.classificationDefs.getAll();
     }
 
-    public void updateType(AtlasBaseTypeDef typeDef) throws AtlasBaseException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.updateType({})", typeDef);
-        }
+    public AtlasClassificationDef getClassificationDefByGuid(String guid) {
+        return registryData.classificationDefs.getTypeDefByGuid(guid);
+    }
 
-        if (typeDef == null) {
-            // ignore
-        } else if (StringUtils.isNotBlank(typeDef.getGuid())) {
-            updateTypeByGuid(typeDef.getGuid(), typeDef);
-        } else if (StringUtils.isNotBlank(typeDef.getName())) {
-            updateTypeByName(typeDef.getName(), typeDef);
-        }
+    public AtlasClassificationDef getClassificationDefByName(String name) {
+        return registryData.classificationDefs.getTypeDefByName(name);
+    }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.updateType({})", typeDef);
-        }
+
+    public Collection<AtlasEntityDef> getAllEntityDefs() { return registryData.entityDefs.getAll(); }
+
+    public AtlasEntityDef getEntityDefByGuid(String guid) {
+        return registryData.entityDefs.getTypeDefByGuid(guid);
     }
 
-    public void updateTypeWithNoRefResolve(AtlasBaseTypeDef typeDef) {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.updateType({})", typeDef);
-        }
+    public AtlasEntityDef getEntityDefByName(String name) {
+        return registryData.entityDefs.getTypeDefByName(name);
+    }
 
-        if (typeDef == null) {
-            // ignore
-        } else if (StringUtils.isNotBlank(typeDef.getGuid())) {
-            updateTypeByGuidWithNoRefResolve(typeDef.getGuid(), typeDef);
-        } else if (StringUtils.isNotBlank(typeDef.getName())) {
-            updateTypeByNameWithNoRefResolve(typeDef.getName(), typeDef);
-        }
+    public AtlasTransientTypeRegistry createTransientTypeRegistry() {
+        return new AtlasTransientTypeRegistry(this);
+    }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.updateType({})", typeDef);
+    public void commitTransientTypeRegistry(AtlasTransientTypeRegistry transientTypeRegistry) {
+        this.registryData = transientTypeRegistry.registryData;
+    }
+
+    static class RegistryData {
+        final TypeCache                            allTypes;
+        final TypeDefCache<AtlasEnumDef>           enumDefs;
+        final TypeDefCache<AtlasStructDef>         structDefs;
+        final TypeDefCache<AtlasClassificationDef> classificationDefs;
+        final TypeDefCache<AtlasEntityDef>         entityDefs;
+
+        RegistryData() {
+            allTypes           = new TypeCache();
+            enumDefs           = new TypeDefCache<>(allTypes);
+            structDefs         = new TypeDefCache<>(allTypes);
+            classificationDefs = new TypeDefCache<>(allTypes);
+            entityDefs         = new TypeDefCache<>(allTypes);
+
+            allTypes.addType(new AtlasBuiltInTypes.AtlasBooleanType());
+            allTypes.addType(new AtlasBuiltInTypes.AtlasByteType());
+            allTypes.addType(new AtlasBuiltInTypes.AtlasShortType());
+            allTypes.addType(new AtlasBuiltInTypes.AtlasIntType());
+            allTypes.addType(new AtlasBuiltInTypes.AtlasLongType());
+            allTypes.addType(new AtlasBuiltInTypes.AtlasFloatType());
+            allTypes.addType(new AtlasBuiltInTypes.AtlasDoubleType());
+            allTypes.addType(new AtlasBuiltInTypes.AtlasBigIntegerType());
+            allTypes.addType(new AtlasBuiltInTypes.AtlasBigDecimalType());
+            allTypes.addType(new AtlasBuiltInTypes.AtlasDateType());
+            allTypes.addType(new AtlasBuiltInTypes.AtlasStringType());
+            allTypes.addType(new AtlasBuiltInTypes.AtlasObjectIdType());
+        }
+
+        RegistryData(RegistryData other) {
+            allTypes           = new TypeCache(other.allTypes);
+            enumDefs           = new TypeDefCache<>(other.enumDefs, allTypes);
+            structDefs         = new TypeDefCache<>(other.structDefs, allTypes);
+            classificationDefs = new TypeDefCache<>(other.classificationDefs, allTypes);
+            entityDefs         = new TypeDefCache<>(other.entityDefs, allTypes);
         }
     }
 
-    public void updateTypeByGuid(String guid, AtlasBaseTypeDef typeDef) throws AtlasBaseException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.updateTypeByGuid({})", guid);
+    public static class AtlasTransientTypeRegistry extends AtlasTypeRegistry {
+
+        private AtlasTransientTypeRegistry(AtlasTypeRegistry parent) {
+            super(parent);
         }
 
-        if (guid == null || typeDef == null) {
-            // ignore
-        } else if (typeDef.getClass().equals(AtlasEnumDef.class)) {
-            AtlasEnumDef enumDef = (AtlasEnumDef)typeDef;
+        private void resolveReferences() throws AtlasBaseException {
+            for (AtlasType type : registryData.allTypes.getAllTypes()) {
+                type.resolveReferences(this);
+            }
+        }
 
-            enumDefs.removeTypeDefByGuid(guid);
-            enumDefs.addType(enumDef, new AtlasEnumType(enumDef));
-        } else if (typeDef.getClass().equals(AtlasStructDef.class)) {
-            AtlasStructDef structDef = (AtlasStructDef)typeDef;
+        public void addType(AtlasBaseTypeDef typeDef) throws AtlasBaseException {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.addType({})", typeDef);
+            }
 
-            structDefs.removeTypeDefByGuid(guid);
-            structDefs.addType(structDef, new AtlasStructType(structDef, this));
-        } else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
-            AtlasClassificationDef classificationDef = (AtlasClassificationDef)typeDef;
+            if (typeDef != null) {
+                addTypeWithNoRefResolve(typeDef);
 
-            classificationDefs.removeTypeDefByGuid(guid);
-            classificationDefs.addType(classificationDef, new AtlasClassificationType(classificationDef, this));
-        } else if (typeDef.getClass().equals(AtlasEntityDef.class)) {
-            AtlasEntityDef entityDef = (AtlasEntityDef)typeDef;
+                resolveReferences();
+            }
 
-            entityDefs.removeTypeDefByGuid(guid);
-            entityDefs.addType(entityDef, new AtlasEntityType(entityDef, this));
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.addType({})", typeDef);
+            }
         }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.updateTypeByGuid({})", guid);
-        }
-    }
+        public void addTypes(Collection<? extends AtlasBaseTypeDef> typeDefs) throws AtlasBaseException {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.addTypes(length={})", (typeDefs == null ? 0 : typeDefs.size()));
+            }
 
-    public void updateTypeByName(String name, AtlasBaseTypeDef typeDef) throws AtlasBaseException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.updateEnumDefByName({})", name);
+            if (CollectionUtils.isNotEmpty(typeDefs)) {
+                addTypesWithNoRefResolve(typeDefs);
+
+                resolveReferences();
+            }
+
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.addTypes(length={})", (typeDefs == null ? 0 : typeDefs.size()));
+            }
         }
 
-        if (name == null || typeDef == null) {
-            // ignore
-        } else if (typeDef.getClass().equals(AtlasEnumDef.class)) {
-            AtlasEnumDef enumDef = (AtlasEnumDef)typeDef;
+        public void addTypes(AtlasTypesDef typesDef) throws AtlasBaseException {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.addTypes({})", typesDef);
+            }
 
-            enumDefs.removeTypeDefByName(name);
-            enumDefs.addType(enumDef, new AtlasEnumType(enumDef));
-        } else if (typeDef.getClass().equals(AtlasStructDef.class)) {
-            AtlasStructDef structDef = (AtlasStructDef)typeDef;
+            if (typesDef != null) {
+                addTypesWithNoRefResolve(typesDef.getEnumDefs());
+                addTypesWithNoRefResolve(typesDef.getStructDefs());
+                addTypesWithNoRefResolve(typesDef.getClassificationDefs());
+                addTypesWithNoRefResolve(typesDef.getEntityDefs());
 
-            structDefs.removeTypeDefByName(name);
-            structDefs.addType(structDef, new AtlasStructType(structDef, this));
-        } else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
-            AtlasClassificationDef classificationDef = (AtlasClassificationDef)typeDef;
+                resolveReferences();
+            }
+
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.addTypes({})", typesDef);
+            }
+        }
 
-            classificationDefs.removeTypeDefByName(name);
-            classificationDefs.addType(classificationDef, new AtlasClassificationType(classificationDef, this));
-        } else if (typeDef.getClass().equals(AtlasEntityDef.class)) {
-            AtlasEntityDef entityDef = (AtlasEntityDef)typeDef;
+        public void updateType(AtlasBaseTypeDef typeDef) throws AtlasBaseException {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.updateType({})", typeDef);
+            }
+
+            if (typeDef != null) {
+                updateTypeWithNoRefResolve(typeDef);
 
-            entityDefs.removeTypeDefByName(name);
-            entityDefs.addType(entityDef, new AtlasEntityType(entityDef, this));
+                resolveReferences();
+            }
+
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.updateType({})", typeDef);
+            }
         }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.updateEnumDefByName({})", name);
+        public void updateTypeByGuid(String guid, AtlasBaseTypeDef typeDef) throws AtlasBaseException {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.updateTypeByGuid({})", guid);
+            }
+
+            if (guid != null && typeDef != null) {
+                updateTypeByGuidWithNoRefResolve(guid, typeDef);
+
+                resolveReferences();
+            }
+
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.updateTypeByGuid({})", guid);
+            }
         }
-    }
 
-    public void updateTypeByGuidWithNoRefResolve(String guid, AtlasBaseTypeDef typeDef) {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.updateTypeByGuidWithNoRefResolve({})", guid);
+        public void updateTypeByName(String name, AtlasBaseTypeDef typeDef) throws AtlasBaseException {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.updateEnumDefByName({})", name);
+            }
+
+            if (name != null && typeDef != null) {
+                updateTypeByNameWithNoRefResolve(name, typeDef);
+
+                resolveReferences();
+            }
+
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.updateEnumDefByName({})", name);
+            }
         }
 
-        if (guid == null || typeDef == null) {
-            // ignore
-        } else if (typeDef.getClass().equals(AtlasEnumDef.class)) {
-            AtlasEnumDef enumDef = (AtlasEnumDef)typeDef;
+        public void updateTypes(Collection<? extends AtlasBaseTypeDef> typeDefs) throws AtlasBaseException {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.updateTypes(length={})", (typeDefs == null ? 0 : typeDefs.size()));
+            }
 
-            enumDefs.removeTypeDefByGuid(guid);
-            enumDefs.addType(enumDef, new AtlasEnumType(enumDef));
-        } else if (typeDef.getClass().equals(AtlasStructDef.class)) {
-            AtlasStructDef structDef = (AtlasStructDef)typeDef;
+            if (CollectionUtils.isNotEmpty(typeDefs)) {
+                updateTypesWithNoRefResolve(typeDefs);
 
-            structDefs.removeTypeDefByGuid(guid);
-            structDefs.addType(structDef, new AtlasStructType(structDef));
-        } else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
-            AtlasClassificationDef classificationDef = (AtlasClassificationDef)typeDef;
+                resolveReferences();
+            }
 
-            classificationDefs.removeTypeDefByGuid(guid);
-            classificationDefs.addType(classificationDef, new AtlasClassificationType(classificationDef));
-        } else if (typeDef.getClass().equals(AtlasEntityDef.class)) {
-            AtlasEntityDef entityDef = (AtlasEntityDef)typeDef;
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.updateTypes(length={})", (typeDefs == null ? 0 : typeDefs.size()));
+            }
+        }
 
-            entityDefs.removeTypeDefByGuid(guid);
-            entityDefs.addType(entityDef, new AtlasEntityType(entityDef));
+        public void updateTypes(AtlasTypesDef typesDef) throws AtlasBaseException {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.updateTypes({})", typesDef);
+            }
+
+            if (typesDef != null) {
+                updateTypesWithNoRefResolve(typesDef.getEnumDefs());
+                updateTypesWithNoRefResolve(typesDef.getStructDefs());
+                updateTypesWithNoRefResolve(typesDef.getClassificationDefs());
+                updateTypesWithNoRefResolve(typesDef.getEntityDefs());
+
+                resolveReferences();
+            }
+
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.updateTypes({})", typesDef);
+            }
         }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.updateTypeByGuidWithNoRefResolve({})", guid);
+        public void removeTypeByGuid(String guid) throws AtlasBaseException {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.removeTypeByGuid({})", guid);
+            }
+
+            if (guid != null) {
+                registryData.enumDefs.removeTypeDefByGuid(guid);
+                registryData.structDefs.removeTypeDefByGuid(guid);
+                registryData.classificationDefs.removeTypeDefByGuid(guid);
+                registryData.entityDefs.removeTypeDefByGuid(guid);
+
+                resolveReferences();
+            }
+
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.removeTypeByGuid({})", guid);
+            }
         }
-    }
 
-    public void updateTypeByNameWithNoRefResolve(String name, AtlasBaseTypeDef typeDef) {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.updateTypeByNameWithNoRefResolve({})", name);
+        public void removeTypeByName(String name) throws AtlasBaseException {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.removeTypeByName({})", name);
+            }
+
+            if (name != null) {
+                registryData.enumDefs.removeTypeDefByName(name);
+                registryData.structDefs.removeTypeDefByName(name);
+                registryData.classificationDefs.removeTypeDefByName(name);
+                registryData.entityDefs.removeTypeDefByName(name);
+
+                resolveReferences();
+            }
+
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.removeEnumDefByName({})", name);
+            }
         }
 
-        if (name == null || typeDef == null) {
-            // ignore
-        } else if (typeDef.getClass().equals(AtlasEnumDef.class)) {
-            AtlasEnumDef enumDef = (AtlasEnumDef)typeDef;
 
-            enumDefs.removeTypeDefByName(name);
-            enumDefs.addType(enumDef, new AtlasEnumType(enumDef));
-        } else if (typeDef.getClass().equals(AtlasStructDef.class)) {
-            AtlasStructDef structDef = (AtlasStructDef)typeDef;
+        private void addTypeWithNoRefResolve(AtlasBaseTypeDef typeDef) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.addTypeWithNoRefResolve({})", typeDef);
+            }
 
-            structDefs.removeTypeDefByName(name);
-            structDefs.addType(structDef, new AtlasStructType(structDef));
-        } else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
-            AtlasClassificationDef classificationDef = (AtlasClassificationDef)typeDef;
+            if (typeDef != null) {
+                if (StringUtils.isBlank(typeDef.getGuid())) {
+                    typeDef.setGuid(UUID.randomUUID().toString());
+                }
 
-            classificationDefs.removeTypeDefByName(name);
-            classificationDefs.addType(classificationDef, new AtlasClassificationType(classificationDef));
-        } else if (typeDef.getClass().equals(AtlasEntityDef.class)) {
-            AtlasEntityDef entityDef = (AtlasEntityDef)typeDef;
+                if (typeDef.getClass().equals(AtlasEnumDef.class)) {
+                    AtlasEnumDef enumDef = (AtlasEnumDef) typeDef;
 
-            entityDefs.removeTypeDefByName(name);
-            entityDefs.addType(entityDef, new AtlasEntityType(entityDef));
-        }
+                    registryData.enumDefs.addType(enumDef, new AtlasEnumType(enumDef));
+                } else if (typeDef.getClass().equals(AtlasStructDef.class)) {
+                    AtlasStructDef structDef = (AtlasStructDef) typeDef;
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.updateTypeByNameWithNoRefResolve({})", name);
-        }
-    }
+                    registryData.structDefs.addType(structDef, new AtlasStructType(structDef));
+                } else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
+                    AtlasClassificationDef classificationDef = (AtlasClassificationDef) typeDef;
 
-    public void removeTypeByGuid(String guid) {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.removeTypeByGuid({})", guid);
-        }
+                    registryData.classificationDefs.addType(classificationDef,
+                                                            new AtlasClassificationType(classificationDef));
+                } else if (typeDef.getClass().equals(AtlasEntityDef.class)) {
+                    AtlasEntityDef entityDef = (AtlasEntityDef) typeDef;
 
-        if (guid != null) {
-            enumDefs.removeTypeDefByGuid(guid);
-            structDefs.removeTypeDefByGuid(guid);
-            classificationDefs.removeTypeDefByGuid(guid);
-            entityDefs.removeTypeDefByGuid(guid);
-        }
+                    registryData.entityDefs.addType(entityDef, new AtlasEntityType(entityDef));
+                }
+            }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.removeTypeByGuid({})", guid);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.addTypeWithNoRefResolve({})", typeDef);
+            }
         }
-    }
 
-    public void removeTypeByName(String name) {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.removeTypeByName({})", name);
-        }
+        private void addTypesWithNoRefResolve(Collection<? extends AtlasBaseTypeDef> typeDefs) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.addTypesWithNoRefResolve(length={})",
+                          (typeDefs == null ? 0 : typeDefs.size()));
+            }
 
-        if (name != null) {
-            enumDefs.removeTypeDefByName(name);
-            structDefs.removeTypeDefByName(name);
-            classificationDefs.removeTypeDefByName(name);
-            entityDefs.removeTypeDefByName(name);
-        }
+            if (CollectionUtils.isNotEmpty(typeDefs)) {
+                for (AtlasBaseTypeDef typeDef : typeDefs) {
+                    addTypeWithNoRefResolve(typeDef);
+                }
+            }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.removeEnumDefByName({})", name);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.addTypesWithNoRefResolve(length={})",
+                          (typeDefs == null ? 0 : typeDefs.size()));
+            }
         }
-    }
 
-    public void addTypes(Collection<? extends AtlasBaseTypeDef> typeDefs) throws AtlasBaseException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.addTypes(length={})", (typeDefs == null ? 0 : typeDefs.size()));
-        }
+        private void updateTypeWithNoRefResolve(AtlasBaseTypeDef typeDef) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.updateType({})", typeDef);
+            }
 
-        if (CollectionUtils.isNotEmpty(typeDefs)) {
-            for (AtlasBaseTypeDef typeDef : typeDefs) {
-                addType(typeDef);
+            if (typeDef == null) {
+                // ignore
+            } else if (StringUtils.isNotBlank(typeDef.getGuid())) {
+                updateTypeByGuidWithNoRefResolve(typeDef.getGuid(), typeDef);
+            } else if (StringUtils.isNotBlank(typeDef.getName())) {
+                updateTypeByNameWithNoRefResolve(typeDef.getName(), typeDef);
             }
-        }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.addTypes(length={})", (typeDefs == null ? 0 : typeDefs.size()));
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.updateType({})", typeDef);
+            }
         }
-    }
 
-    public void addTypesWithNoRefResolve(Collection<? extends AtlasBaseTypeDef> typeDefs) {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.addTypes(length={})", (typeDefs == null ? 0 : typeDefs.size()));
-        }
+        private void updateTypeByGuidWithNoRefResolve(String guid, AtlasBaseTypeDef typeDef) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.updateTypeByGuidWithNoRefResolve({})", guid);
+            }
 
-        if (CollectionUtils.isNotEmpty(typeDefs)) {
-            for (AtlasBaseTypeDef typeDef : typeDefs) {
-                addTypeWithNoRefResolve(typeDef);
+            if (guid == null || typeDef == null) {
+                // ignore
+            } else if (typeDef.getClass().equals(AtlasEnumDef.class)) {
+                AtlasEnumDef enumDef = (AtlasEnumDef)typeDef;
+
+                registryData.enumDefs.removeTypeDefByGuid(guid);
+                registryData.enumDefs.addType(enumDef, new AtlasEnumType(enumDef));
+            } else if (typeDef.getClass().equals(AtlasStructDef.class)) {
+                AtlasStructDef structDef = (AtlasStructDef)typeDef;
+
+                registryData.structDefs.removeTypeDefByGuid(guid);
+                registryData.structDefs.addType(structDef, new AtlasStructType(structDef));
+            } else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
+                AtlasClassificationDef classificationDef = (AtlasClassificationDef)typeDef;
+
+                registryData.classificationDefs.removeTypeDefByGuid(guid);
+                registryData.classificationDefs.addType(classificationDef,
+                                                        new AtlasClassificationType(classificationDef));
+            } else if (typeDef.getClass().equals(AtlasEntityDef.class)) {
+                AtlasEntityDef entityDef = (AtlasEntityDef)typeDef;
+
+                registryData.entityDefs.removeTypeDefByGuid(guid);
+                registryData.entityDefs.addType(entityDef, new AtlasEntityType(entityDef));
             }
-        }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.addTypes(length={})", (typeDefs == null ? 0 : typeDefs.size()));
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.updateTypeByGuidWithNoRefResolve({})", guid);
+            }
         }
-    }
 
-    public void updateTypes(Collection<? extends AtlasBaseTypeDef> typeDefs) throws AtlasBaseException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.updateTypes(length={})", (typeDefs == null ? 0 : typeDefs.size()));
-        }
+        private void updateTypeByNameWithNoRefResolve(String name, AtlasBaseTypeDef typeDef) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.updateTypeByNameWithNoRefResolve({})", name);
+            }
 
-        if (CollectionUtils.isNotEmpty(typeDefs)) {
-            for (AtlasBaseTypeDef typeDef : typeDefs) {
-                updateType(typeDef);
+            if (name == null || typeDef == null) {
+                // ignore
+            } else if (typeDef.getClass().equals(AtlasEnumDef.class)) {
+                AtlasEnumDef enumDef = (AtlasEnumDef)typeDef;
+
+                registryData.enumDefs.removeTypeDefByName(name);
+                registryData.enumDefs.addType(enumDef, new AtlasEnumType(enumDef));
+            } else if (typeDef.getClass().equals(AtlasStructDef.class)) {
+                AtlasStructDef structDef = (AtlasStructDef)typeDef;
+
+                registryData.structDefs.removeTypeDefByName(name);
+                registryData.structDefs.addType(structDef, new AtlasStructType(structDef));
+            } else if (typeDef.getClass().equals(AtlasClassificationDef.class)) {
+                AtlasClassificationDef classificationDef = (AtlasClassificationDef)typeDef;
+
+                registryData.classificationDefs.removeTypeDefByName(name);
+                registryData.classificationDefs.addType(classificationDef,
+                                                        new AtlasClassificationType(classificationDef));
+            } else if (typeDef.getClass().equals(AtlasEntityDef.class)) {
+                AtlasEntityDef entityDef = (AtlasEntityDef)typeDef;
+
+                registryData.entityDefs.removeTypeDefByName(name);
+                registryData.entityDefs.addType(entityDef, new AtlasEntityType(entityDef));
             }
-        }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.updateTypes(length={})", (typeDefs == null ? 0 : typeDefs.size()));
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.updateTypeByNameWithNoRefResolve({})", name);
+            }
         }
-    }
 
-    public void updateTypesWithNoRefResolve(Collection<? extends AtlasBaseTypeDef> typeDefs) {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("==> AtlasTypeRegistry.updateTypesWithNoRefResolve(length={})", (typeDefs == null ? 0 : typeDefs.size()));
-        }
+        private void updateTypesWithNoRefResolve(Collection<? extends AtlasBaseTypeDef> typeDefs) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("==> AtlasTypeRegistry.updateTypesWithNoRefResolve(length={})",
+                                                                             (typeDefs == null ? 0 : typeDefs.size()));
+            }
 
-        if (CollectionUtils.isNotEmpty(typeDefs)) {
-            for (AtlasBaseTypeDef typeDef : typeDefs) {
-                updateTypeWithNoRefResolve(typeDef);
+            if (CollectionUtils.isNotEmpty(typeDefs)) {
+                for (AtlasBaseTypeDef typeDef : typeDefs) {
+                    updateTypeWithNoRefResolve(typeDef);
+                }
             }
-        }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("<== AtlasTypeRegistry.updateTypesWithNoRefResolve(length={})", (typeDefs == null ? 0 : typeDefs.size()));
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("<== AtlasTypeRegistry.updateTypesWithNoRefResolve(length={})",
+                                                                              (typeDefs == null ? 0 : typeDefs.size()));
+            }
         }
     }
+}
 
+class TypeCache {
+    private final Map<String, AtlasType> typeGuidMap;
+    private final Map<String, AtlasType> typeNameMap;
 
-    public Collection<AtlasEnumDef> getAllEnumDefs() { return enumDefs.getAll(); }
-
-    public AtlasEnumDef getEnumDefByGuid(String guid) {
-        return enumDefs.getTypeDefByGuid(guid);
+    public TypeCache() {
+        typeGuidMap = new ConcurrentHashMap<>();
+        typeNameMap = new ConcurrentHashMap<>();
     }
 
-    public AtlasEnumDef getEnumDefByName(String name) {
-        return enumDefs.getTypeDefByName(name);
+    public TypeCache(TypeCache other) {
+        typeGuidMap = new ConcurrentHashMap<>(other.typeGuidMap);
+        typeNameMap = new ConcurrentHashMap<>(other.typeNameMap);
     }
 
-
-    public Collection<AtlasStructDef> getAllStructDefs() { return structDefs.getAll(); }
-
-    public AtlasStructDef getStructDefByGuid(String guid) {
-        return structDefs.getTypeDefByGuid(guid);
+    public void addType(AtlasType type) {
+        if (type != null) {
+            if (StringUtils.isNotEmpty(type.getTypeName())) {
+                typeNameMap.put(type.getTypeName(), type);
+            }
+        }
     }
 
-    public AtlasStructDef getStructDefByName(String name) { return structDefs.getTypeDefByName(name); }
-
-
-    public Collection<AtlasClassificationDef> getAllClassificationDefs() { return classificationDefs.getAll(); }
+    public void addType(AtlasBaseTypeDef typeDef, AtlasType type) {
+        if (typeDef != null && type != null) {
+            if (StringUtils.isNotEmpty(typeDef.getGuid())) {
+                typeGuidMap.put(typeDef.getGuid(), type);
+            }
 
-    public AtlasClassificationDef getClassificationDefByGuid(String guid) {
-        return classificationDefs.getTypeDefByGuid(guid);
+            if (StringUtils.isNotEmpty(typeDef.getName())) {
+                typeNameMap.put(typeDef.getName(), type);
+            }
+        }
     }
 
-    public AtlasClassificationDef getClassificationDefByName(String name) {
-        return classificationDefs.getTypeDefByName(name);
+    public Collection<String> getAllTypeNames() {
+        return Collections.unmodifiableCollection(typeNameMap.keySet());
     }
 
+    public Collection<AtlasType> getAllTypes() {
+        return Collections.unmodifiableCollection(typeNameMap.values());
+    }
 
-    public Collection<AtlasEntityDef> getAllEntityDefs() { return entityDefs.getAll(); }
+    public AtlasType getTypeByGuid(String guid) {
+        AtlasType ret = guid != null ? typeGuidMap.get(guid) : null;
 
-    public AtlasEntityDef getEntityDefByGuid(String guid) {
-        return entityDefs.getTypeDefByGuid(guid);
+        return ret;
     }
 
-    public AtlasEntityDef getEntityDefByName(String name) {
-        return entityDefs.getTypeDefByName(name);
-    }
+    public AtlasType getTypeByName(String name) {
+        AtlasType ret = name != null ? typeNameMap.get(name) : null;
 
+        return ret;
+    }
 
-    public void resolveReferences() throws AtlasBaseException {
-        for (Map.Entry<String, AtlasType> e : allTypes.entrySet()) {
-            e.getValue().resolveReferences(this);
+    public void removeTypeByGuid(String guid) {
+        if (guid != null) {
+            typeGuidMap.remove(guid);
         }
     }
 
-
-    private void registerType(AtlasType dataType) {
-        allTypes.put(dataType.getTypeName(), dataType);
+    public void removeTypeByName(String name) {
+        if (name != null) {
+            typeNameMap.get(name);
+        }
     }
+}
 
-    private void unregisterType(AtlasType dataType) {
-        allTypes.remove(dataType.getTypeName());
+class TypeDefCache<T extends AtlasBaseTypeDef> {
+    private final TypeCache      typeCache;
+    private final Map<String, T> typeDefGuidMap;
+    private final Map<String, T> typeDefNameMap;
+
+    public TypeDefCache(TypeCache typeCache) {
+        this.typeCache      = typeCache;
+        this.typeDefGuidMap = new ConcurrentHashMap<>();
+        this.typeDefNameMap = new ConcurrentHashMap<>();
     }
 
-    private void unregisterTypeByName(String typeName) {
-        allTypes.remove(typeName);
+    public TypeDefCache(TypeDefCache other, TypeCache typeCache) {
+        this.typeCache      = typeCache;
+        this.typeDefGuidMap = new ConcurrentHashMap<>(other.typeDefGuidMap);
+        this.typeDefNameMap = new ConcurrentHashMap<>(other.typeDefNameMap);
     }
 
+    public void addType(T typeDef, AtlasType type) {
+        if (typeDef != null && type != null) {
+            if (StringUtils.isNotEmpty(typeDef.getGuid())) {
+                typeDefGuidMap.put(typeDef.getGuid(), typeDef);
+            }
 
-    class TypeDefCache<T extends AtlasBaseTypeDef> {
-        private final AtlasTypeRegistry typeRegistry;
-        private final Map<String, T>    typeDefGuidMap = new ConcurrentHashMap<String, T>();
-        private final Map<String, T>    typeDefNameMap = new ConcurrentHashMap<String, T>();
+            if (StringUtils.isNotEmpty(typeDef.getName())) {
+                typeDefNameMap.put(typeDef.getName(), typeDef);
+            }
 
-        public TypeDefCache(AtlasTypeRegistry typeRegistry) {
-            this.typeRegistry = typeRegistry;
+            typeCache.addType(typeDef, type);
         }
+    }
 
-        public void addType(T typeDef, AtlasType type) {
-            if (type != null) {
-                if (StringUtils.isNotEmpty(typeDef.getGuid())) {
-                    typeDefGuidMap.put(typeDef.getGuid(), typeDef);
-                }
-
-                if (StringUtils.isNotEmpty(typeDef.getName())) {
-                    typeDefNameMap.put(typeDef.getName(), typeDef);
-                }
+    public Collection<T> getAll() {
+        return Collections.unmodifiableCollection(typeDefNameMap.values());
+    }
 
-                typeRegistry.registerType(type);
-            }
-        }
+    public T getTypeDefByGuid(String guid) {
+        T ret = guid != null ? typeDefGuidMap.get(guid) : null;
 
-        public Collection<T> getAll() {
-            return Collections.unmodifiableCollection(typeDefNameMap.values());
-        }
+        return ret;
+    }
 
-        public T getTypeDefByGuid(String guid) {
-            T ret = guid != null ? typeDefGuidMap.get(guid) : null;
+    public T getTypeDefByName(String name) {
+        T ret = name != null ? typeDefNameMap.get(name) : null;
 
-            return ret;
-        }
+        return ret;
+    }
 
-        public T getTypeDefByName(String name) {
-            T ret = name != null ? typeDefNameMap.get(name) : null;
+    public void removeTypeDefByGuid(String guid) {
+        if (guid != null) {
+            T typeDef = typeDefGuidMap.remove(guid);
 
-            return ret;
-        }
+            typeCache.removeTypeByGuid(guid);
 
-        public void removeTypeDefByGuid(String guid) {
-            T      typeDef = guid != null ? typeDefGuidMap.remove(guid) : null;
-            String name    = typeDef != null ? typeDef.getName() : null;
+            String name = typeDef != null ? typeDef.getName() : null;
 
             if (name != null) {
                 typeDefNameMap.remove(name);
-                typeRegistry.unregisterTypeByName(name);
+                typeCache.removeTypeByName(name);
             }
+
         }
+    }
+
+    public void removeTypeDefByName(String name) {
+        if (name != null) {
+            T typeDef = typeDefNameMap.remove(name);
+
+            typeCache.removeTypeByName(name);
 
-        public void removeTypeDefByName(String name) {
-            T      typeDef = name != null ? typeDefNameMap.get(name) : null;
-            String guid    = typeDef != null ? typeDef.getGuid() : null;
+            String guid = typeDef != null ? typeDef.getGuid() : null;
 
             if (guid != null) {
                 typeDefGuidMap.remove(guid);
-            }
-
-            if (name != null) {
-                typeRegistry.unregisterTypeByName(name);
+                typeCache.removeTypeByGuid(guid);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/intg/src/test/java/org/apache/atlas/model/ModelTestUtil.java
----------------------------------------------------------------------
diff --git a/intg/src/test/java/org/apache/atlas/model/ModelTestUtil.java b/intg/src/test/java/org/apache/atlas/model/ModelTestUtil.java
index e2db68e..c0bb1f2 100644
--- a/intg/src/test/java/org/apache/atlas/model/ModelTestUtil.java
+++ b/intg/src/test/java/org/apache/atlas/model/ModelTestUtil.java
@@ -41,6 +41,7 @@ import org.apache.atlas.type.AtlasClassificationType;
 import org.apache.atlas.type.AtlasEntityType;
 import org.apache.atlas.type.AtlasStructType;
 import org.apache.atlas.type.AtlasTypeRegistry;
+import org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -158,7 +159,11 @@ public final class  ModelTestUtil {
         }
 
         try {
-            typesRegistry.addType(ret);
+            AtlasTransientTypeRegistry ttr = typesRegistry.createTransientTypeRegistry();
+
+            ttr.addType(ret);
+
+            typesRegistry.commitTransientTypeRegistry(ttr);
         } catch (AtlasBaseException excp) {
             LOG.error("failed to create enum-def", excp);
 
@@ -182,7 +187,11 @@ public final class  ModelTestUtil {
         ret.setAttributeDefs(newAttributeDefsWithAllBuiltInTypes(PREFIX_ATTRIBUTE_NAME));
 
         try {
-            typesRegistry.addType(ret);
+            AtlasTransientTypeRegistry ttr = typesRegistry.createTransientTypeRegistry();
+
+            ttr.addType(ret);
+
+            typesRegistry.commitTransientTypeRegistry(ttr);
         } catch (AtlasBaseException excp) {
             LOG.error("failed to create struct-def", excp);
 
@@ -220,7 +229,11 @@ public final class  ModelTestUtil {
         }
 
         try {
-            typesRegistry.addType(ret);
+            AtlasTransientTypeRegistry ttr = typesRegistry.createTransientTypeRegistry();
+
+            ttr.addType(ret);
+
+            typesRegistry.commitTransientTypeRegistry(ttr);
         } catch (AtlasBaseException excp) {
             LOG.error("failed to create entity-def", excp);
 
@@ -267,7 +280,11 @@ public final class  ModelTestUtil {
         }
 
         try {
-            typesRegistry.addType(ret);
+            AtlasTransientTypeRegistry ttr = typesRegistry.createTransientTypeRegistry();
+
+            ttr.addType(ret);
+
+            typesRegistry.commitTransientTypeRegistry(ttr);
         } catch (AtlasBaseException excp) {
             LOG.error("failed to create classification-def", excp);
 
@@ -285,10 +302,14 @@ public final class  ModelTestUtil {
     public static AtlasEntity newEntity(AtlasEntityDef entityDef, AtlasTypeRegistry typesRegistry) {
         AtlasEntity ret = null;
 
-        AtlasType dataType = typesRegistry.getType(entityDef.getName());
+        try {
+            AtlasType dataType = typesRegistry.getType(entityDef.getName());
 
-        if (dataType != null && dataType instanceof AtlasEntityType) {
-            ret = ((AtlasEntityType)dataType).createDefaultValue();
+            if (dataType instanceof AtlasEntityType) {
+                ret = ((AtlasEntityType) dataType).createDefaultValue();
+            }
+        } catch (AtlasBaseException excp) {
+            LOG.error("failed to get entity-type " + entityDef.getName(), excp);
         }
 
         return ret;
@@ -301,10 +322,14 @@ public final class  ModelTestUtil {
     public static AtlasStruct newStruct(AtlasStructDef structDef, AtlasTypeRegistry typesRegistry) {
         AtlasStruct ret = null;
 
-        AtlasType dataType = typesRegistry.getType(structDef.getName());
+        try {
+            AtlasType dataType = typesRegistry.getType(structDef.getName());
 
-        if (dataType != null && dataType instanceof AtlasStructType) {
-            ret = ((AtlasStructType)dataType).createDefaultValue();
+            if (dataType instanceof AtlasStructType) {
+                ret = ((AtlasStructType)dataType).createDefaultValue();
+            }
+        } catch (AtlasBaseException excp) {
+            LOG.error("failed to get struct-type " + structDef.getName(), excp);
         }
 
         return ret;
@@ -318,10 +343,14 @@ public final class  ModelTestUtil {
                                                         AtlasTypeRegistry typesRegistry) {
         AtlasClassification ret = null;
 
-        AtlasType dataType = typesRegistry.getType(classificationDef.getName());
+        try {
+            AtlasType dataType = typesRegistry.getType(classificationDef.getName());
 
-        if (dataType != null && dataType instanceof AtlasClassificationType) {
-            ret = ((AtlasClassificationType)dataType).createDefaultValue();
+            if (dataType instanceof AtlasClassificationType) {
+                ret = ((AtlasClassificationType)dataType).createDefaultValue();
+            }
+        } catch (AtlasBaseException excp) {
+            LOG.error("failed to get classification-type " + classificationDef.getName(), excp);
         }
 
         return ret;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/intg/src/test/java/org/apache/atlas/model/instance/TestAtlasClassification.java
----------------------------------------------------------------------
diff --git a/intg/src/test/java/org/apache/atlas/model/instance/TestAtlasClassification.java b/intg/src/test/java/org/apache/atlas/model/instance/TestAtlasClassification.java
index 577dccf..6dc72ee 100644
--- a/intg/src/test/java/org/apache/atlas/model/instance/TestAtlasClassification.java
+++ b/intg/src/test/java/org/apache/atlas/model/instance/TestAtlasClassification.java
@@ -17,6 +17,7 @@
  */
 package org.apache.atlas.model.instance;
 
+import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.ModelTestUtil;
 import org.apache.atlas.model.typedef.AtlasClassificationDef;
 import org.apache.atlas.type.AtlasType;
@@ -31,7 +32,7 @@ import static org.testng.Assert.assertTrue;
 public class TestAtlasClassification {
 
     @Test
-    public void testClassificationSerDe() {
+    public void testClassificationSerDe() throws AtlasBaseException {
         AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDef();
         AtlasTypeRegistry      typeRegistry      = ModelTestUtil.getTypesRegistry();
         AtlasType              dataType          = typeRegistry.getType(classificationDef.getName());
@@ -50,7 +51,7 @@ public class TestAtlasClassification {
     }
 
     @Test
-    public void testClassificationSerDeWithSuperType() {
+    public void testClassificationSerDeWithSuperType() throws AtlasBaseException {
         AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDefWithSuperType();
         AtlasTypeRegistry      typeRegistry      = ModelTestUtil.getTypesRegistry();
         AtlasType              dataType          = typeRegistry.getType(classificationDef.getName());
@@ -69,7 +70,7 @@ public class TestAtlasClassification {
     }
 
     @Test
-    public void testClassificationSerDeWithSuperTypes() {
+    public void testClassificationSerDeWithSuperTypes() throws AtlasBaseException {
         AtlasClassificationDef classificationDef = ModelTestUtil.getClassificationDefWithSuperTypes();
         AtlasTypeRegistry      typeRegistry      = ModelTestUtil.getTypesRegistry();
         AtlasType              dataType          = typeRegistry.getType(classificationDef.getName());

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/intg/src/test/java/org/apache/atlas/model/instance/TestAtlasEntity.java
----------------------------------------------------------------------
diff --git a/intg/src/test/java/org/apache/atlas/model/instance/TestAtlasEntity.java b/intg/src/test/java/org/apache/atlas/model/instance/TestAtlasEntity.java
index fbf1cc7..efcf1cf 100644
--- a/intg/src/test/java/org/apache/atlas/model/instance/TestAtlasEntity.java
+++ b/intg/src/test/java/org/apache/atlas/model/instance/TestAtlasEntity.java
@@ -17,6 +17,7 @@
  */
 package org.apache.atlas.model.instance;
 
+import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.ModelTestUtil;
 import org.apache.atlas.model.typedef.AtlasEntityDef;
 import org.apache.atlas.type.AtlasType;
@@ -31,7 +32,7 @@ import static org.testng.Assert.assertTrue;
 public class TestAtlasEntity {
 
     @Test
-    public void testEntitySerDe() {
+    public void testEntitySerDe() throws AtlasBaseException {
         AtlasEntityDef    entityDef    = ModelTestUtil.getEntityDef();
         AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry();
         AtlasType         dataType     = typeRegistry.getType(entityDef.getName());
@@ -50,7 +51,7 @@ public class TestAtlasEntity {
     }
 
     @Test
-    public void testEntitySerDeWithSuperType() {
+    public void testEntitySerDeWithSuperType() throws AtlasBaseException {
         AtlasEntityDef    entityDef    = ModelTestUtil.getEntityDefWithSuperType();
         AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry();
         AtlasType         dataType     = typeRegistry.getType(entityDef.getName());
@@ -69,7 +70,7 @@ public class TestAtlasEntity {
     }
 
     @Test
-    public void testEntitySerDeWithSuperTypes() {
+    public void testEntitySerDeWithSuperTypes() throws AtlasBaseException {
         AtlasEntityDef    entityDef    = ModelTestUtil.getEntityDefWithSuperTypes();
         AtlasTypeRegistry typeRegistry = ModelTestUtil.getTypesRegistry();
         AtlasType         dataType     = typeRegistry.getType(entityDef.getName());

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/intg/src/test/java/org/apache/atlas/model/typedef/TestAtlasEntityDef.java
----------------------------------------------------------------------
diff --git a/intg/src/test/java/org/apache/atlas/model/typedef/TestAtlasEntityDef.java b/intg/src/test/java/org/apache/atlas/model/typedef/TestAtlasEntityDef.java
index f3b12ef..b8cc77c 100644
--- a/intg/src/test/java/org/apache/atlas/model/typedef/TestAtlasEntityDef.java
+++ b/intg/src/test/java/org/apache/atlas/model/typedef/TestAtlasEntityDef.java
@@ -84,10 +84,12 @@ public class TestAtlasEntityDef {
         entityDef.addSuperType(newSuperType);
 
         assertTrue(entityDef.hasSuperType(newSuperType));
+
+        entityDef.removeSuperType(newSuperType);
     }
 
     @Test
-    public void testEntityDefDefRemoveElement() {
+    public void testEntityDefRemoveElement() {
         AtlasEntityDef entityDef = ModelTestUtil.newEntityDefWithSuperTypes();
 
         for (String superType : entityDef.getSuperTypes()) {
@@ -114,6 +116,9 @@ public class TestAtlasEntityDef {
         for (String superType : newSuperTypes) {
             assertTrue(entityDef.hasSuperType(superType));
         }
+
+        // restore old sypertypes
+        entityDef.setSuperTypes(oldSuperTypes);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/intg/src/test/java/org/apache/atlas/type/TestAtlasEntityType.java
----------------------------------------------------------------------
diff --git a/intg/src/test/java/org/apache/atlas/type/TestAtlasEntityType.java b/intg/src/test/java/org/apache/atlas/type/TestAtlasEntityType.java
index ec893a0..90fea9f 100644
--- a/intg/src/test/java/org/apache/atlas/type/TestAtlasEntityType.java
+++ b/intg/src/test/java/org/apache/atlas/type/TestAtlasEntityType.java
@@ -17,7 +17,11 @@
  */
 package org.apache.atlas.type;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.atlas.exception.AtlasBaseException;
 import org.apache.atlas.model.ModelTestUtil;
@@ -26,6 +30,7 @@ import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
 import org.apache.atlas.model.typedef.AtlasEntityDef;
 import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
 import org.apache.atlas.model.typedef.AtlasStructDef.AtlasConstraintDef;
+import org.apache.atlas.type.AtlasTypeRegistry.AtlasTransientTypeRegistry;
 import org.testng.annotations.Test;
 
 import static org.testng.Assert.*;
@@ -127,8 +132,11 @@ public class TestAtlasEntityType {
         entityDefs.add(createColumnEntityDef());
 
         try {
-            typeRegistry.addTypesWithNoRefResolve(entityDefs);
-            typeRegistry.resolveReferences();
+            AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+            ttr.addTypes(entityDefs);
+
+            typeRegistry.commitTransientTypeRegistry(ttr);
         } catch (AtlasBaseException excp) {
             failureMsg = excp.getMessage();
         }
@@ -144,7 +152,11 @@ public class TestAtlasEntityType {
         entityDefs.add(createTableEntityDef());
 
         try {
-            typeRegistry.addTypes(entityDefs);
+            AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+            ttr.addTypes(entityDefs);
+
+            typeRegistry.commitTransientTypeRegistry(ttr);
         } catch (AtlasBaseException excp) {
             failureMsg = excp.getMessage();
         }
@@ -161,8 +173,11 @@ public class TestAtlasEntityType {
         entityDefs.add(createColumnEntityDef());
 
         try {
-            typeRegistry.addTypesWithNoRefResolve(entityDefs);
-            typeRegistry.resolveReferences();
+            AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+            ttr.addTypes(entityDefs);
+
+            typeRegistry.commitTransientTypeRegistry(ttr);
         } catch (AtlasBaseException excp) {
             failureMsg = excp.getMessage();
         }
@@ -178,7 +193,11 @@ public class TestAtlasEntityType {
         entityDefs.add(createColumnEntityDef());
 
         try {
-            typeRegistry.addTypes(entityDefs);
+            AtlasTransientTypeRegistry ttr = typeRegistry.createTransientTypeRegistry();
+
+            ttr.addTypes(entityDefs);
+
+            typeRegistry.commitTransientTypeRegistry(ttr);
         } catch (AtlasBaseException excp) {
             failureMsg = excp.getMessage();
         }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/eb6e656b/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 0792d46..d2b848b 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
 ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
 
 ALL CHANGES:
+ATLAS-1230 updated AtlasTypeRegistry to support batch, atomic type updates (mneethiraj)
 ATLAS-1229 Add TypeCategory and methods to access attribute definitiions in AtlasTypes (sumasai)
 ATLAS-1227 Added support for attribute constraints in the API (mneethiraj)
 ATLAS-1225 Optimize AtlasTypeDefGraphStore to use typeRegistry (mneethiraj via sumasai)