CTS configuration design pattern is the SPI pattern.
Consuming/hosting application is expected to implement ClusterTasksServiceConfigurerSPI and add this implementation to the Spring context.
CTS will wire the configurer, validate it and use it to get any required information provided by consuming application.
If configurer is not available or some of essential data is missing CTS will fail-fast (failing Spring context loading).
-
CompletableFuture<Boolean> getConfigReadyLatch()- optional, default implementation returnsnullReadiness latch allows consuming application to control exactly when
CTSmay start it's routine:- if the future will resolve with
true,CTSwill run normally - if the future will resolve with
falseor throw,CTSwill halt, logging the error - if the future will not resolve,
CTSwill hang forever waiting for resolution
In case the SPI returns
null,CTSconsiders it as an immediate truthy resolution. - if the future will resolve with
-
DataSource getDataSource()- requiredMust provide properly configured
DataSourceobject, pointing to the relevant schema. This is the data source that will be used to manage allDBtyped tasks. -
DataSource getAdministrativeDataSource()- optional, default implementation returnsnullAdministrative data source, if/when provided, will be used for auto schema management. Therefore it is either the consuming application responsibility to provide a correct schema for the
CTS, or letCTSto manage it by providing relevant data source in this SPI. The user configured in this data source MUST be privileged enough to perform schema changes. -
DBType getDbType()- requiredOne of the supported DB types. This will be assumed the DB type, that is referred to in the
DataSourceobject/s provided bygetDataSourceand, optionally,getAdministrativeDataSourceSPI/s. -
boolean isEnabled()- optional, default implementation returnstrueAllows consuming application to control
CTS's execution at 'runtime'.CTScalls this SPI each dispatch and maintenance cycle, meaning effective, that consumer may stop or resume the queue within at most 1 second. Pay attention to the following details:- only the current
CTSinstance is stopped, other instances (running on otherJVMs or even in another Spring context on the sameJVM) will not be affected - this SPI is expected to run as fast as possible, it is called on the thread of the main event loops (dispatch, maintenance), thus directly affecting the speed of the queue;
CTSwill measure this call duration among other 'foreign' calls (see monitoring documentation)
- only the current