Package com.flowable.indexing
Class IndexManagerImpl
- java.lang.Object
-
- com.flowable.indexing.IndexManagerImpl
-
- All Implemented Interfaces:
IndexManager,InitializingBean,Lifecycle,Phased,SmartLifecycle
public class IndexManagerImpl extends Object implements IndexManager, SmartLifecycle, InitializingBean
-
-
Field Summary
-
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
-
Constructor Summary
Constructors Constructor Description IndexManagerImpl(ElasticsearchClient elasticsearchClient, Function<String,LockManager> lockManagerProvider, String indexNamePrefix, String projectName, Resource[] mappingResources, Resource[] mappingExtensionResources, IndexTemplateComposer indexTemplateComposer, com.fasterxml.jackson.databind.ObjectMapper objectMapper)IndexManagerImpl(ElasticsearchClient elasticsearchClient, Function<String,LockManager> lockManagerProvider, String indexNamePrefix, String projectName, Resource[] mappingResources, Resource[] mappingExtensionResources, IndexTemplateComposer indexTemplateComposer, com.fasterxml.jackson.databind.ObjectMapper objectMapper, boolean useLockForIndexMappingCreation, 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(String alias, String indexMapping)protected Map<String,List<com.fasterxml.jackson.databind.JsonNode>>createCustomAliasesFromMappings(Map<String,com.fasterxml.jackson.databind.JsonNode> indexMetaData)protected voidcreateCustomMappings()com.fasterxml.jackson.databind.JsonNodecreateIndexAndAlias(String alias, String indexMapping)voidcreateIndexesAndCustomAliasesFromMappings()Map<String,com.fasterxml.jackson.databind.JsonNode>createIndexesFromMappings()Creates the indices for all known mappingscom.fasterxml.jackson.databind.JsonNodecreateIndexWithAlias(String indexName)Creates an index.StringcreateIndexWithoutAlias(String indexName)Similar toIndexManager.createIndexWithAlias(String), but doesn't create an alias, only the index with the mapping.voiddeleteAliasAndRelatedIndices(String indexName)Deletes the given index and all its aliases.voiddeleteAllKnownIndices()Deletes all indices registered in the systemvoiddeleteIndex(String indexName)Deletes the index with the given name.protected StringenhanceIndexName(String indexName)protected voidenhanceMappingWithExtension(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName)protected voidenhanceProperties(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName)protected voidenhanceSettings(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName)protected voidenhanceVariableProperties(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName)IndexMappingfindIndexMapping(String indexName)List<IndexMapping>findMatchingCustomMappings(String indexName)Returns a list ofIndexMapping(s) that are applicable for the provided index name.List<IndexMapping>findMatchingIndexMappings(com.fasterxml.jackson.databind.node.ObjectNode objectNode)Returns a list ofIndexMappinginstances that are applicable for the provided data.List<IndexMapping>findMatchingIndexMappings(String mappingType)Returns a list ofIndexMapping(s) that are applicable for the provided mapping type.IndexMappinggetCustomQueryMapping(String indexName, String mappingName)Get custom query mapping for given index if exists.StringgetESIndexName(String indexName)Returns the internal index name for the provided raw index name.CustomIndexConfigurationgetIndexConfiguration(String indexName)Returns the mapping information for the given index.StringgetIndexNamePrefix()Returns the prefix that is added to all indices.Function<String,LockManager>getLockManagerProvider()protected com.fasterxml.jackson.databind.node.ObjectNodegetMappingDelta(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping, String currentType)Resource[]getMappingExtensionResources()Resource[]getMappingResources()intgetPhase()booleanisKnownIndex(String index)Returns whether the index is a known mapped index.booleanisRunning()protected voidlogElasticsearchVersionInformation()protected Map<String,List<com.fasterxml.jackson.databind.JsonNode>>processMappingExtensionResources()protected voidprocessMappingResources(Map<String,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(String indexName)Reloads selected indexbooleanreloadIndices()Reloads all indexesvoidsetIndexNamePrefix(String indexNamePrefix)voidsetLockManagerProvider(Function<String,LockManager> lockManagerProvider)voidsetMappingExtensionResources(Resource[] mappingExtensionResources)voidsetMappingResources(Resource[] mappingResources)voidstart()voidstop()protected voidupdateExistingAliasMapping(IndexMapping customMapping)protected com.fasterxml.jackson.databind.JsonNodeupdateExistingMappingIfNeeded(String indexName, IndexMapping indexMapping)protected voidupdateIndexAndMappingMetaData(String index, com.fasterxml.jackson.databind.JsonNode metaData)protected voidupdateIndexMetaData(Map<String,com.fasterxml.jackson.databind.JsonNode> indicesMetaData, Map<String,List<com.fasterxml.jackson.databind.JsonNode>> aliasesMetaData)protected booleanvalidateMappingExtensionJson(Resource mappingExtensionResource, com.fasterxml.jackson.databind.JsonNode mappingExtensionJson)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.springframework.context.SmartLifecycle
isAutoStartup, stop
-
-
-
-
Field Detail
-
INDEX_SUFFIX_FORMAT
protected static final DateTimeFormatter INDEX_SUFFIX_FORMAT
-
MINIMAL_COMPATIBLE_ES_VERSION
protected static int MINIMAL_COMPATIBLE_ES_VERSION
-
PROPERTIES_FIELD
protected static final String PROPERTIES_FIELD
- See Also:
- Constant Field Values
-
SETTINGS_FIELD
protected static final String SETTINGS_FIELD
- See Also:
- Constant Field Values
-
VARIABLE_PROPERTIES_FIELD
protected static final String VARIABLE_PROPERTIES_FIELD
- See Also:
- Constant Field Values
-
VARIABLE_EXTRACTORS_FIELD
protected static final String VARIABLE_EXTRACTORS_FIELD
- See Also:
- Constant Field Values
-
FULL_TEXT_VARIABLES_FIELD
protected static final String FULL_TEXT_VARIABLES_FIELD
- See Also:
- Constant Field Values
-
elasticsearchClient
protected ElasticsearchClient elasticsearchClient
-
lockManagerProvider
protected Function<String,LockManager> lockManagerProvider
-
mappingResources
protected Resource[] mappingResources
-
mappingExtensionResources
protected Resource[] mappingExtensionResources
-
indexTemplateComposer
protected IndexTemplateComposer indexTemplateComposer
-
objectMapper
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
indexNamePrefix
protected String indexNamePrefix
-
useLockForIndexMappingCreation
protected boolean useLockForIndexMappingCreation
-
mappingSchemaLockWaitTime
protected Duration mappingSchemaLockWaitTime
-
indexMappings
protected Map<String,IndexMapping> indexMappings
-
customMappings
protected Map<String,IndexMapping> customMappings
-
customConfigurations
protected List<CustomIndexConfiguration> customConfigurations
-
indexedDocumentTypes
protected Map<String,CustomIndexConfiguration> indexedDocumentTypes
-
lifeCycleMonitor
protected final Object lifeCycleMonitor
-
running
protected boolean running
-
-
Constructor Detail
-
IndexManagerImpl
public IndexManagerImpl(ElasticsearchClient elasticsearchClient, Function<String,LockManager> lockManagerProvider, String indexNamePrefix, String projectName, Resource[] mappingResources, Resource[] mappingExtensionResources, IndexTemplateComposer indexTemplateComposer, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
IndexManagerImpl
public IndexManagerImpl(ElasticsearchClient elasticsearchClient, Function<String,LockManager> lockManagerProvider, String indexNamePrefix, String projectName, Resource[] mappingResources, Resource[] mappingExtensionResources, IndexTemplateComposer indexTemplateComposer, com.fasterxml.jackson.databind.ObjectMapper objectMapper, boolean useLockForIndexMappingCreation, Duration mappingSchemaLockWaitTime)
-
-
Method Detail
-
getPhase
public int getPhase()
- Specified by:
getPhasein interfacePhased- Specified by:
getPhasein interfaceSmartLifecycle
-
processResources
protected void processResources()
-
processMappingExtensionResources
protected Map<String,List<com.fasterxml.jackson.databind.JsonNode>> processMappingExtensionResources()
-
validateMappingExtensionJson
protected boolean validateMappingExtensionJson(Resource mappingExtensionResource, com.fasterxml.jackson.databind.JsonNode mappingExtensionJson)
-
processMappingResources
protected void processMappingResources(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations)
-
processVariableMappings
protected void processVariableMappings(CustomIndexMapping indexMapping, com.fasterxml.jackson.databind.JsonNode jsonNode)
-
enhanceMappingWithExtension
protected void enhanceMappingWithExtension(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName)
-
enhanceProperties
protected void enhanceProperties(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName)
-
enhanceVariableProperties
protected void enhanceVariableProperties(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName)
-
enhanceSettings
protected void enhanceSettings(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName)
-
getIndexNamePrefix
public 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(String indexNamePrefix)
-
getESIndexName
public String getESIndexName(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(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 String createIndexWithoutAlias(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(String alias, String indexMapping)
-
getCustomQueryMapping
public IndexMapping getCustomQueryMapping(String indexName, String mappingName)
Description copied from interface:IndexManagerGet custom query mapping for given index if exists.- Specified by:
getCustomQueryMappingin interfaceIndexManager
-
deleteAliasAndRelatedIndices
public void deleteAliasAndRelatedIndices(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(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
-
isKnownIndex
public boolean isKnownIndex(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 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 List<IndexMapping> findMatchingIndexMappings(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 List<IndexMapping> findMatchingCustomMappings(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(String indexName)
- Specified by:
findIndexMappingin interfaceIndexManager
-
getIndexConfiguration
public CustomIndexConfiguration getIndexConfiguration(String indexName)
Description copied from interface:IndexManagerReturns the mapping information for the given index.- Specified by:
getIndexConfigurationin interfaceIndexManager
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception- Specified by:
afterPropertiesSetin interfaceInitializingBean- Throws:
Exception
-
createIndexesAndCustomAliasesFromMappings
public void createIndexesAndCustomAliasesFromMappings()
- Specified by:
createIndexesAndCustomAliasesFromMappingsin interfaceIndexManager
-
updateIndexMetaData
protected void updateIndexMetaData(Map<String,com.fasterxml.jackson.databind.JsonNode> indicesMetaData, Map<String,List<com.fasterxml.jackson.databind.JsonNode>> aliasesMetaData)
-
updateIndexAndMappingMetaData
protected void updateIndexAndMappingMetaData(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 Map<String,List<com.fasterxml.jackson.databind.JsonNode>> createCustomAliasesFromMappings(Map<String,com.fasterxml.jackson.databind.JsonNode> indexMetaData)
-
updateExistingAliasMapping
protected void updateExistingAliasMapping(IndexMapping customMapping)
-
createIndexesFromMappings
public Map<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(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, String currentType)
-
logElasticsearchVersionInformation
protected void logElasticsearchVersionInformation()
-
reloadIndices
public boolean reloadIndices()
Description copied from interface:IndexManagerReloads all indexes- Specified by:
reloadIndicesin interfaceIndexManager
-
reloadIndex
public boolean reloadIndex(String indexName)
Description copied from interface:IndexManagerReloads selected index- Specified by:
reloadIndexin interfaceIndexManager
-
getLockManagerProvider
public Function<String,LockManager> getLockManagerProvider()
-
setLockManagerProvider
public void setLockManagerProvider(Function<String,LockManager> lockManagerProvider)
-
getMappingResources
public Resource[] getMappingResources()
-
setMappingResources
public void setMappingResources(Resource[] mappingResources)
-
getMappingExtensionResources
public Resource[] getMappingExtensionResources()
-
setMappingExtensionResources
public void setMappingExtensionResources(Resource[] mappingExtensionResources)
-
-