Class ThreadingService
- java.lang.Object
-
- org.neotropic.kuwaiba.core.services.threading.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 Summary
Fields Modifier and Type Field Description static int
PARALLEL_LIMIT
The number of registered jobs after which a parallel access to the table will be attempted.static int
TABLE_SIZE
Max number of jobs that can be managed by the threading service at once.
-
Constructor Summary
Constructors Constructor Description ThreadingService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCompletedJobs()
Removes all jobs in the current job list, provided that they are not running.void
clearJobs()
Removes all jobs in the current job list.ManagedJobDescriptor
getJob(String jobId)
Looks up a job in the job table (if existing).void
killJob(String jobId)
Kills a job.void
startJob(ManagedJob theJob)
Registers and starts a job.
-
-
-
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
-
-
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.
-
killJob
public void killJob(String jobId) throws IllegalArgumentException
Kills a job.- Parameters:
jobId
- The id of the job to kill.- Throws:
IllegalArgumentException
- If the job could not be found, or if found, killed.
-
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, iftheDescriptor
is a job that already exists in the table, or ifTABLE_SIZE
limit has been reached.
-
clearJobs
public void clearJobs() throws IllegalArgumentException
Removes all jobs in the current job list.- Throws:
IllegalArgumentException
- If at least one job is running. If that's the case, no
-
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
-
-