Package org.nuxeo.elasticsearch.core
Class ElasticSearchAdminImpl
java.lang.Object
org.nuxeo.elasticsearch.core.ElasticSearchAdminImpl
- All Implemented Interfaces:
ElasticSearchAdmin
- Since:
- 6.0
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected ESClient
protected final ElasticSearchClientConfig
protected ElasticSearchEmbeddedNode
protected final ElasticSearchEmbeddedServerConfig
static final String
protected String[]
protected Map<String,
ESHintQueryBuilder> protected String[]
protected final Map<String,
ElasticSearchIndexConfig> protected boolean
static final String
protected final ElasticSearchAdminImpl.ReindexingPubSub
protected static final int
protected static final int
protected final AtomicInteger
protected boolean
-
Constructor Summary
ConstructorDescriptionElasticSearchAdminImpl
(ElasticSearchEmbeddedServerConfig embeddedServerConfig, ElasticSearchClientConfig clientConfig, Map<String, ElasticSearchIndexConfig> indexConfig, Collection<ESHintQueryBuilderDescriptor> hintDescriptors) Init the admin service, remote configuration if not null will take precedence over local embedded configuration. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkClusterHealth
(String... indexNames) protected void
protected void
connect()
protected ESClient
void
void
dropAndInitIndex
(String indexName) Reinitialize an index.void
dropAndInitRepositoryIndex
(String repositoryName, boolean syncAlias) Reinitialize the index of a repository.void
flush()
Elasticsearch flush on all document indexes, triggers a lucene commit, empties the transaction log.void
flushRepositoryIndex
(String repositoryName) Elasticsearch flush on document index for a specific repository, triggers a lucene commit, empties the transaction log.Retrieves theClient
that can be used to access Elasticsearch APIprotected String[]
getHintByOperator
(String name) Returns the hint by the Elasticsearch operator name.protected String[]
getIndexNameForRepository
(String repositoryName) Get the search index name associated with the repository name.getIndexNameForType
(String type) Get the first search index name with the given type.getIndexNamesForType
(String type) Get the index names with the given type.Get the list of repository names that have their index created.protected KeyValueStore
long
Returns the number of indexing worker scheduled waiting to be executed.getRepositoryForIndex
(String indexName) Gets the repository name associated with the index.List repository names that have Elasticsearch support.long
Returns the number of indexing worker that are currently running.protected String[]
getSearchIndexes
(List<String> searchRepositories) Get the elastic search indexes for searchesgetSecondaryWriteIndexName
(String searchIndexName) Returns the secondary write index used during re-indexing with aliases.int
Returns the total number of command processed by Elasticsearch for this Nuxeo instance.getWriteIndexName
(String searchIndexName) Returns the index to use for any write operations.protected void
protected void
initIndex
(String indexName, ElasticSearchIndexConfig conf, boolean dropIfExists) protected void
initIndex
(ElasticSearchIndexConfig conf, boolean dropIfExists) protected void
initIndex
(ElasticSearchIndexConfig conf, boolean dropIfExists, boolean syncAlias) void
initIndexes
(boolean dropIfExists) Initialize Elasticsearch indexes.void
initRepositoryIndexWithAliases
(String repositoryName) Creates a new index for the repository applying the mapping and settings.protected void
protected void
initWriteAlias
(ElasticSearchIndexConfig conf, boolean create) boolean
Returns true if the Elasticsearch is embedded with Nuxeo, sharing the same JVM.boolean
Returns true if there are indexing activities scheduled or running.boolean
isReady()
void
optimize()
Elasticsearch runElasticSearchAdmin.optimizeRepositoryIndex(java.lang.String)
on all document indexes,void
optimizeIndex
(String indexName) Elasticsearch optimize operation allows to reduce the number of segments to one, Note that this can potentially be a very heavy operation.void
optimizeRepositoryIndex
(String repositoryName) Elasticsearch optimize operation allows to reduce the number of segments to one, Note that this can potentially be a very heavy operation.com.google.common.util.concurrent.ListenableFuture<Boolean>
AFuture
that accepts callback on completion when all the indexing worker are done.void
refresh()
Refresh all document indexes, immediately after the operation occurs, so that the updated document appears in search results immediately.void
refreshRepositoryIndex
(String repositoryName) Refresh document index for the specific repository, immediately after the operation occurs, so that the updated document appears in search results immediately.void
syncSearchAndWriteAlias
(String searchIndexName) Make sure that the search alias point to the same index as the write alias.protected void
Update the search index to point to the write index.boolean
When true use an external version for Elasticsearch document, this enable an optimistic concurrency control ensuring that an older version of a document never overwrites a newer version.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.nuxeo.elasticsearch.api.ElasticSearchAdmin
dropAndInitRepositoryIndex
-
Field Details
-
TIMEOUT_WAIT_FOR_CLUSTER_SECOND
protected static final int TIMEOUT_WAIT_FOR_CLUSTER_SECOND- See Also:
-
TIMEOUT_DELETE_SECOND
protected static final int TIMEOUT_DELETE_SECOND- See Also:
-
ES_KV_STORE
- See Also:
-
totalCommandProcessed
-
indexNames
-
repoNames
-
writeIndexNames
-
secondaryWriteIndexNames
-
useSecondaryWriteIndex
protected boolean useSecondaryWriteIndex -
reindexingPubSub
-
REINDEXING_PUBSUB_TOPIC
- See Also:
-
indexConfig
-
hints
-
embeddedServerConfig
-
clientConfig
-
embeddedServer
-
client
-
indexInitDone
protected boolean indexInitDone -
includeSourceFields
-
excludeSourceFields
-
repositoryInitialized
-
-
Constructor Details
-
ElasticSearchAdminImpl
public ElasticSearchAdminImpl(ElasticSearchEmbeddedServerConfig embeddedServerConfig, ElasticSearchClientConfig clientConfig, Map<String, ElasticSearchIndexConfig> indexConfig, Collection<ESHintQueryBuilderDescriptor> hintDescriptors) Init the admin service, remote configuration if not null will take precedence over local embedded configuration. The transport client initialization can be customized.- Since:
- 9.1
-
-
Method Details
-
checkConfig
protected void checkConfig() -
connect
protected void connect() -
disconnect
public void disconnect() -
createClient
-
checkClusterHealth
-
initializeIndexes
protected void initializeIndexes() -
refreshRepositoryIndex
Description copied from interface:ElasticSearchAdmin
Refresh document index for the specific repository, immediately after the operation occurs, so that the updated document appears in search results immediately. There is no fsync thus doesn't guarantee durability.- Specified by:
refreshRepositoryIndex
in interfaceElasticSearchAdmin
-
getIndexNameForRepository
Description copied from interface:ElasticSearchAdmin
Get the search index name associated with the repository name.- Specified by:
getIndexNameForRepository
in interfaceElasticSearchAdmin
-
getRepositoryForIndex
Description copied from interface:ElasticSearchAdmin
Gets the repository name associated with the index.- Specified by:
getRepositoryForIndex
in interfaceElasticSearchAdmin
-
getIndexNamesForType
Description copied from interface:ElasticSearchAdmin
Get the index names with the given type.- Specified by:
getIndexNamesForType
in interfaceElasticSearchAdmin
-
getIndexNameForType
Description copied from interface:ElasticSearchAdmin
Get the first search index name with the given type.- Specified by:
getIndexNameForType
in interfaceElasticSearchAdmin
-
getWriteIndexName
Description copied from interface:ElasticSearchAdmin
Returns the index to use for any write operations.- Specified by:
getWriteIndexName
in interfaceElasticSearchAdmin
-
getSecondaryWriteIndexName
Description copied from interface:ElasticSearchAdmin
Returns the secondary write index used during re-indexing with aliases.- Specified by:
getSecondaryWriteIndexName
in interfaceElasticSearchAdmin
- Returns:
- an index name or null if there is no re-indexing in progress.
-
syncSearchAndWriteAlias
Description copied from interface:ElasticSearchAdmin
Make sure that the search alias point to the same index as the write alias.- Specified by:
syncSearchAndWriteAlias
in interfaceElasticSearchAdmin
-
flushRepositoryIndex
Description copied from interface:ElasticSearchAdmin
Elasticsearch flush on document index for a specific repository, triggers a lucene commit, empties the transaction log. Data is flushed to disk.- Specified by:
flushRepositoryIndex
in interfaceElasticSearchAdmin
-
refresh
public void refresh()Description copied from interface:ElasticSearchAdmin
Refresh all document indexes, immediately after the operation occurs, so that the updated document appears in search results immediately. There is no fsync thus doesn't guarantee durability.- Specified by:
refresh
in interfaceElasticSearchAdmin
-
flush
public void flush()Description copied from interface:ElasticSearchAdmin
Elasticsearch flush on all document indexes, triggers a lucene commit, empties the transaction log. Data is flushed to disk.- Specified by:
flush
in interfaceElasticSearchAdmin
-
optimizeIndex
Description copied from interface:ElasticSearchAdmin
Elasticsearch optimize operation allows to reduce the number of segments to one, Note that this can potentially be a very heavy operation.- Specified by:
optimizeIndex
in interfaceElasticSearchAdmin
-
optimizeRepositoryIndex
Description copied from interface:ElasticSearchAdmin
Elasticsearch optimize operation allows to reduce the number of segments to one, Note that this can potentially be a very heavy operation.- Specified by:
optimizeRepositoryIndex
in interfaceElasticSearchAdmin
-
optimize
public void optimize()Description copied from interface:ElasticSearchAdmin
Elasticsearch runElasticSearchAdmin.optimizeRepositoryIndex(java.lang.String)
on all document indexes,- Specified by:
optimize
in interfaceElasticSearchAdmin
-
getClient
Description copied from interface:ElasticSearchAdmin
Retrieves theClient
that can be used to access Elasticsearch API- Specified by:
getClient
in interfaceElasticSearchAdmin
-
initIndexes
public void initIndexes(boolean dropIfExists) Description copied from interface:ElasticSearchAdmin
Initialize Elasticsearch indexes. Setup the index settings and mapping for each index that has been registered.- Specified by:
initIndexes
in interfaceElasticSearchAdmin
- Parameters:
dropIfExists
- if {true} remove an existing index
-
dropAndInitIndex
Description copied from interface:ElasticSearchAdmin
Reinitialize an index. This will drop the existing index, recreate it with its settings and mapping, the index will be empty.- Specified by:
dropAndInitIndex
in interfaceElasticSearchAdmin
-
dropAndInitRepositoryIndex
Description copied from interface:ElasticSearchAdmin
Reinitialize the index of a repository. This will drop the existing index, recreate it with its settings and mapping, the index will be empty. When syncAlias is false then search alias is not updated with the new index, you need to explicitly callElasticSearchAdmin.syncSearchAndWriteAlias(String)
- Specified by:
dropAndInitRepositoryIndex
in interfaceElasticSearchAdmin
-
initRepositoryIndexWithAliases
Description copied from interface:ElasticSearchAdmin
Creates a new index for the repository applying the mapping and settings. Update the write alias to point to this new index. The search alias is updated to the new index only for the initial creation. Otherwise, there are two write indexes until an explicit call toElasticSearchAdmin.syncSearchAndWriteAlias(String)
.- Specified by:
initRepositoryIndexWithAliases
in interfaceElasticSearchAdmin
-
getRepositoryNames
Description copied from interface:ElasticSearchAdmin
List repository names that have Elasticsearch support.- Specified by:
getRepositoryNames
in interfaceElasticSearchAdmin
-
initIndex
-
initIndex
-
initWriteAlias
-
initSearchAlias
-
syncSearchAndWriteAlias
Update the search index to point to the write index. -
initIndex
-
getPendingWorkerCount
public long getPendingWorkerCount()Description copied from interface:ElasticSearchAdmin
Returns the number of indexing worker scheduled waiting to be executed.- Specified by:
getPendingWorkerCount
in interfaceElasticSearchAdmin
-
getRunningWorkerCount
public long getRunningWorkerCount()Description copied from interface:ElasticSearchAdmin
Returns the number of indexing worker that are currently running.- Specified by:
getRunningWorkerCount
in interfaceElasticSearchAdmin
-
getTotalCommandProcessed
public int getTotalCommandProcessed()Description copied from interface:ElasticSearchAdmin
Returns the total number of command processed by Elasticsearch for this Nuxeo instance. Useful for test assertion.- Specified by:
getTotalCommandProcessed
in interfaceElasticSearchAdmin
-
isEmbedded
public boolean isEmbedded()Description copied from interface:ElasticSearchAdmin
Returns true if the Elasticsearch is embedded with Nuxeo, sharing the same JVM.- Specified by:
isEmbedded
in interfaceElasticSearchAdmin
-
useExternalVersion
public boolean useExternalVersion()Description copied from interface:ElasticSearchAdmin
When true use an external version for Elasticsearch document, this enable an optimistic concurrency control ensuring that an older version of a document never overwrites a newer version.- Specified by:
useExternalVersion
in interfaceElasticSearchAdmin
-
isIndexingInProgress
public boolean isIndexingInProgress()Description copied from interface:ElasticSearchAdmin
Returns true if there are indexing activities scheduled or running.- Specified by:
isIndexingInProgress
in interfaceElasticSearchAdmin
-
prepareWaitForIndexing
Description copied from interface:ElasticSearchAdmin
AFuture
that accepts callback on completion when all the indexing worker are done.- Specified by:
prepareWaitForIndexing
in interfaceElasticSearchAdmin
-
getSearchIndexes
Get the elastic search indexes for searches -
isReady
public boolean isReady() -
getIncludeSourceFields
-
getExcludeSourceFields
-
getRepositoryMap
-
getInitializedRepositories
Get the list of repository names that have their index created. -
getHintByOperator
Description copied from interface:ElasticSearchAdmin
Returns the hint by the Elasticsearch operator name.- Specified by:
getHintByOperator
in interfaceElasticSearchAdmin
-
getKvStore
-