Commit 1cc40fd9 by Madhan Neethiraj

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

parent a127e26b
......@@ -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();
}
}
......@@ -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(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment