Class 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 Detail

      • 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
      • 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
      • 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
      • 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
      • indices

        protected java.util.List<java.lang.String> indices
      • 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:
        getOrder in interface org.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: IndexManager
        Returns the prefix that is added to all indices. Empty by default.
        Specified by:
        getIndexNamePrefix in interface IndexManager
      • setIndexNamePrefix

        public void setIndexNamePrefix​(java.lang.String indexNamePrefix)
      • getESIndexName

        public java.lang.String getESIndexName​(java.lang.String indexName)
        Description copied from interface: IndexManager
        Returns 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:
        getESIndexName in interface IndexManager
        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: IndexManager
        Creates 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:
        createIndexWithAlias in interface IndexManager
      • createIndexWithoutAlias

        public java.lang.String createIndexWithoutAlias​(java.lang.String indexName)
        Description copied from interface: IndexManager
        Similar to IndexManager.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:
        createIndexWithoutAlias in interface IndexManager
      • 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: IndexManager
        Get custom query mapping for given index if exists.
        Specified by:
        getCustomQueryMapping in interface IndexManager
      • deleteAliasAndRelatedIndices

        public void deleteAliasAndRelatedIndices​(java.lang.String indexName)
        Description copied from interface: IndexManager
        Deletes the given index and all its aliases. Or, when the name is an alias, deletes the alias and all indices.
        Specified by:
        deleteAliasAndRelatedIndices in interface IndexManager
      • deleteIndex

        public void deleteIndex​(java.lang.String indexName)
        Description copied from interface: IndexManager
        Deletes the index with the given name. Does not delete the alias, if one exists.
        Specified by:
        deleteIndex in interface IndexManager
      • enhanceIndexName

        protected java.lang.String enhanceIndexName​(java.lang.String indexName)
      • isKnownIndex

        public boolean isKnownIndex​(java.lang.String index)
        Description copied from interface: IndexManager
        Returns whether the index is a known mapped index. This is useful when parsing queries.
        Specified by:
        isKnownIndex in interface IndexManager
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws java.lang.Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        java.lang.Exception
      • onApplicationEvent

        public void onApplicationEvent​(org.springframework.context.event.ContextRefreshedEvent event)
        Specified by:
        onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
      • 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()
      • 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: IndexManager
        Creates the indices for all known mappings
        Specified by:
        createIndexesFromMappings in interface IndexManager
      • 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()
      • reloadIndex

        public boolean reloadIndex​(java.lang.String indexName)
        Description copied from interface: IndexManager
        Reloads selected index
        Specified by:
        reloadIndex in interface IndexManager
      • setApplicationContext

        public void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
                                   throws org.springframework.beans.BeansException
        Specified by:
        setApplicationContext in interface org.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)