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
FieldsModifier and TypeFieldDescriptionprotected List<CustomIndexConfiguration>protected Map<String,IndexMapping> protected ElasticsearchClientprotected Collection<String>protected static final Stringprotected static final DateTimeFormatterprotected Map<String,CustomIndexConfiguration> protected Map<String,IndexMapping> protected Stringprotected IndexTemplateComposerprotected final Objectprotected Function<String,LockManager> protected Resource[]protected Resource[]protected Durationprotected static intprotected com.fasterxml.jackson.databind.ObjectMapperprotected static final Stringprotected booleanprotected static final Stringprotected booleanprotected static final Stringprotected static final StringFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionIndexManagerImpl(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, Collection<String> enabledIndices) IndexManagerImpl(ElasticsearchClient elasticsearchClient, Function<String, LockManager> lockManagerProvider, String indexNamePrefix, String projectName, Resource[] mappingResources, Resource[] mappingExtensionResources, IndexTemplateComposer indexTemplateComposer, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Collection<String> enabledIndices) -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected booleancompareExtensionMetadata(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping) protected voidcreateCustomAlias(String alias, String indexMapping) createCustomAliasesFromMappings(Map<String, com.fasterxml.jackson.databind.JsonNode> indexMetaData) protected voidcom.fasterxml.jackson.databind.JsonNodecreateIndexAndAlias(String alias, String indexMapping) voidCreates the indices for all known mappingscom.fasterxml.jackson.databind.JsonNodecreateIndexWithAlias(String indexName) Creates an index.createIndexWithoutAlias(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.voidDeletes 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) findIndexMapping(String indexName) findMatchingCustomMappings(String indexName) Returns a list ofIndexMapping(s) that are applicable for the provided index name.findMatchingIndexMappings(com.fasterxml.jackson.databind.node.ObjectNode objectNode) Returns a list ofIndexMappinginstances that are applicable for the provided data.findMatchingIndexMappings(String mappingType) Returns a list ofIndexMapping(s) that are applicable for the provided mapping type.getCustomQueryMapping(String indexName, String mappingName) Get custom query mapping for given index if exists.getESIndexName(String indexName) Returns the internal index name for the provided raw index name.getIndexConfiguration(String indexName) Returns the mapping information for the given index.Returns the prefix that is added to all indices.protected com.fasterxml.jackson.databind.node.ObjectNodegetMappingDelta(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping, String currentType) Resource[]Resource[]intgetPhase()booleanisKnownIndex(String index) Returns whether the index is a known mapped index.booleanprotected voidprotected voidprocessMappingResources(Map<String, List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations) protected voidprotected voidprocessVariableMappings(CustomIndexMapping indexMapping, com.fasterxml.jackson.databind.JsonNode jsonNode) recreateMapping(IndexMapping indexMapping) Used to recreate mapping ifCustomIndexConfigurationchanged.booleanreloadIndex(String indexName) Reloads selected indexbooleanReloads 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, waitMethods inherited from interface org.springframework.context.SmartLifecycle
isAutoStartup, stop
-
Field Details
-
INDEX_SUFFIX_FORMAT
-
MINIMAL_COMPATIBLE_ES_VERSION
protected static int MINIMAL_COMPATIBLE_ES_VERSION -
PROPERTIES_FIELD
- See Also:
-
SETTINGS_FIELD
- See Also:
-
VARIABLE_PROPERTIES_FIELD
- See Also:
-
VARIABLE_EXTRACTORS_FIELD
- See Also:
-
FULL_TEXT_VARIABLES_FIELD
- See Also:
-
elasticsearchClient
-
lockManagerProvider
-
mappingResources
-
mappingExtensionResources
-
indexTemplateComposer
-
objectMapper
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper -
indexNamePrefix
-
useLockForIndexMappingCreation
protected boolean useLockForIndexMappingCreation -
mappingSchemaLockWaitTime
-
indexMappings
-
customMappings
-
customConfigurations
-
indices
-
indexedDocumentTypes
-
lifeCycleMonitor
-
running
protected boolean running -
enabledIndices
-
-
Constructor Details
-
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, Collection<String> enabledIndices) -
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, Collection<String> enabledIndices)
-
-
Method Details
-
getPhase
public int getPhase()- Specified by:
getPhasein interfacePhased- Specified by:
getPhasein interfaceSmartLifecycle
-
start
public void start() -
stop
public void stop() -
isRunning
public boolean isRunning() -
processResources
protected void processResources() -
processMappingExtensionResources
-
validateMappingExtensionJson
protected boolean validateMappingExtensionJson(Resource mappingExtensionResource, com.fasterxml.jackson.databind.JsonNode mappingExtensionJson) -
processMappingResources
-
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
Description copied from interface:IndexManagerReturns the prefix that is added to all indices. Empty by default.- Specified by:
getIndexNamePrefixin interfaceIndexManager
-
setIndexNamePrefix
-
getESIndexName
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
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
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
-
getCustomQueryMapping
Description copied from interface:IndexManagerGet custom query mapping for given index if exists.- Specified by:
getCustomQueryMappingin interfaceIndexManager
-
deleteAliasAndRelatedIndices
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
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
-
isKnownIndex
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
Description copied from interface:IndexManagerReturns a list ofIndexMapping(s) that are applicable for the provided mapping type.- Specified by:
findMatchingIndexMappingsin interfaceIndexManager
-
findMatchingCustomMappings
Description copied from interface:IndexManagerReturns a list ofIndexMapping(s) that are applicable for the provided index name.- Specified by:
findMatchingCustomMappingsin interfaceIndexManager
-
findIndexMapping
- Specified by:
findIndexMappingin interfaceIndexManager
-
getIndexConfiguration
Description copied from interface:IndexManagerReturns the mapping information for the given index.- Specified by:
getIndexConfigurationin interfaceIndexManager
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceInitializingBean- Throws:
Exception
-
createIndexesAndCustomAliasesFromMappings
public void createIndexesAndCustomAliasesFromMappings()- Specified by:
createIndexesAndCustomAliasesFromMappingsin interfaceIndexManager
-
updateIndexMetaData
-
updateIndexAndMappingMetaData
protected void updateIndexAndMappingMetaData(String index, com.fasterxml.jackson.databind.JsonNode metaData) -
createCustomMappings
protected void createCustomMappings() -
recreateMapping
Description copied from interface:IndexManagerUsed to recreate mapping ifCustomIndexConfigurationchanged.- Specified by:
recreateMappingin interfaceIndexManager- Returns:
- Updated indexMapping
-
createCustomAliasesFromMappings
-
updateExistingAliasMapping
-
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) -
createCustomAlias
-
logElasticsearchVersionInformation
protected void logElasticsearchVersionInformation() -
reloadIndices
public boolean reloadIndices()Description copied from interface:IndexManagerReloads all indexes- Specified by:
reloadIndicesin interfaceIndexManager
-
reloadIndex
Description copied from interface:IndexManagerReloads selected index- Specified by:
reloadIndexin interfaceIndexManager
-
getLockManagerProvider
-
setLockManagerProvider
-
getMappingResources
-
setMappingResources
-
getMappingExtensionResources
-
setMappingExtensionResources
-