Interface CronJobService

All Known Implementing Classes:
DefaultCronJobService

public interface CronJobService
Service for cronjob handling covering business methods for data manipulation and search methods.
Since:
4.0
Spring Bean ID:
cronJobService
  • Method Details

    • performCronJob

      void performCronJob(CronJobModel model, boolean synchronous)
      Performs given Cronjob by starting its Job. If synchronous is true, the Job will be performed synchronous, which means that this method will return the control to its caller as recently as this Job is performed. Synchronous execution is especially useful for short Jobs or testing purpose (JUnit tests for example).
      If synchronous is false, the Job will be performed asynchronous by executing the Job in a separate Thread. This method ignores a nodeId CronJobModel.getNodeID() and does not start a Job on the cluster node.
      Parameters:
      model - which will be used
      synchronous - true if the Job should be performed synchronously, false if the Job should be performed asynchronously
    • performCronJob

      void performCronJob(CronJobModel model)
      Performs given Cronjob by starting its Job on the cluster node. The node is given by JobModel.getNodeID(), the Job will be performed asynchronous, which means that this method will return the control to its caller as recently as this Job is performed. Call for a CronJobModel with nodeId CronJobModel.getNodeID() equal to current nodeId ClusterService.getClusterId() is the same as call performCronJob(CronJobModel, boolean) with synchronous equal false
      Parameters:
      model - which will be used
    • requestAbortCronJob

      void requestAbortCronJob(CronJobModel model)
      This method applies only to CronJobModel instance with status as CronJobStatus.RUNNING OR CronJobStatus.RUNNINGRESTART Sets the request abort attribute CronJobModel.REQUESTABORTto true for a given Cronjob. The logic in CronJob itself has to finish and set result from cronjob execution CronJobModel.getStatus() as different than CronJobStatus.RUNNING AND CronJobStatus.RUNNINGRESTART. Method throws IllegalStateException if the given CronJob is not performable.
      Parameters:
      model - which will be used
    • getCronJob

      CronJobModel getCronJob(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 found
      AmbiguousIdentifierException - in case more than one cronjob is found
    • getJob

      JobModel getJob(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 found
      AmbiguousIdentifierException - 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:
      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:
      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

      List<CronJobModel> getRunningOrRestartedCronJobs()
      Returns list of CronJobModel instances 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)
      Returns JobPerformable bean instance for a ServicelayerJobModel see BeanFactory.getBean(String).
    • getCronJobFactory

      <C extends CronJobModel, J extends JobModel> CronJobFactory<C,J> getCronJobFactory(ServicelayerJobModel slayerJobModel)
      Returns CronJobFactory bean instance for a ServicelayerJobModel see BeanFactory.getBean(String).
    • getLogsAsText

      String getLogsAsText(CronJobModel cronjob)
      Returns text representation of top 500 CronJobModel.getLogs() entries for a given CronJobModel, as concatenated and decorated content of its JobLogModel.getMessage().
    • getLogsAsText

      String getLogsAsText(CronJobModel cronjob, int count)
      Returns text representation of top given count CronJobModel.getLogs() entries for a given CronJobModel, as concatenated and decorated content of its JobLogModel.getMessage().