Class ElasticsearchInitialiser
java.lang.Object
org.alfresco.repo.search.impl.elasticsearch.contentmodelsync.ElasticsearchInitialiser
- All Implemented Interfaces:
DictionaryListener
Class responsible for initialising Elasticsearch when the subsystem is started.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final QNameThe name of the lock used to ensure that Elasticsearch configuration does not run on more than one node at the same time.static final longThe time this lock will persist in the database (60 sec but refreshed at regular intervals) -
Constructor Summary
ConstructorsConstructorDescriptionElasticsearchInitialiser(DictionaryDAOImpl dictionary, ElasticsearchIndexService elasticsearchIndexService, ContentModelSynchronizer contentModelSynchronizer, JobLockService jobLockService, int retryAttempts, int retryPeriodSeconds, int lockRetryAttempts, int lockRetryPeriodSeconds, boolean createIndexIfNotExists) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidGet a lock before mapping models.intintintintvoidinit()Check if the index exists and attempt to create it if the configuration permits.Async initialisation method, a lock will be used to avoid multiple initialisationvoidInitialisation method, a lock will be used to avoid multiple initialisationbooleanvoidvoidsetContentModelSynchronizer(ContentModelSynchronizer contentModelSynchronizer) voidsetCreateIndexIfNotExists(boolean createIndexIfNotExists) voidsetDictionaryDAO(DictionaryDAOImpl dictionaryDAO) voidsetElasticsearchIndexService(ElasticsearchIndexService elasticsearchIndexService) voidsetJobLockService(JobLockService jobLockService) voidsetLockRetryAttempts(int lockRetryAttempts) voidsetLockRetryPeriodSeconds(int lockRetryPeriodSeconds) voidsetRetryAttempts(int retryAttempts) voidsetRetryPeriodSeconds(int retryPeriodSeconds) voidstop()Stop the index initialization.
-
Field Details
-
LOCK_QNAME
The name of the lock used to ensure that Elasticsearch configuration does not run on more than one node at the same time. -
LOCK_TTL
public static final long LOCK_TTLThe time this lock will persist in the database (60 sec but refreshed at regular intervals)- See Also:
-
-
Constructor Details
-
ElasticsearchInitialiser
public ElasticsearchInitialiser(DictionaryDAOImpl dictionary, ElasticsearchIndexService elasticsearchIndexService, ContentModelSynchronizer contentModelSynchronizer, JobLockService jobLockService, int retryAttempts, int retryPeriodSeconds, int lockRetryAttempts, int lockRetryPeriodSeconds, boolean createIndexIfNotExists) -
ElasticsearchInitialiser
public ElasticsearchInitialiser()
-
-
Method Details
-
stop
public void stop()Stop the index initialization. This method is required when the Spring context is reloaded in order to stop the asynchronous initialization. -
initAsync
Async initialisation method, a lock will be used to avoid multiple initialisation- Returns:
- the started thread created to execute the asynchronous initialisation.
-
initWithLock
public void initWithLock()Initialisation method, a lock will be used to avoid multiple initialisation -
init
public void init()Check if the index exists and attempt to create it if the configuration permits. When creating the index then also load the analysers and the basic mappings. Retry periodically on failure, and only return once the index exists. The index will be automatically created only if elasticsearch.createIndexIfNotExists property is true. -
onDictionaryInit
public void onDictionaryInit()- Specified by:
onDictionaryInitin interfaceDictionaryListener
-
afterDictionaryDestroy
public void afterDictionaryDestroy()- Specified by:
afterDictionaryDestroyin interfaceDictionaryListener
-
afterDictionaryInit
public void afterDictionaryInit()Get a lock before mapping models. Reuse the same lock asinitWithLock().- Specified by:
afterDictionaryInitin interfaceDictionaryListener
-
getDictionaryDAO
-
setDictionaryDAO
-
getContentModelSynchronizer
-
getElasticsearchIndexService
-
isCreateIndexIfNotExists
public boolean isCreateIndexIfNotExists() -
getRetryAttempts
public int getRetryAttempts() -
getLockRetryAttempts
public int getLockRetryAttempts() -
getLockRetryPeriodSeconds
public int getLockRetryPeriodSeconds() -
getJobLockService
-
setJobLockService
-
getRetryPeriodSeconds
public int getRetryPeriodSeconds() -
setContentModelSynchronizer
-
setElasticsearchIndexService
-
setCreateIndexIfNotExists
public void setCreateIndexIfNotExists(boolean createIndexIfNotExists) -
setRetryAttempts
public void setRetryAttempts(int retryAttempts) -
setLockRetryPeriodSeconds
public void setLockRetryPeriodSeconds(int lockRetryPeriodSeconds) -
setRetryPeriodSeconds
public void setRetryPeriodSeconds(int retryPeriodSeconds) -
setLockRetryAttempts
public void setLockRetryAttempts(int lockRetryAttempts)
-