This is an automated email from the ASF dual-hosted git repository. madhan pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new 2f1d206 ATLAS-3709: fix to address skipped index initialization in earlier commit - #2 2f1d206 is described below commit 2f1d206351be9a9648136590c7b736292fdd3f18 Author: Madhan Neethiraj <mad...@apache.org> AuthorDate: Wed Apr 15 08:52:44 2020 -0700 ATLAS-3709: fix to address skipped index initialization in earlier commit - #2 Change-Id: I9152792cfb5dd66fc29bd1691268219fb64c13b5 (cherry picked from commit 490e37ec35fe6671396029a40a006a0be521eaf8) --- .../atlas/repository/graph/GraphBackedSearchIndexer.java | 15 +++++++-------- .../apache/atlas/repository/graph/SolrIndexHelper.java | 10 ++++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java index 8289069..21d467f 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedSearchIndexer.java @@ -31,7 +31,6 @@ import org.apache.atlas.listener.ChangedTypeDefs; import org.apache.atlas.listener.TypeDefChangeListener; import org.apache.atlas.model.TypeCategory; 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.AtlasStructDef; import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef; @@ -209,18 +208,18 @@ public class GraphBackedSearchIndexer implements SearchIndexer, ActiveStateChang 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; try { management = provider.get().getManagementSystem(); - //resolve index fields names for the new entity attributes. - 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); + //resolve index fields names resolveIndexFieldNames(management, changedTypeDefs); //Commit indexes diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/SolrIndexHelper.java b/repository/src/main/java/org/apache/atlas/repository/graph/SolrIndexHelper.java index 0670d50..401bc02 100644 --- a/repository/src/main/java/org/apache/atlas/repository/graph/SolrIndexHelper.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/SolrIndexHelper.java @@ -68,10 +68,16 @@ public class SolrIndexHelper implements IndexChangeListener { @Override public void onChange(ChangedTypeDefs changedTypeDefs) { - if (!AtlasRepositoryConfiguration.isFreeTextSearchEnabled() || - changedTypeDefs == null || !(changedTypeDefs.hasEntityDef() || changedTypeDefs.hasBusinessMetadataDef())) { // nothing to do if there are no changes to entity-defs + if (!AtlasRepositoryConfiguration.isFreeTextSearchEnabled()) { 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) { try { AtlasGraph graph = AtlasGraphProvider.getGraphInstance();