ATLAS-1675: type-registry re-initialization failure when instance goes from 
passive to active state


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

Branch: refs/heads/master
Commit: 1cc40fd9eff4827aa4507e78b274829511a2acb7
Parents: a127e26
Author: Madhan Neethiraj <[email protected]>
Authored: Tue Mar 21 01:39:30 2017 -0700
Committer: Madhan Neethiraj <[email protected]>
Committed: Tue Mar 21 01:39:30 2017 -0700

----------------------------------------------------------------------
 .../apache/atlas/type/AtlasTypeRegistry.java    | 31 ++++++++++++++++++++
 .../store/graph/AtlasTypeDefGraphStore.java     |  2 ++
 2 files changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1cc40fd9/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 ddb6c71..d40eb51 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java
@@ -231,6 +231,10 @@ public class AtlasTypeRegistry {
             entityDefs         = new TypeDefCache<>(allTypes);
             allDefCaches       = new TypeDefCache[] { enumDefs, structDefs, 
classificationDefs, entityDefs };
 
+            init();
+        }
+
+        void init() {
             allTypes.addType(new AtlasBuiltInTypes.AtlasBooleanType());
             allTypes.addType(new AtlasBuiltInTypes.AtlasByteType());
             allTypes.addType(new AtlasBuiltInTypes.AtlasShortType());
@@ -303,6 +307,16 @@ public class AtlasTypeRegistry {
                 entityDefs.removeTypeDefByName(typeName);
             }
         }
+
+        void clear() {
+            allTypes.clear();
+            enumDefs.clear();
+            structDefs.clear();
+            classificationDefs.clear();
+            entityDefs.clear();
+
+            init();
+        }
     }
 
     public static class AtlasTransientTypeRegistry extends AtlasTypeRegistry {
@@ -334,6 +348,10 @@ public class AtlasTypeRegistry {
             }
         }
 
+        public void clear() {
+            registryData.clear();
+        }
+
         public void addType(AtlasBaseTypeDef typeDef) throws 
AtlasBaseException {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("==> AtlasTypeRegistry.addType({})", typeDef);
@@ -863,10 +881,16 @@ class TypeCache {
             typeNameMap.get(name);
         }
     }
+
+    public void clear() {
+        typeGuidMap.clear();
+        typeNameMap.clear();
+    }
 }
 
 class TypeDefCache<T1 extends AtlasBaseTypeDef, T2 extends AtlasType> {
     private static final Logger LOG = 
LoggerFactory.getLogger(TypeDefCache.class);
+
     private final TypeCache       typeCache;
     private final Map<String, T1> typeDefGuidMap;
     private final Map<String, T1> typeDefNameMap;
@@ -985,4 +1009,11 @@ class TypeDefCache<T1 extends AtlasBaseTypeDef, T2 
extends AtlasType> {
             }
         }
     }
+
+    public void clear() {
+        typeCache.clear();
+        typeDefGuidMap.clear();
+        typeDefNameMap.clear();
+        typeNameMap.clear();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/1cc40fd9/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 c3b6d20..2f43e9b 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
@@ -93,6 +93,8 @@ public abstract class AtlasTypeDefGraphStore implements 
AtlasTypeDefStore, Activ
         try {
             ttr = 
typeRegistry.lockTypeRegistryForUpdate(typeUpdateLockMaxWaitTimeSeconds);
 
+            ttr.clear();
+
             AtlasTypesDef typesDef = new 
AtlasTypesDef(getEnumDefStore(ttr).getAll(),
                     getStructDefStore(ttr).getAll(),
                     getClassificationDefStore(ttr).getAll(),

Reply via email to