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 returnsnull
Readiness latch allows consuming application to control exactly when
CTS
may start it's routine:- if the future will resolve with
true
,CTS
will run normally - if the future will resolve with
false
or throw,CTS
will halt, logging the error - if the future will not resolve,
CTS
will hang forever waiting for resolution
In case the SPI returns
null
,CTS
considers it as an immediate truthy resolution. - if the future will resolve with
-
DataSource getDataSource()
- requiredMust provide properly configured
DataSource
object, pointing to the relevant schema. This is the data source that will be used to manage allDB
typed tasks. -
DataSource getAdministrativeDataSource()
- optional, default implementation returnsnull
Administrative 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 letCTS
to 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
DataSource
object/s provided bygetDataSource
and, optionally,getAdministrativeDataSource
SPI/s. -
boolean isEnabled()
- optional, default implementation returnstrue
Allows consuming application to control
CTS
's execution at 'runtime'.CTS
calls 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
CTS
instance is stopped, other instances (running on otherJVM
s 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;
CTS
will measure this call duration among other 'foreign' calls (see monitoring documentation)
- only the current