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 void
afterPropertiesSet()
protected boolean
compareExtensionMetadata(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping)
protected void
createCustomAlias(String alias, String indexMapping)
protected Map<String,List<com.fasterxml.jackson.databind.JsonNode>>
createCustomAliasesFromMappings(Map<String,com.fasterxml.jackson.databind.JsonNode> indexMetaData)
protected void
createCustomMappings()
com.fasterxml.jackson.databind.JsonNode
createIndexAndAlias(String alias, String indexMapping)
void
createIndexesAndCustomAliasesFromMappings()
Map<String,com.fasterxml.jackson.databind.JsonNode>
createIndexesFromMappings()
Creates the indices for all known mappingscom.fasterxml.jackson.databind.JsonNode
createIndexWithAlias(String indexName)
Creates an index.String
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
deleteAllKnownIndices()
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)
IndexMapping
findIndexMapping(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 ofIndexMapping
instances 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.IndexMapping
getCustomQueryMapping(String indexName, String mappingName)
Get custom query mapping for given index if exists.String
getESIndexName(String indexName)
Returns the internal index name for the provided raw index name.CustomIndexConfiguration
getIndexConfiguration(String indexName)
Returns the mapping information for the given index.String
getIndexNamePrefix()
Returns the prefix that is added to all indices.Function<String,LockManager>
getLockManagerProvider()
protected com.fasterxml.jackson.databind.node.ObjectNode
getMappingDelta(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping, String currentType)
Resource[]
getMappingExtensionResources()
Resource[]
getMappingResources()
int
getPhase()
boolean
isKnownIndex(String index)
Returns whether the index is a known mapped index.boolean
isRunning()
protected void
logElasticsearchVersionInformation()
protected Map<String,List<com.fasterxml.jackson.databind.JsonNode>>
processMappingExtensionResources()
protected void
processMappingResources(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations)
protected void
processResources()
protected void
processVariableMappings(CustomIndexMapping indexMapping, com.fasterxml.jackson.databind.JsonNode jsonNode)
IndexMapping
recreateMapping(IndexMapping indexMapping)
Used to recreate mapping ifCustomIndexConfiguration
changed.boolean
reloadIndex(String indexName)
Reloads selected indexboolean
reloadIndices()
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 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:
getPhase
in interfacePhased
- Specified by:
getPhase
in 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:IndexManager
Returns the prefix that is added to all indices. Empty by default.- Specified by:
getIndexNamePrefix
in interfaceIndexManager
-
setIndexNamePrefix
public void setIndexNamePrefix(String indexNamePrefix)
-
getESIndexName
public String getESIndexName(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 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: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
public String createIndexWithoutAlias(String indexName)
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
public com.fasterxml.jackson.databind.JsonNode createIndexAndAlias(String alias, String indexMapping)
-
getCustomQueryMapping
public IndexMapping getCustomQueryMapping(String indexName, String mappingName)
Description copied from interface:IndexManager
Get custom query mapping for given index if exists.- Specified by:
getCustomQueryMapping
in interfaceIndexManager
-
deleteAliasAndRelatedIndices
public void deleteAliasAndRelatedIndices(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 interfaceIndexManager
-
deleteIndex
public void deleteIndex(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 interfaceIndexManager
-
deleteAllKnownIndices
public void deleteAllKnownIndices()
Description copied from interface:IndexManager
Deletes all indices registered in the system- Specified by:
deleteAllKnownIndices
in interfaceIndexManager
-
isKnownIndex
public boolean isKnownIndex(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 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
public List<IndexMapping> findMatchingIndexMappings(String mappingType)
Description copied from interface:IndexManager
Returns a list ofIndexMapping
(s) that are applicable for the provided mapping type.- Specified by:
findMatchingIndexMappings
in interfaceIndexManager
-
findMatchingCustomMappings
public List<IndexMapping> findMatchingCustomMappings(String indexName)
Description copied from interface:IndexManager
Returns a list ofIndexMapping
(s) that are applicable for the provided index name.- Specified by:
findMatchingCustomMappings
in interfaceIndexManager
-
findIndexMapping
public IndexMapping findIndexMapping(String indexName)
- Specified by:
findIndexMapping
in interfaceIndexManager
-
getIndexConfiguration
public CustomIndexConfiguration getIndexConfiguration(String indexName)
Description copied from interface:IndexManager
Returns the mapping information for the given index.- Specified by:
getIndexConfiguration
in interfaceIndexManager
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
Exception
-
createIndexesAndCustomAliasesFromMappings
public void createIndexesAndCustomAliasesFromMappings()
- Specified by:
createIndexesAndCustomAliasesFromMappings
in 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:IndexManager
Used to recreate mapping ifCustomIndexConfiguration
changed.- Specified by:
recreateMapping
in 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: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)
-
logElasticsearchVersionInformation
protected void logElasticsearchVersionInformation()
-
reloadIndices
public boolean reloadIndices()
Description copied from interface:IndexManager
Reloads all indexes- Specified by:
reloadIndices
in interfaceIndexManager
-
reloadIndex
public boolean reloadIndex(String indexName)
Description copied from interface:IndexManager
Reloads selected index- Specified by:
reloadIndex
in 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)
-
-