public class IndexManagerImpl extends Object implements IndexManager, ApplicationListener<ContextRefreshedEvent>, ApplicationContextAware, Ordered, InitializingBean
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and 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) |
Modifier and Type | Method and 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 mappings
|
com.fasterxml.jackson.databind.JsonNode |
createIndexWithAlias(String indexName)
Creates an index.
|
String |
createIndexWithoutAlias(String indexName)
Similar to
IndexManager.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 system
|
void |
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 of
IndexMapping (s) that are applicable for the provided index name. |
List<IndexMapping> |
findMatchingIndexMappings(com.fasterxml.jackson.databind.node.ObjectNode objectNode)
Returns a list of
IndexMapping instances that are applicable for the provided data. |
List<IndexMapping> |
findMatchingIndexMappings(String mappingType)
Returns a list of
IndexMapping (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 |
getOrder() |
boolean |
isKnownIndex(String index)
Returns whether the index is a known mapped index.
|
protected void |
logElasticsearchVersionInformation() |
void |
onApplicationEvent(ContextRefreshedEvent event) |
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 if
CustomIndexConfiguration changed. |
boolean |
reloadIndex(String indexName)
Reloads selected index
|
boolean |
reloadIndices()
Reloads all indexes
|
void |
setApplicationContext(ApplicationContext applicationContext) |
void |
setIndexNamePrefix(String indexNamePrefix) |
void |
setLockManagerProvider(Function<String,LockManager> lockManagerProvider) |
void |
setMappingExtensionResources(Resource[] mappingExtensionResources) |
void |
setMappingResources(Resource[] mappingResources) |
void |
setOrder(int order) |
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) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forPayload
public static final int DEFAULT_ORDER
protected static final DateTimeFormatter INDEX_SUFFIX_FORMAT
protected static int MINIMAL_COMPATIBLE_ES_VERSION
protected static final String PROPERTIES_FIELD
protected static final String SETTINGS_FIELD
protected static final String VARIABLE_PROPERTIES_FIELD
protected static final String VARIABLE_EXTRACTORS_FIELD
protected static final String FULL_TEXT_VARIABLES_FIELD
protected ElasticsearchClient elasticsearchClient
protected Function<String,LockManager> lockManagerProvider
protected Resource[] mappingResources
protected Resource[] mappingExtensionResources
protected IndexTemplateComposer indexTemplateComposer
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
protected String indexNamePrefix
protected boolean useLockForIndexMappingCreation
protected Duration mappingSchemaLockWaitTime
protected Map<String,IndexMapping> indexMappings
protected Map<String,IndexMapping> customMappings
protected List<CustomIndexConfiguration> customConfigurations
protected Map<String,CustomIndexConfiguration> indexedDocumentTypes
protected ApplicationContext applicationContext
protected int order
public IndexManagerImpl(ElasticsearchClient elasticsearchClient, Function<String,LockManager> lockManagerProvider, String indexNamePrefix, String projectName, Resource[] mappingResources, Resource[] mappingExtensionResources, IndexTemplateComposer indexTemplateComposer, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
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)
public void setOrder(int order)
protected void processResources()
protected Map<String,List<com.fasterxml.jackson.databind.JsonNode>> processMappingExtensionResources()
protected boolean validateMappingExtensionJson(Resource mappingExtensionResource, com.fasterxml.jackson.databind.JsonNode mappingExtensionJson)
protected void processMappingResources(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations)
protected void processVariableMappings(CustomIndexMapping indexMapping, com.fasterxml.jackson.databind.JsonNode jsonNode)
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 enhanceVariableProperties(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)
public String getIndexNamePrefix()
IndexManager
getIndexNamePrefix
in interface IndexManager
public void setIndexNamePrefix(String indexNamePrefix)
public String getESIndexName(String indexName)
IndexManager
getESIndexName
in interface IndexManager
indexName
- the index name as being used in configuration, query DSL and APIpublic com.fasterxml.jackson.databind.JsonNode createIndexWithAlias(String indexName)
IndexManager
createIndexWithAlias
in interface IndexManager
public String createIndexWithoutAlias(String indexName)
IndexManager
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.createIndexWithoutAlias
in interface IndexManager
public com.fasterxml.jackson.databind.JsonNode createIndexAndAlias(String alias, String indexMapping)
public IndexMapping getCustomQueryMapping(String indexName, String mappingName)
IndexManager
getCustomQueryMapping
in interface IndexManager
public void deleteAliasAndRelatedIndices(String indexName)
IndexManager
deleteAliasAndRelatedIndices
in interface IndexManager
public void deleteIndex(String indexName)
IndexManager
deleteIndex
in interface IndexManager
public void deleteAllKnownIndices()
IndexManager
deleteAllKnownIndices
in interface IndexManager
public boolean isKnownIndex(String index)
IndexManager
isKnownIndex
in interface IndexManager
public List<IndexMapping> findMatchingIndexMappings(com.fasterxml.jackson.databind.node.ObjectNode objectNode)
IndexManager
IndexMapping
instances that are applicable for the provided data.findMatchingIndexMappings
in interface IndexManager
public List<IndexMapping> findMatchingIndexMappings(String mappingType)
IndexManager
IndexMapping
(s) that are applicable for the provided mapping type.findMatchingIndexMappings
in interface IndexManager
public List<IndexMapping> findMatchingCustomMappings(String indexName)
IndexManager
IndexMapping
(s) that are applicable for the provided index name.findMatchingCustomMappings
in interface IndexManager
public IndexMapping findIndexMapping(String indexName)
findIndexMapping
in interface IndexManager
public CustomIndexConfiguration getIndexConfiguration(String indexName)
IndexManager
getIndexConfiguration
in interface IndexManager
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
public void onApplicationEvent(ContextRefreshedEvent event)
onApplicationEvent
in interface ApplicationListener<ContextRefreshedEvent>
public void createIndexesAndCustomAliasesFromMappings()
createIndexesAndCustomAliasesFromMappings
in interface IndexManager
protected void updateIndexMetaData(Map<String,com.fasterxml.jackson.databind.JsonNode> indicesMetaData, Map<String,List<com.fasterxml.jackson.databind.JsonNode>> aliasesMetaData)
protected void updateIndexAndMappingMetaData(String index, com.fasterxml.jackson.databind.JsonNode metaData)
protected void createCustomMappings()
public IndexMapping recreateMapping(IndexMapping indexMapping)
IndexManager
CustomIndexConfiguration
changed.recreateMapping
in interface IndexManager
protected Map<String,List<com.fasterxml.jackson.databind.JsonNode>> createCustomAliasesFromMappings(Map<String,com.fasterxml.jackson.databind.JsonNode> indexMetaData)
protected void updateExistingAliasMapping(IndexMapping customMapping)
public Map<String,com.fasterxml.jackson.databind.JsonNode> createIndexesFromMappings()
IndexManager
createIndexesFromMappings
in interface IndexManager
protected com.fasterxml.jackson.databind.JsonNode updateExistingMappingIfNeeded(String indexName, IndexMapping indexMapping)
protected boolean compareExtensionMetadata(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping)
protected com.fasterxml.jackson.databind.node.ObjectNode getMappingDelta(com.fasterxml.jackson.databind.JsonNode currentMapping, com.fasterxml.jackson.databind.JsonNode updateMapping, String currentType)
protected void logElasticsearchVersionInformation()
public boolean reloadIndices()
IndexManager
reloadIndices
in interface IndexManager
public boolean reloadIndex(String indexName)
IndexManager
reloadIndex
in interface IndexManager
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext
in interface ApplicationContextAware
BeansException
public Function<String,LockManager> getLockManagerProvider()
public void setLockManagerProvider(Function<String,LockManager> lockManagerProvider)
public Resource[] getMappingResources()
public void setMappingResources(Resource[] mappingResources)
public Resource[] getMappingExtensionResources()
public void setMappingExtensionResources(Resource[] mappingExtensionResources)