1 package com.trendmicro.grid.acl.ds; 2 3 import com.trendmicro.grid.acl.ds.datatypes.SharedJob; 4 import com.trendmicro.grid.acl.ds.datatypes.SharedJobDetails; 5 import com.trendmicro.grid.acl.l0.datatypes.Job; 6 import com.trendmicro.grid.acl.l0.datatypes.Source; 7 import com.trendmicro.grid.acl.l0.datatypes.UUIDListPage; 8 9 import java.util.Collection; 10 import java.util.Date; 11 import java.util.List; 12 import java.util.UUID; 13 14 /** 15 * Defines a repository that manages the processing Jobs inside the GRID. 16 * 17 * @author juergen_kellerer, 2010-05-07 18 * @version 1.0 19 */ 20 public interface JobRepository extends Repository { 21 22 /** 23 * Prepares a new processing job and returns the job's GUID. 24 * 25 * @return The GUID of the job. 26 */ 27 UUID createJob(); 28 29 /** 30 * Prepares a new processing job and returns the job's GUID. 31 * 32 * @param parentJobId The id of the parent job to bind this job to. 33 * @return The GUID of the job. 34 */ 35 UUID createSubJob(UUID parentJobId); 36 37 /** 38 * Adds sources to a single processing job. 39 * 40 * @param jobId the id of the job to add the source to. 41 * @param sources The sources to add. 42 */ 43 void addJobSources(UUID jobId, List<Source> sources); 44 45 /** 46 * Adds sources to a single processing job. 47 * 48 * @param job the job to add the source to. 49 * @param sources The sources to add. 50 */ 51 void addJobSources(Job job, List<Source> sources); 52 53 /** 54 * Updates the given job inside the persistent store (= the database) 55 * 56 * @param job the job to update. 57 * @throws IllegalArgumentException in case of the given value is null or doesn't reference an existing job. 58 */ 59 void updateJob(Job job); 60 61 /** 62 * Finalizes the specified job (sets it to the final state) or removes the job if it hasn't been started. 63 * 64 * @param jobId The GUID of the job to finalize. 65 * @param finalJobState the final state of the job or 'null' to finalize / remove a job that hasn't been started. 66 * @throws IllegalArgumentException in case of the final job state is set and not in {@link Job#FINAL_STATES}. 67 */ 68 void finalizeJob(UUID jobId, Job.State finalJobState) throws IllegalArgumentException; 69 70 /** 71 * Finalizes the specified job (sets it to the final state) or removes the job if it hasn't been started. 72 * 73 * @param job The job to finalize. 74 * @param finalJobState the final state of the job or 'null' to finalize / remove a job that hasn't been started. 75 * @throws IllegalArgumentException in case of the final job state is set and not in {@link Job#FINAL_STATES}. 76 */ 77 void finalizeJob(Job job, Job.State finalJobState) throws IllegalArgumentException; 78 79 /** 80 * Returns a paged list of running jobs. 81 * 82 * @param jobState The state of the jobs to list. 83 * @param updatedFromDate The inclusive lower bound for the last-update date value 84 * or 'null' if there is no lower bound. 85 * @param updatedToDate The exclusive upper bound for the last-update date value 86 * or 'null' if there is no upper bound. 87 * @param pageNumber The page number of the list page to return (0 is first page). 88 * @return A single list page for the given page number or 'null' if no jobs are running or the 89 * pageNumber is out of range. 90 */ 91 UUIDListPage getJobsByStateInRange(Job.State jobState, Date updatedFromDate, Date updatedToDate, int pageNumber); 92 93 /** 94 * Returns the state of the given job. 95 * 96 * @param jobId the id of the job to validate the state of. 97 * @return the state of the given job or 'null' no job exists for the given id. 98 */ 99 Job.State getJobState(UUID jobId); 100 101 /** 102 * Returns the read & writable information on the jobs, idenified by its ids. 103 * 104 * @param jobIds The GUIDs of the jobs to retur. 105 * @return the jobs, idenified by its ids. 106 * @ In case of the current user is not 107 * authenticated or doesn't have the right to access the service. 108 */ 109 Collection<SharedJob> getJobs(Collection<UUID> jobIds); 110 111 /** 112 * Returns the detailed information on a job, idenified by its id. 113 * 114 * @param jobId The GUID of the job to return the details for. 115 * @return the details on a job, idenified by its id. 116 * @ In case of the current user is not 117 * authenticated or doesn't have the right to access the service. 118 */ 119 SharedJobDetails getJobDetails(UUID jobId); 120 }