Package com.flowable.indexing
Class IndexManagerImpl
- java.lang.Object
-
- com.flowable.indexing.IndexManagerImpl
-
- All Implemented Interfaces:
IndexManager,java.util.EventListener,org.springframework.beans.factory.Aware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>,org.springframework.core.Ordered
public class IndexManagerImpl extends java.lang.Object implements IndexManager, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>, org.springframework.context.ApplicationContextAware, org.springframework.core.Ordered, org.springframework.beans.factory.InitializingBean
-
-
Field Summary
Fields Modifier and Type Field Description protected org.springframework.context.ApplicationContextapplicationContextprotected java.util.List<CustomIndexConfiguration>customConfigurationsprotected java.util.Map<java.lang.String,IndexMapping>customMappingsstatic intDEFAULT_ORDERprotected ElasticsearchClientelasticsearchClientprotected static java.lang.StringFULL_TEXT_VARIABLES_FIELDprotected static java.time.format.DateTimeFormatterINDEX_SUFFIX_FORMATprotected java.util.Map<java.lang.String,CustomIndexConfiguration>indexedDocumentTypesprotected java.util.Map<java.lang.String,IndexMapping>indexMappingsprotected java.lang.StringindexNamePrefixprotected IndexTemplateComposerindexTemplateComposerprotected java.util.List<java.lang.String>indicesprotected java.util.function.Function<java.lang.String,org.flowable.common.engine.impl.lock.LockManager>lockManagerProviderprotected org.springframework.core.io.Resource[]mappingExtensionResourcesprotected org.springframework.core.io.Resource[]mappingResourcesprotected java.time.DurationmappingSchemaLockWaitTimeprotected static intMINIMAL_COMPATIBLE_ES_VERSIONprotected com.fasterxml.jackson.databind.ObjectMapperobjectMapperprotected intorderprotected static java.lang.StringPROPERTIES_FIELDprotected static java.lang.StringSETTINGS_FIELDprotected booleanuseLockForIndexMappingCreationprotected static java.lang.StringVARIABLE_EXTRACTORS_FIELDprotected static java.lang.StringVARIABLE_PROPERTIES_FIELD
-
Constructor Summary
Constructors Constructor Description IndexManagerImpl(ElasticsearchClient elasticsearchClient, java.util.function.Function<java.lang.String,org.flowable.common.engine.impl.lock.LockManager> lockManagerProvider, java.lang.String indexNamePrefix, java.lang.String projectName, org.springframework.core.io.Resource[] mappingResources, org.springframework.core.io.Resource[] mappingExtensionResources, IndexTemplateComposer indexTemplateComposer, com.fasterxml.jackson.databind.ObjectMapper objectMapper)IndexManagerImpl(ElasticsearchClient elasticsearchClient, java.util.function.Function<java.lang.String,org.flowable.common.engine.impl.lock.LockManager> lockManagerProvider, java.lang.String indexNamePrefix, java.lang.String projectName, org.springframework.core.io.Resource[] mappingResources, org.springframework.core.io.Resource[] mappingExtensionResources, IndexTemplateComposer indexTemplateComposer, com.fasterxml.jackson.databind.ObjectMapper objectMapper, boolean useLockForIndexMappingCreation, java.time.Duration mappingSchemaLockWaitTime)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()protected booleancompareExtensionMetadata(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping)protected voidcreateCustomAlias(java.lang.String alias, java.lang.String indexMapping)protected java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>>createCustomAliasesFromMappings(java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode> indexMetaData)protected voidcreateCustomMappings()com.fasterxml.jackson.databind.JsonNodecreateIndexAndAlias(java.lang.String alias, java.lang.String indexMapping)voidcreateIndexesAndCustomAliasesFromMappings()java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode>createIndexesFromMappings()Creates the indices for all known mappingscom.fasterxml.jackson.databind.JsonNodecreateIndexWithAlias(java.lang.String indexName)Creates an index.java.lang.StringcreateIndexWithoutAlias(java.lang.String indexName)Similar toIndexManager.createIndexWithAlias(String), but doesn't create an alias, only the index with the mapping.voiddeleteAliasAndRelatedIndices(java.lang.String indexName)Deletes the given index and all its aliases.voiddeleteAllKnownIndices()Deletes all indices registered in the systemvoiddeleteIndex(java.lang.String indexName)Deletes the index with the given name.protected java.lang.StringenhanceIndexName(java.lang.String indexName)protected voidenhanceMappingWithExtension(java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, java.lang.String indexName)protected voidenhanceProperties(java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, java.lang.String indexName)protected voidenhanceSettings(java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, java.lang.String indexName)protected voidenhanceVariableProperties(java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, java.lang.String indexName)IndexMappingfindIndexMapping(java.lang.String indexName)java.util.List<IndexMapping>findMatchingCustomMappings(java.lang.String indexName)Returns a list ofIndexMapping(s) that are applicable for the provided index name.java.util.List<IndexMapping>findMatchingIndexMappings(com.fasterxml.jackson.databind.node.ObjectNode objectNode)Returns a list ofIndexMappinginstances that are applicable for the provided data.java.util.List<IndexMapping>findMatchingIndexMappings(java.lang.String mappingType)Returns a list ofIndexMapping(s) that are applicable for the provided mapping type.IndexMappinggetCustomQueryMapping(java.lang.String indexName, java.lang.String mappingName)Get custom query mapping for given index if exists.java.lang.StringgetESIndexName(java.lang.String indexName)Returns the internal index name for the provided raw index name.CustomIndexConfigurationgetIndexConfiguration(java.lang.String indexName)Returns the mapping information for the given index.java.lang.StringgetIndexNamePrefix()Returns the prefix that is added to all indices.java.util.function.Function<java.lang.String,org.flowable.common.engine.impl.lock.LockManager>getLockManagerProvider()protected com.fasterxml.jackson.databind.node.ObjectNodegetMappingDelta(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping, java.lang.String currentType)org.springframework.core.io.Resource[]getMappingExtensionResources()org.springframework.core.io.Resource[]getMappingResources()intgetOrder()booleanisKnownIndex(java.lang.String index)Returns whether the index is a known mapped index.protected voidlogElasticsearchVersionInformation()voidonApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)protected java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>>processMappingExtensionResources()protected voidprocessMappingResources(java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations)protected voidprocessResources()protected voidprocessVariableMappings(CustomIndexMapping indexMapping, com.fasterxml.jackson.databind.JsonNode jsonNode)IndexMappingrecreateMapping(IndexMapping indexMapping)Used to recreate mapping ifCustomIndexConfigurationchanged.booleanreloadIndex(java.lang.String indexName)Reloads selected indexbooleanreloadIndices()Reloads all indexesvoidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)voidsetIndexNamePrefix(java.lang.String indexNamePrefix)voidsetLockManagerProvider(java.util.function.Function<java.lang.String,org.flowable.common.engine.impl.lock.LockManager> lockManagerProvider)voidsetMappingExtensionResources(org.springframework.core.io.Resource[] mappingExtensionResources)voidsetMappingResources(org.springframework.core.io.Resource[] mappingResources)voidsetOrder(int order)protected voidupdateExistingAliasMapping(IndexMapping customMapping)protected com.fasterxml.jackson.databind.JsonNodeupdateExistingMappingIfNeeded(java.lang.String indexName, IndexMapping indexMapping)protected voidupdateIndexAndMappingMetaData(java.lang.String index, com.fasterxml.jackson.databind.JsonNode metaData)protected voidupdateIndexMetaData(java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode> indicesMetaData, java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> aliasesMetaData)protected booleanvalidateMappingExtensionJson(org.springframework.core.io.Resource mappingExtensionResource, com.fasterxml.jackson.databind.JsonNode mappingExtensionJson)
-
-
-
Field Detail
-
DEFAULT_ORDER
public static final int DEFAULT_ORDER
- See Also:
- Constant Field Values
-
INDEX_SUFFIX_FORMAT
protected static final java.time.format.DateTimeFormatter INDEX_SUFFIX_FORMAT
-
MINIMAL_COMPATIBLE_ES_VERSION
protected static int MINIMAL_COMPATIBLE_ES_VERSION
-
PROPERTIES_FIELD
protected static final java.lang.String PROPERTIES_FIELD
- See Also:
- Constant Field Values
-
SETTINGS_FIELD
protected static final java.lang.String SETTINGS_FIELD
- See Also:
- Constant Field Values
-
VARIABLE_PROPERTIES_FIELD
protected static final java.lang.String VARIABLE_PROPERTIES_FIELD
- See Also:
- Constant Field Values
-
VARIABLE_EXTRACTORS_FIELD
protected static final java.lang.String VARIABLE_EXTRACTORS_FIELD
- See Also:
- Constant Field Values
-
FULL_TEXT_VARIABLES_FIELD
protected static final java.lang.String FULL_TEXT_VARIABLES_FIELD
- See Also:
- Constant Field Values
-
elasticsearchClient
protected ElasticsearchClient elasticsearchClient
-
lockManagerProvider
protected java.util.function.Function<java.lang.String,org.flowable.common.engine.impl.lock.LockManager> lockManagerProvider
-
mappingResources
protected org.springframework.core.io.Resource[] mappingResources
-
mappingExtensionResources
protected org.springframework.core.io.Resource[] mappingExtensionResources
-
indexTemplateComposer
protected IndexTemplateComposer indexTemplateComposer
-
objectMapper
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
indexNamePrefix
protected java.lang.String indexNamePrefix
-
useLockForIndexMappingCreation
protected boolean useLockForIndexMappingCreation
-
mappingSchemaLockWaitTime
protected java.time.Duration mappingSchemaLockWaitTime
-
indexMappings
protected java.util.Map<java.lang.String,IndexMapping> indexMappings
-
customMappings
protected java.util.Map<java.lang.String,IndexMapping> customMappings
-
customConfigurations
protected java.util.List<CustomIndexConfiguration> customConfigurations
-
indices
protected java.util.List<java.lang.String> indices
-
indexedDocumentTypes
protected java.util.Map<java.lang.String,CustomIndexConfiguration> indexedDocumentTypes
-
applicationContext
protected org.springframework.context.ApplicationContext applicationContext
-
order
protected int order
-
-
Constructor Detail
-
IndexManagerImpl
public IndexManagerImpl(ElasticsearchClient elasticsearchClient, java.util.function.Function<java.lang.String,org.flowable.common.engine.impl.lock.LockManager> lockManagerProvider, java.lang.String indexNamePrefix, java.lang.String projectName, org.springframework.core.io.Resource[] mappingResources, org.springframework.core.io.Resource[] mappingExtensionResources, IndexTemplateComposer indexTemplateComposer, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
IndexManagerImpl
public IndexManagerImpl(ElasticsearchClient elasticsearchClient, java.util.function.Function<java.lang.String,org.flowable.common.engine.impl.lock.LockManager> lockManagerProvider, java.lang.String indexNamePrefix, java.lang.String projectName, org.springframework.core.io.Resource[] mappingResources, org.springframework.core.io.Resource[] mappingExtensionResources, IndexTemplateComposer indexTemplateComposer, com.fasterxml.jackson.databind.ObjectMapper objectMapper, boolean useLockForIndexMappingCreation, java.time.Duration mappingSchemaLockWaitTime)
-
-
Method Detail
-
getOrder
public int getOrder()
- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
setOrder
public void setOrder(int order)
-
processResources
protected void processResources()
-
processMappingExtensionResources
protected java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> processMappingExtensionResources()
-
validateMappingExtensionJson
protected boolean validateMappingExtensionJson(org.springframework.core.io.Resource mappingExtensionResource, com.fasterxml.jackson.databind.JsonNode mappingExtensionJson)
-
processMappingResources
protected void processMappingResources(java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations)
-
processVariableMappings
protected void processVariableMappings(CustomIndexMapping indexMapping, com.fasterxml.jackson.databind.JsonNode jsonNode)
-
enhanceMappingWithExtension
protected void enhanceMappingWithExtension(java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, java.lang.String indexName)
-
enhanceProperties
protected void enhanceProperties(java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, java.lang.String indexName)
-
enhanceVariableProperties
protected void enhanceVariableProperties(java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, java.lang.String indexName)
-
enhanceSettings
protected void enhanceSettings(java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, java.lang.String indexName)
-
getIndexNamePrefix
public java.lang.String getIndexNamePrefix()
Description copied from interface:IndexManagerReturns the prefix that is added to all indices. Empty by default.- Specified by:
getIndexNamePrefixin interfaceIndexManager
-
setIndexNamePrefix
public void setIndexNamePrefix(java.lang.String indexNamePrefix)
-
getESIndexName
public java.lang.String getESIndexName(java.lang.String indexName)
Description copied from interface:IndexManagerReturns the internal index name for the provided raw index name. As there might be an index-prefix in place, the index name towards the Elasticsearch client needs to use the internal name though which is returned using this method.- Specified by:
getESIndexNamein interfaceIndexManager- Parameters:
indexName- the index name as being used in configuration, query DSL and API- Returns:
- the index name as being used towards Elasticsearch (might have a prefix)
-
createIndexWithAlias
public com.fasterxml.jackson.databind.JsonNode createIndexWithAlias(java.lang.String indexName)
Description copied from interface:IndexManagerCreates an index. The index mapping that is used will need to have as 'name' the passed index name. In fact, creates both an alias with the given name and the actual index, prefixed with the project name and with a timestamp. This allows later to change indices, but keep the alias and reindex.- Specified by:
createIndexWithAliasin interfaceIndexManager
-
createIndexWithoutAlias
public java.lang.String createIndexWithoutAlias(java.lang.String indexName)
Description copied from interface:IndexManagerSimilar toIndexManager.createIndexWithAlias(String), but doesn't create an alias, only the index with the mapping. Note that the index will still follow the aliasName-timeStamp pattern. Note that the mapping will be looked up based on the name passed.- Specified by:
createIndexWithoutAliasin interfaceIndexManager
-
createIndexAndAlias
public com.fasterxml.jackson.databind.JsonNode createIndexAndAlias(java.lang.String alias, java.lang.String indexMapping)
-
getCustomQueryMapping
public IndexMapping getCustomQueryMapping(java.lang.String indexName, java.lang.String mappingName)
Description copied from interface:IndexManagerGet custom query mapping for given index if exists.- Specified by:
getCustomQueryMappingin interfaceIndexManager
-
deleteAliasAndRelatedIndices
public void deleteAliasAndRelatedIndices(java.lang.String indexName)
Description copied from interface:IndexManagerDeletes the given index and all its aliases. Or, when the name is an alias, deletes the alias and all indices.- Specified by:
deleteAliasAndRelatedIndicesin interfaceIndexManager
-
deleteIndex
public void deleteIndex(java.lang.String indexName)
Description copied from interface:IndexManagerDeletes the index with the given name. Does not delete the alias, if one exists.- Specified by:
deleteIndexin interfaceIndexManager
-
deleteAllKnownIndices
public void deleteAllKnownIndices()
Description copied from interface:IndexManagerDeletes all indices registered in the system- Specified by:
deleteAllKnownIndicesin interfaceIndexManager
-
enhanceIndexName
protected java.lang.String enhanceIndexName(java.lang.String indexName)
-
isKnownIndex
public boolean isKnownIndex(java.lang.String index)
Description copied from interface:IndexManagerReturns whether the index is a known mapped index. This is useful when parsing queries.- Specified by:
isKnownIndexin interfaceIndexManager
-
findMatchingIndexMappings
public java.util.List<IndexMapping> findMatchingIndexMappings(com.fasterxml.jackson.databind.node.ObjectNode objectNode)
Description copied from interface:IndexManagerReturns a list ofIndexMappinginstances that are applicable for the provided data.- Specified by:
findMatchingIndexMappingsin interfaceIndexManager
-
findMatchingIndexMappings
public java.util.List<IndexMapping> findMatchingIndexMappings(java.lang.String mappingType)
Description copied from interface:IndexManagerReturns a list ofIndexMapping(s) that are applicable for the provided mapping type.- Specified by:
findMatchingIndexMappingsin interfaceIndexManager
-
findMatchingCustomMappings
public java.util.List<IndexMapping> findMatchingCustomMappings(java.lang.String indexName)
Description copied from interface:IndexManagerReturns a list ofIndexMapping(s) that are applicable for the provided index name.- Specified by:
findMatchingCustomMappingsin interfaceIndexManager
-
findIndexMapping
public IndexMapping findIndexMapping(java.lang.String indexName)
- Specified by:
findIndexMappingin interfaceIndexManager
-
getIndexConfiguration
public CustomIndexConfiguration getIndexConfiguration(java.lang.String indexName)
Description copied from interface:IndexManagerReturns the mapping information for the given index.- Specified by:
getIndexConfigurationin interfaceIndexManager
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
java.lang.Exception
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
- Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
-
createIndexesAndCustomAliasesFromMappings
public void createIndexesAndCustomAliasesFromMappings()
- Specified by:
createIndexesAndCustomAliasesFromMappingsin interfaceIndexManager
-
updateIndexMetaData
protected void updateIndexMetaData(java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode> indicesMetaData, java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> aliasesMetaData)
-
updateIndexAndMappingMetaData
protected void updateIndexAndMappingMetaData(java.lang.String index, com.fasterxml.jackson.databind.JsonNode metaData)
-
createCustomMappings
protected void createCustomMappings()
-
recreateMapping
public IndexMapping recreateMapping(IndexMapping indexMapping)
Description copied from interface:IndexManagerUsed to recreate mapping ifCustomIndexConfigurationchanged.- Specified by:
recreateMappingin interfaceIndexManager- Returns:
- Updated indexMapping
-
createCustomAliasesFromMappings
protected java.util.Map<java.lang.String,java.util.List<com.fasterxml.jackson.databind.JsonNode>> createCustomAliasesFromMappings(java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode> indexMetaData)
-
updateExistingAliasMapping
protected void updateExistingAliasMapping(IndexMapping customMapping)
-
createIndexesFromMappings
public java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode> createIndexesFromMappings()
Description copied from interface:IndexManagerCreates the indices for all known mappings- Specified by:
createIndexesFromMappingsin interfaceIndexManager
-
updateExistingMappingIfNeeded
protected com.fasterxml.jackson.databind.JsonNode updateExistingMappingIfNeeded(java.lang.String indexName, IndexMapping indexMapping)
-
compareExtensionMetadata
protected boolean compareExtensionMetadata(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping)
-
getMappingDelta
protected com.fasterxml.jackson.databind.node.ObjectNode getMappingDelta(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping, java.lang.String currentType)
-
createCustomAlias
protected void createCustomAlias(java.lang.String alias, java.lang.String indexMapping)
-
logElasticsearchVersionInformation
protected void logElasticsearchVersionInformation()
-
reloadIndices
public boolean reloadIndices()
Description copied from interface:IndexManagerReloads all indexes- Specified by:
reloadIndicesin interfaceIndexManager
-
reloadIndex
public boolean reloadIndex(java.lang.String indexName)
Description copied from interface:IndexManagerReloads selected index- Specified by:
reloadIndexin interfaceIndexManager
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
getLockManagerProvider
public java.util.function.Function<java.lang.String,org.flowable.common.engine.impl.lock.LockManager> getLockManagerProvider()
-
setLockManagerProvider
public void setLockManagerProvider(java.util.function.Function<java.lang.String,org.flowable.common.engine.impl.lock.LockManager> lockManagerProvider)
-
getMappingResources
public org.springframework.core.io.Resource[] getMappingResources()
-
setMappingResources
public void setMappingResources(org.springframework.core.io.Resource[] mappingResources)
-
getMappingExtensionResources
public org.springframework.core.io.Resource[] getMappingExtensionResources()
-
setMappingExtensionResources
public void setMappingExtensionResources(org.springframework.core.io.Resource[] mappingExtensionResources)
-
-