Class OpenSearchIndexManagerImpl
java.lang.Object
com.atlassian.confluence.plugins.opensearch.indexmanager.OpenSearchIndexManagerImpl
- All Implemented Interfaces:
OpenSearchIndexManager,FieldMappings.FieldMappingWriter,org.springframework.beans.factory.DisposableBean
public class OpenSearchIndexManagerImpl
extends Object
implements OpenSearchIndexManager, FieldMappings.FieldMappingWriter
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.confluence.plugins.opensearch.indexmanager.OpenSearchIndexManager
OpenSearchIndexManager.StagingIndex -
Constructor Summary
ConstructorsConstructorDescriptionOpenSearchIndexManagerImpl(Index index, Supplier<org.opensearch.client.opensearch.indices.IndexSettingsAnalysis> analysisSettingsSupplier, org.opensearch.client.opensearch.OpenSearchClient client, OpenSearchConfig openSearchConfig, com.atlassian.event.api.EventPublisher eventPublisher, OpenSearchFieldMappingMapper fieldMappingMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcreateNewIndex(String indexName, String... aliases) Create a new staging index, i.e.protected voiddeleteIndexes(List<String> indexNames) voiddestroy()voidCreate an index on OpenSearch based on the provided settingsbooleanexists()getAlias()Gets the alias for accessing the OpenSearch index.protected org.opensearch.client.opensearch.indices.IndexSettingsAnalysisGet or add field mappings on this index.getIndex()voidonIndexCreatedRemotely(ClusterEventWrapper eventWrapper) When index gets recreated by another node, make sure all mappings registered on this node are present in the index.booleanputIfAbsent(FieldMapping mapping) Create the specified field mapping on the underlying index if it is not already present.protected booleanputIfAbsent(FieldMapping mapping, String indexName) voidrecreate()Create a new index on OpenSearch based on the provided settings.
-
Constructor Details
-
OpenSearchIndexManagerImpl
public OpenSearchIndexManagerImpl(Index index, Supplier<org.opensearch.client.opensearch.indices.IndexSettingsAnalysis> analysisSettingsSupplier, org.opensearch.client.opensearch.OpenSearchClient client, OpenSearchConfig openSearchConfig, com.atlassian.event.api.EventPublisher eventPublisher, OpenSearchFieldMappingMapper fieldMappingMapper)
-
-
Method Details
-
recreate
Description copied from interface:OpenSearchIndexManagerCreate a new index on OpenSearch based on the provided settings. If it already exists, it will be deleted first.- Specified by:
recreatein interfaceOpenSearchIndexManager- Throws:
IOException
-
createStagingIndex
Description copied from interface:OpenSearchIndexManagerCreate a new staging index, i.e. an index that's not pointed to by the alias.- Specified by:
createStagingIndexin interfaceOpenSearchIndexManager- Returns:
- the new staging index
- Throws:
IOException
-
putIfAbsent
Description copied from interface:FieldMappings.FieldMappingWriterCreate the specified field mapping on the underlying index if it is not already present.- Specified by:
putIfAbsentin interfaceFieldMappings.FieldMappingWriter- Parameters:
mapping- a mapping to add- Returns:
- true if the mapping was created on the index, or false if it was already present.
- Throws:
SearchIndexAccessException- if the mapping failed to be created
-
getIndex
- Specified by:
getIndexin interfaceOpenSearchIndexManager- Returns:
- the index managed by this instance
-
getAlias
Description copied from interface:OpenSearchIndexManagerGets the alias for accessing the OpenSearch index. Note: each index is created behind an alias to improve resiliency during reindexing. On system indexes, it allows green/blue reindexing to avoid downtime (seeOpenSearchIndexManager.StagingIndex). On custom index, it tolerates failures when deleting the old index (e.g. because snapshotting is taking place).- Specified by:
getAliasin interfaceOpenSearchIndexManager- Returns:
- the alias
-
getFieldMappings
Description copied from interface:OpenSearchIndexManagerGet or add field mappings on this index.- Specified by:
getFieldMappingsin interfaceOpenSearchIndexManager- Returns:
- field mappings
-
ensureExists
Description copied from interface:OpenSearchIndexManagerCreate an index on OpenSearch based on the provided settings- Specified by:
ensureExistsin interfaceOpenSearchIndexManager- Throws:
IOException
-
exists
- Specified by:
existsin interfaceOpenSearchIndexManager- Returns:
- true if the index exists, or false if it does not exist
- Throws:
IOException
-
createNewIndex
- Throws:
IOException
-
deleteIndexes
- Throws:
IOException
-
onIndexCreatedRemotely
When index gets recreated by another node, make sure all mappings registered on this node are present in the index. This is to prevent rare cases that can result in fields getting created on OpenSearch index with auto-generated (dynamic) mapping.- Parameters:
eventWrapper-
-
putIfAbsent
protected boolean putIfAbsent(FieldMapping mapping, String indexName) throws SearchIndexAccessException - Throws:
SearchIndexAccessException
-
getAnalysisSettings
protected org.opensearch.client.opensearch.indices.IndexSettingsAnalysis getAnalysisSettings() -
destroy
public void destroy()- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean
-