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
Modifier and TypeFieldDescriptionprotected List<CustomIndexConfiguration>
protected Map<String,
IndexMapping> protected ElasticsearchClient
protected Collection<String>
protected static final String
protected static final DateTimeFormatter
protected Map<String,
CustomIndexConfiguration> protected Map<String,
IndexMapping> protected String
protected IndexTemplateComposer
protected final Object
protected Function<String,
LockManager> protected Resource[]
protected Resource[]
protected Duration
protected static int
protected com.fasterxml.jackson.databind.ObjectMapper
protected static final String
protected boolean
protected static final String
protected boolean
protected static final String
protected static final String
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionIndexManagerImpl
(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 TypeMethodDescriptionvoid
protected boolean
compareExtensionMetadata
(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping) protected void
createCustomAlias
(String alias, String indexMapping) createCustomAliasesFromMappings
(Map<String, com.fasterxml.jackson.databind.JsonNode> indexMetaData) protected void
com.fasterxml.jackson.databind.JsonNode
createIndexAndAlias
(String alias, String indexMapping) void
Creates the indices for all known mappingscom.fasterxml.jackson.databind.JsonNode
createIndexWithAlias
(String indexName) Creates an index.createIndexWithoutAlias
(String indexName) Similar toIndexManager.createIndexWithAlias(String)
, but doesn't create an alias, only the index with the mapping.void
deleteAliasAndRelatedIndices
(String indexName) Deletes the given index and all its aliases.void
Deletes all indices registered in the systemvoid
deleteIndex
(String indexName) Deletes the index with the given name.protected String
enhanceIndexName
(String indexName) protected void
enhanceMappingWithExtension
(Map<String, List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName) protected void
enhanceProperties
(Map<String, List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName) protected void
enhanceSettings
(Map<String, List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName) protected void
enhanceVariableProperties
(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 ofIndexMapping
instances 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.ObjectNode
getMappingDelta
(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping, String currentType) Resource[]
Resource[]
int
getPhase()
boolean
isKnownIndex
(String index) Returns whether the index is a known mapped index.boolean
protected void
protected void
processMappingResources
(Map<String, List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations) protected void
protected void
processVariableMappings
(CustomIndexMapping indexMapping, com.fasterxml.jackson.databind.JsonNode jsonNode) recreateMapping
(IndexMapping indexMapping) Used to recreate mapping ifCustomIndexConfiguration
changed.boolean
reloadIndex
(String indexName) Reloads selected indexboolean
Reloads all indexesvoid
setIndexNamePrefix
(String indexNamePrefix) void
setLockManagerProvider
(Function<String, LockManager> lockManagerProvider) void
setMappingExtensionResources
(Resource[] mappingExtensionResources) void
setMappingResources
(Resource[] mappingResources) void
start()
void
stop()
protected void
updateExistingAliasMapping
(IndexMapping customMapping) protected com.fasterxml.jackson.databind.JsonNode
updateExistingMappingIfNeeded
(String indexName, IndexMapping indexMapping) protected void
updateIndexAndMappingMetaData
(String index, com.fasterxml.jackson.databind.JsonNode metaData) protected void
updateIndexMetaData
(Map<String, com.fasterxml.jackson.databind.JsonNode> indicesMetaData, Map<String, List<com.fasterxml.jackson.databind.JsonNode>> aliasesMetaData) protected boolean
validateMappingExtensionJson
(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 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:
getPhase
in interfacePhased
- Specified by:
getPhase
in 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:IndexManager
Returns the prefix that is added to all indices. Empty by default.- Specified by:
getIndexNamePrefix
in interfaceIndexManager
-
setIndexNamePrefix
-
getESIndexName
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 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: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 interfaceIndexManager
-
createIndexWithoutAlias
Description copied from interface:IndexManager
Similar 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:
createIndexWithoutAlias
in interfaceIndexManager
-
createIndexAndAlias
-
getCustomQueryMapping
Description copied from interface:IndexManager
Get custom query mapping for given index if exists.- Specified by:
getCustomQueryMapping
in interfaceIndexManager
-
deleteAliasAndRelatedIndices
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 interfaceIndexManager
-
deleteIndex
Description copied from interface:IndexManager
Deletes the index with the given name. Does not delete the alias, if one exists.- Specified by:
deleteIndex
in interfaceIndexManager
-
deleteAllKnownIndices
public void deleteAllKnownIndices()Description copied from interface:IndexManager
Deletes all indices registered in the system- Specified by:
deleteAllKnownIndices
in interfaceIndexManager
-
enhanceIndexName
-
isKnownIndex
Description copied from interface:IndexManager
Returns whether the index is a known mapped index. This is useful when parsing queries.- Specified by:
isKnownIndex
in interfaceIndexManager
-
findMatchingIndexMappings
public List<IndexMapping> findMatchingIndexMappings(com.fasterxml.jackson.databind.node.ObjectNode objectNode) Description copied from interface:IndexManager
Returns a list ofIndexMapping
instances that are applicable for the provided data.- Specified by:
findMatchingIndexMappings
in interfaceIndexManager
-
findMatchingIndexMappings
Description copied from interface:IndexManager
Returns a list ofIndexMapping
(s) that are applicable for the provided mapping type.- Specified by:
findMatchingIndexMappings
in interfaceIndexManager
-
findMatchingCustomMappings
Description copied from interface:IndexManager
Returns a list ofIndexMapping
(s) that are applicable for the provided index name.- Specified by:
findMatchingCustomMappings
in interfaceIndexManager
-
findIndexMapping
- Specified by:
findIndexMapping
in interfaceIndexManager
-
getIndexConfiguration
Description copied from interface:IndexManager
Returns the mapping information for the given index.- Specified by:
getIndexConfiguration
in interfaceIndexManager
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
Exception
-
createIndexesAndCustomAliasesFromMappings
public void createIndexesAndCustomAliasesFromMappings()- Specified by:
createIndexesAndCustomAliasesFromMappings
in interfaceIndexManager
-
updateIndexMetaData
-
updateIndexAndMappingMetaData
protected void updateIndexAndMappingMetaData(String index, com.fasterxml.jackson.databind.JsonNode metaData) -
createCustomMappings
protected void createCustomMappings() -
recreateMapping
Description copied from interface:IndexManager
Used to recreate mapping ifCustomIndexConfiguration
changed.- Specified by:
recreateMapping
in interfaceIndexManager
- Returns:
- Updated indexMapping
-
createCustomAliasesFromMappings
-
updateExistingAliasMapping
-
createIndexesFromMappings
Description copied from interface:IndexManager
Creates the indices for all known mappings- Specified by:
createIndexesFromMappings
in 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:IndexManager
Reloads all indexes- Specified by:
reloadIndices
in interfaceIndexManager
-
reloadIndex
Description copied from interface:IndexManager
Reloads selected index- Specified by:
reloadIndex
in interfaceIndexManager
-
getLockManagerProvider
-
setLockManagerProvider
-
getMappingResources
-
setMappingResources
-
getMappingExtensionResources
-
setMappingExtensionResources
-