Class OpenSearchIndexManagerFactory.OpenSearchIndexManagerImpl
- java.lang.Object
-
- com.atlassian.confluence.plugins.opensearch.OpenSearchIndexManagerFactory.OpenSearchIndexManagerImpl
-
- All Implemented Interfaces:
OpenSearchIndexManager,FieldMappings.FieldMappingWriter,org.springframework.beans.factory.DisposableBean
- Enclosing class:
- OpenSearchIndexManagerFactory
public class OpenSearchIndexManagerFactory.OpenSearchIndexManagerImpl extends Object implements OpenSearchIndexManager, FieldMappings.FieldMappingWriter
-
-
Constructor Summary
Constructors Constructor Description OpenSearchIndexManagerImpl(Index index, Supplier<org.opensearch.client.opensearch.indices.IndexSettingsAnalysis> analysisSettingsSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreate()Create the index on OpenSearch.voiddelete()Delete the index from OpenSearch.voiddestroy()voidensureExists()Create an index on OpenSearch based on the provided settingsbooleanexists()FieldMappingsgetFieldMappings()Get or add field mappings on this index.IndexgetIndex()StringgetIndexName()voidonIndexRecreatedRemotely(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.voidrecreate()Create the new index on OpenSearch based on the provided settings.
-
-
-
Method Detail
-
getIndex
public Index getIndex()
- Specified by:
getIndexin interfaceOpenSearchIndexManager- Returns:
- the index managed by this instance
-
getIndexName
public String getIndexName()
- Specified by:
getIndexNamein interfaceOpenSearchIndexManager- Returns:
- the name of the index on OpenSearch
-
getFieldMappings
public FieldMappings getFieldMappings()
Description copied from interface:OpenSearchIndexManagerGet or add field mappings on this index.- Specified by:
getFieldMappingsin interfaceOpenSearchIndexManager- Returns:
- field mappings
-
exists
public boolean exists() throws IOException- Specified by:
existsin interfaceOpenSearchIndexManager- Returns:
- true if the index exists, or false if it does not exist
- Throws:
IOException
-
ensureExists
public void ensureExists() throws IOExceptionDescription copied from interface:OpenSearchIndexManagerCreate an index on OpenSearch based on the provided settings- Specified by:
ensureExistsin interfaceOpenSearchIndexManager- Throws:
IOException
-
create
public void create() throws IOExceptionDescription copied from interface:OpenSearchIndexManagerCreate the index on OpenSearch. This will throw an exception if the index already exists.- Specified by:
createin interfaceOpenSearchIndexManager- Throws:
IOException
-
delete
public void delete() throws IOExceptionDescription copied from interface:OpenSearchIndexManagerDelete the index from OpenSearch.- Specified by:
deletein interfaceOpenSearchIndexManager- Throws:
IOException
-
recreate
public void recreate() throws IOExceptionDescription copied from interface:OpenSearchIndexManagerCreate the new index on OpenSearch based on the provided settings. If it already exists, it will be deleted first.- Specified by:
recreatein interfaceOpenSearchIndexManager- Throws:
IOException
-
onIndexRecreatedRemotely
@EventListener public void onIndexRecreatedRemotely(ClusterEventWrapper eventWrapper)
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
public boolean putIfAbsent(FieldMapping mapping) throws SearchIndexAccessException
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
-
destroy
public void destroy()
- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean
-
-