Commit 490e37ec by Madhan Neethiraj

ATLAS-3709: fix to address skipped index initialization in earlier commit - #2

Change-Id: I9152792cfb5dd66fc29bd1691268219fb64c13b5
parent eef89a77
...@@ -31,7 +31,6 @@ import org.apache.atlas.listener.ChangedTypeDefs; ...@@ -31,7 +31,6 @@ import org.apache.atlas.listener.ChangedTypeDefs;
import org.apache.atlas.listener.TypeDefChangeListener; import org.apache.atlas.listener.TypeDefChangeListener;
import org.apache.atlas.model.TypeCategory; import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef; import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.model.typedef.AtlasEntityDef;
import org.apache.atlas.model.typedef.AtlasEnumDef; import org.apache.atlas.model.typedef.AtlasEnumDef;
import org.apache.atlas.model.typedef.AtlasStructDef; import org.apache.atlas.model.typedef.AtlasStructDef;
import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
...@@ -209,18 +208,18 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang ...@@ -209,18 +208,18 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang
LOG.debug("Type definition load completed. Informing the completion to IndexChangeListeners."); LOG.debug("Type definition load completed. Informing the completion to IndexChangeListeners.");
} }
ChangedTypeDefs changedTypeDefs = null; Collection<AtlasBaseTypeDef> typeDefs = new ArrayList<>();
typeDefs.addAll(typeRegistry.getAllEntityDefs());
typeDefs.addAll(typeRegistry.getAllBusinessMetadataDefs());
ChangedTypeDefs changedTypeDefs = new ChangedTypeDefs(null, new ArrayList<>(typeDefs), null);
AtlasGraphManagement management = null; AtlasGraphManagement management = null;
try { try {
management = provider.get().getManagementSystem(); management = provider.get().getManagementSystem();
//resolve index fields names for the new entity attributes. //resolve index fields names
changedTypeDefs = new ChangedTypeDefs(null, new ArrayList<>(typeRegistry.getAllEntityDefs()), null);
resolveIndexFieldNames(management, changedTypeDefs);
//resolve index fields names for the new business metadata attributes.
changedTypeDefs = new ChangedTypeDefs(null, new ArrayList<>(typeRegistry.getAllBusinessMetadataDefs()), null);
resolveIndexFieldNames(management, changedTypeDefs); resolveIndexFieldNames(management, changedTypeDefs);
//Commit indexes //Commit indexes
......
...@@ -68,10 +68,16 @@ public class SolrIndexHelper implements IndexChangeListener { ...@@ -68,10 +68,16 @@ public class SolrIndexHelper implements IndexChangeListener {
@Override @Override
public void onChange(ChangedTypeDefs changedTypeDefs) { public void onChange(ChangedTypeDefs changedTypeDefs) {
if (!AtlasRepositoryConfiguration.isFreeTextSearchEnabled() || if (!AtlasRepositoryConfiguration.isFreeTextSearchEnabled()) {
changedTypeDefs == null || !(changedTypeDefs.hasEntityDef() || changedTypeDefs.hasBusinessMetadataDef())) { // nothing to do if there are no changes to entity-defs
return; return;
} }
if (changedTypeDefs == null || !(changedTypeDefs.hasEntityDef() || changedTypeDefs.hasBusinessMetadataDef())) {
LOG.info("SolrIndexHelper.onChange(): no change in entity/business-metadata types. No updates needed.");
return;
}
if(initializationCompleted) { if(initializationCompleted) {
try { try {
AtlasGraph graph = AtlasGraphProvider.getGraphInstance(); AtlasGraph graph = AtlasGraphProvider.getGraphInstance();
......
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