Class ThreadingService


  • @Service
    public class ThreadingService
    extends Object
    A service that manages long-lived jobs, such as synchronization providers execution, view rendering or management tasks execution.
    Author:
    Charles Edward Bedon Cortazar <charles.bedon@kuwaiba.org>
    • Field Detail

      • PARALLEL_LIMIT

        public static final int PARALLEL_LIMIT
        The number of registered jobs after which a parallel access to the table will be attempted.
        See Also:
        Constant Field Values
      • TABLE_SIZE

        public static final int TABLE_SIZE
        Max number of jobs that can be managed by the threading service at once.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ThreadingService

        public ThreadingService()
    • Method Detail

      • getJob

        public ManagedJobDescriptor getJob​(String jobId)
        Looks up a job in the job table (if existing).
        Parameters:
        jobId - The id of the job.
        Returns:
        The job, if present, or null otherwise.
      • startJob

        public void startJob​(ManagedJob theJob)
                      throws IllegalArgumentException
        Registers and starts a job.
        Parameters:
        theJob - The job to be started.
        Throws:
        IllegalArgumentException - If the job could not be started, most likely because of its state. Also, if theDescriptor is a job that already exists in the table, or if TABLE_SIZE limit has been reached.
      • clearCompletedJobs

        public void clearCompletedJobs()
                                throws IllegalArgumentException
        Removes all jobs in the current job list, provided that they are not running.
        Throws:
        IllegalArgumentException - If at least one job is running. If that's the case, no