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 void
create()
Create the index on OpenSearch.void
delete()
Delete the index from OpenSearch.void
destroy()
void
ensureExists()
Create an index on OpenSearch based on the provided settingsboolean
exists()
FieldMappings
getFieldMappings()
Get or add field mappings on this index.Index
getIndex()
String
getIndexName()
void
onIndexRecreatedRemotely(ClusterEventWrapper eventWrapper)
When index gets recreated by another node, make sure all mappings registered on this node are present in the index.boolean
putIfAbsent(FieldMapping mapping)
Create the specified field mapping on the underlying index if it is not already present.void
recreate()
Create the new index on OpenSearch based on the provided settings.
-
-
-
Method Detail
-
getIndex
public Index getIndex()
- Specified by:
getIndex
in interfaceOpenSearchIndexManager
- Returns:
- the index managed by this instance
-
getIndexName
public String getIndexName()
- Specified by:
getIndexName
in interfaceOpenSearchIndexManager
- Returns:
- the name of the index on OpenSearch
-
getFieldMappings
public FieldMappings getFieldMappings()
Description copied from interface:OpenSearchIndexManager
Get or add field mappings on this index.- Specified by:
getFieldMappings
in interfaceOpenSearchIndexManager
- Returns:
- field mappings
-
exists
public boolean exists() throws IOException
- Specified by:
exists
in interfaceOpenSearchIndexManager
- Returns:
- true if the index exists, or false if it does not exist
- Throws:
IOException
-
ensureExists
public void ensureExists() throws IOException
Description copied from interface:OpenSearchIndexManager
Create an index on OpenSearch based on the provided settings- Specified by:
ensureExists
in interfaceOpenSearchIndexManager
- Throws:
IOException
-
create
public void create() throws IOException
Description copied from interface:OpenSearchIndexManager
Create the index on OpenSearch. This will throw an exception if the index already exists.- Specified by:
create
in interfaceOpenSearchIndexManager
- Throws:
IOException
-
delete
public void delete() throws IOException
Description copied from interface:OpenSearchIndexManager
Delete the index from OpenSearch.- Specified by:
delete
in interfaceOpenSearchIndexManager
- Throws:
IOException
-
recreate
public void recreate() throws IOException
Description copied from interface:OpenSearchIndexManager
Create the new index on OpenSearch based on the provided settings. If it already exists, it will be deleted first.- Specified by:
recreate
in 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.FieldMappingWriter
Create the specified field mapping on the underlying index if it is not already present.- Specified by:
putIfAbsent
in 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:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
-
-