Interface CronJobService
-
- All Known Subinterfaces:
ImportCockpitCronJobService
- All Known Implementing Classes:
DefaultCronJobService,DefaultImportCockpitCronJobService
public interface CronJobServiceService for cronjob handling covering business methods for data manipulation and search methods.- Since:
- 4.0
- Spring Bean ID:
- cronJobService
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CronJobModelgetCronJob(java.lang.String code)Gets the cronjob identified unique by given code.<C extends CronJobModel,J extends JobModel>
CronJobFactory<C,J>getCronJobFactory(ServicelayerJobModel slayerJobModel)JobModelgetJob(java.lang.String code)Gets the job identified unique by given code.java.lang.StringgetLogsAsText(CronJobModel cronjob)Returns text representation of top 500CronJobModel.getLogs()entries for a givenCronJobModel, as concatenated and decorated content of itsJobLogModel.getMessage().java.lang.StringgetLogsAsText(CronJobModel cronjob, int count)Returns text representation of top givencountCronJobModel.getLogs()entries for a givenCronJobModel, as concatenated and decorated content of itsJobLogModel.getMessage().JobPerformable<? extends CronJobModel>getPerformable(ServicelayerJobModel slayerJobModel)java.util.List<CronJobModel>getRunningOrRestartedCronJobs()Returns list ofCronJobModelinstances running on the platform regardless the cluster node.booleanisAbortable(CronJobModel cronJob)Checks if the cronjob model is abortable.booleanisError(CronJobModel cronJob)Checks whether the cronjob was executed not successfully.booleanisFinished(CronJobModel cronJob)Checks whether the cronjob has finished execution and is not running or paused anymore.booleanisPaused(CronJobModel cronJob)Checks whether the cronjob is paused.booleanisPerformable(CronJobModel cronJob)Checks if the cronjob model is performable.booleanisRunning(CronJobModel cronJob)Checks whether the cronjob has not finished or paused execution yet and is still running regardless if has it been restarted or not.booleanisSuccessful(CronJobModel cronJob)Checks whether the cronjob was executed successfully.voidperformCronJob(CronJobModel model)Performs givenCronjobby starting itsJobon the cluster node.voidperformCronJob(CronJobModel model, boolean synchronous)Performs givenCronjobby starting itsJob.voidrequestAbortCronJob(CronJobModel model)This method applies only to CronJobModel instance with status asCronJobStatus.RUNNINGORCronJobStatus.RUNNINGRESTARTSets the request abort attributeCronJobModel.REQUESTABORTto true for a givenCronjob.
-
-
-
Method Detail
-
performCronJob
void performCronJob(CronJobModel model, boolean synchronous)
Performs givenCronjobby starting itsJob. If synchronous istrue, theJobwill be performed synchronous, which means that this method will return the control to its caller as recently as thisJobis performed. Synchronous execution is especially useful for short Jobs or testing purpose (JUnit tests for example). If synchronous isfalse, theJobwill be performed asynchronous by executing theJobin a separateThread. This method ignores a nodeIdCronJobModel.getNodeID()and does not start aJobon the cluster node.- Parameters:
model- which will be usedsynchronous-trueif theJobshould be performed synchronously,falseif theJobshould be performed asynchronously
-
performCronJob
void performCronJob(CronJobModel model)
Performs givenCronjobby starting itsJobon the cluster node. The node is given byJobModel.getNodeID(), theJobwill be performed asynchronous, which means that this method will return the control to its caller as recently as thisJobis performed. Call for aCronJobModelwith nodeIdCronJobModel.getNodeID()equal to current nodeIdClusterService.getClusterId()is the same as callperformCronJob(CronJobModel, boolean)withsynchronousequal false- Parameters:
model- which will be used
-
requestAbortCronJob
void requestAbortCronJob(CronJobModel model)
This method applies only to CronJobModel instance with status asCronJobStatus.RUNNINGORCronJobStatus.RUNNINGRESTARTSets the request abort attributeCronJobModel.REQUESTABORTto true for a givenCronjob. The logic in CronJob itself has to finish and set result from cronjob executionCronJobModel.getStatus()as different thanCronJobStatus.RUNNINGANDCronJobStatus.RUNNINGRESTART. Method throws IllegalStateException if the given CronJob is not performable.- Parameters:
model- which will be used
-
getCronJob
CronJobModel getCronJob(java.lang.String code)
Gets the cronjob identified unique by given code.- Parameters:
code- code for which a cronjob is needed- Returns:
- cronjob identified unique by given code
- Throws:
UnknownIdentifierException- in case no cronjob is foundAmbiguousIdentifierException- in case more than one cronjob is found
-
getJob
JobModel getJob(java.lang.String code)
Gets the job identified unique by given code.- Parameters:
code- code for which a job is needed- Returns:
- job identified unique by given code
- Throws:
UnknownIdentifierException- in case no job is foundAmbiguousIdentifierException- in case more than one job is found
-
isSuccessful
boolean isSuccessful(CronJobModel cronJob)
Checks whether the cronjob was executed successfully. Can only be used if cronjob has finished execution (isFinished(CronJobModel)returns true).- Parameters:
cronJob- cronjob to check for- Returns:
- true if cronjob has finished successfully
- Throws:
java.lang.IllegalStateException- in case cronjob is still running
-
isError
boolean isError(CronJobModel cronJob)
Checks whether the cronjob was executed not successfully. Can only be used if cronjob has finished execution (isFinished(CronJobModel)returns true).- Parameters:
cronJob- cronjob to check for- Returns:
- true if cronjob has finished not successfully
- Throws:
java.lang.IllegalStateException- in case cronjob is still running
-
isPaused
boolean isPaused(CronJobModel cronJob)
Checks whether the cronjob is paused.- Parameters:
cronJob- cronjob to check for- Returns:
- true if cronjob is paused
-
isRunning
boolean isRunning(CronJobModel cronJob)
Checks whether the cronjob has not finished or paused execution yet and is still running regardless if has it been restarted or not.- Parameters:
cronJob- cronjob to check for- Returns:
- true if cronjob is still running
-
isFinished
boolean isFinished(CronJobModel cronJob)
Checks whether the cronjob has finished execution and is not running or paused anymore.- Parameters:
cronJob- cronjob to check for- Returns:
- true if cronjob has finished execution
-
getRunningOrRestartedCronJobs
java.util.List<CronJobModel> getRunningOrRestartedCronJobs()
Returns list ofCronJobModelinstances running on the platform regardless the cluster node.
-
isPerformable
boolean isPerformable(CronJobModel cronJob)
Checks if the cronjob model is performable.- Parameters:
cronJob- which will be used
-
isAbortable
boolean isAbortable(CronJobModel cronJob)
Checks if the cronjob model is abortable.- Parameters:
cronJob- which will be used
-
getPerformable
JobPerformable<? extends CronJobModel> getPerformable(ServicelayerJobModel slayerJobModel)
-
getCronJobFactory
<C extends CronJobModel,J extends JobModel> CronJobFactory<C,J> getCronJobFactory(ServicelayerJobModel slayerJobModel)
-
getLogsAsText
java.lang.String getLogsAsText(CronJobModel cronjob)
Returns text representation of top 500CronJobModel.getLogs()entries for a givenCronJobModel, as concatenated and decorated content of itsJobLogModel.getMessage().
-
getLogsAsText
java.lang.String getLogsAsText(CronJobModel cronjob, int count)
Returns text representation of top givencountCronJobModel.getLogs()entries for a givenCronJobModel, as concatenated and decorated content of itsJobLogModel.getMessage().
-
-