Package com.sun.enterprise.v3.admin
Class JobManagerService
- java.lang.Object
-
- com.sun.enterprise.v3.admin.JobManagerService
-
- All Implemented Interfaces:
JobManager,EventListener,org.glassfish.hk2.api.PostConstruct
@Service(name="job-manager") @Singleton public class JobManagerService extends Object implements JobManager, org.glassfish.hk2.api.PostConstruct, EventListener
This is the implementation for the JobManagerService The JobManager is responsible 1. generating unique ids for jobs 2. serving as a registry for jobs 3. creating threadpools for jobs 4.removing expired jobs- Author:
- Martin Mares, Bhakti Mehta
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.glassfish.api.event.EventListener
EventListener.Event<T>
-
Nested classes/interfaces inherited from interface org.glassfish.api.admin.JobManager
JobManager.Checkpoint
-
-
Field Summary
Fields Modifier and Type Field Description protected static LocalStringManagerImpladminStringsprotected jakarta.xml.bind.JAXBContextjaxbContextprotected FilejobsFile
-
Constructor Summary
Constructors Constructor Description JobManagerService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddToCompletedJobs(CompletedJob job)voidcheckpoint(AdminCommandContext context, Serializable data)Stores current command state.voidcheckpoint(AdminCommand command, AdminCommandContext context)Stores current command state.voidcheckpointAttachement(String jobId, String attachId, Serializable data)longconvert(String input)voiddeleteCheckpoint(File parentDir, String jobId)voidevent(EventListener.Event event)Process a Glassfish/Payara eventJobget(String id)This will return a job associated with the idJobInfogetCompletedJobForId(String id)This is a convenience method to get a completed job with an idJobInfogetCompletedJobForId(String id, File file)JobInfosgetCompletedJobs(File jobsFile)This will load the jobs which have already completed and persisted in the jobs.xmlConcurrentHashMap<String,CompletedJob>getCompletedJobsInfo()ArrayList<JobInfo>getExpiredJobs(File file)This will return a list of jobs which have crossed the JOBS_RETENTION_PERIOD and need to be purgedIterator<Job>getJobs()This returns all the jobs in the registryFilegetJobsFile()This is used to get the jobs file for a jobStringgetNewId()This will return a new id which is unusedConcurrentHashMap<String,CheckpointHelper.CheckpointFilename>getRetryableJobsInfo()ExecutorServicegetThreadPool()JobManager.CheckpointloadCheckpoint(String jobId, Payload.Outbound outbound)<T extends Serializable>
TloadCheckpointAttachement(String jobId, String attachId)SerializableloadCheckpointData(String jobId)Load checkpoint related data.voidpostConstruct()JobInfospurgeCompletedJobForId(String id)This is used to purge a completed job whose id is providedJobInfospurgeCompletedJobForId(String jobId, File file)This method looks for the completed jobs and purges a job which is marked with the jobIdvoidpurgeJob(String id)This will remove the job from the registryprotected voidreapCompletedJobs(File file)voidregisterJob(Job job)This adds the jobsvoidremoveFromCompletedJobs(String id)
-
-
-
Field Detail
-
adminStrings
protected static final LocalStringManagerImpl adminStrings
-
jaxbContext
protected jakarta.xml.bind.JAXBContext jaxbContext
-
jobsFile
protected File jobsFile
-
-
Method Detail
-
getNewId
public String getNewId()
This will return a new id which is unused- Specified by:
getNewIdin interfaceJobManager- Returns:
-
getCompletedJobForId
public JobInfo getCompletedJobForId(String id)
Description copied from interface:JobManagerThis is a convenience method to get a completed job with an id- Specified by:
getCompletedJobForIdin interfaceJobManager- Parameters:
id- the completed Job whose id needs to be looked up- Returns:
- the completed Job
-
registerJob
public void registerJob(Job job) throws IllegalArgumentException
This adds the jobs- Specified by:
registerJobin interfaceJobManager- Parameters:
job-- Throws:
IllegalArgumentException
-
getJobs
public Iterator<Job> getJobs()
This returns all the jobs in the registry- Specified by:
getJobsin interfaceJobManager- Returns:
- The iterator of jobs
-
get
public Job get(String id)
This will return a job associated with the id- Specified by:
getin interfaceJobManager- Parameters:
id- The job whose id matches- Returns:
-
getExpiredJobs
public ArrayList<JobInfo> getExpiredJobs(File file)
This will return a list of jobs which have crossed the JOBS_RETENTION_PERIOD and need to be purged- Returns:
- list of jobs to be purged
-
convert
public long convert(String input)
-
purgeJob
public void purgeJob(String id)
This will remove the job from the registry- Specified by:
purgeJobin interfaceJobManager- Parameters:
id- The job id of the job to be removed
-
getThreadPool
public ExecutorService getThreadPool()
-
getCompletedJobs
public JobInfos getCompletedJobs(File jobsFile)
This will load the jobs which have already completed and persisted in the jobs.xml- Specified by:
getCompletedJobsin interfaceJobManager- Returns:
- JobsInfos which contains information about completed jobs
-
purgeCompletedJobForId
public JobInfos purgeCompletedJobForId(String jobId, File file)
This method looks for the completed jobs and purges a job which is marked with the jobId- Parameters:
jobId- the job to purge- Returns:
- the new list of completed jobs
-
purgeCompletedJobForId
public JobInfos purgeCompletedJobForId(String id)
Description copied from interface:JobManagerThis is used to purge a completed job whose id is provided- Specified by:
purgeCompletedJobForIdin interfaceJobManager- Parameters:
id- the id of the Job which needs to be purged- Returns:
- the new list of completed jobs
-
postConstruct
public void postConstruct()
- Specified by:
postConstructin interfaceorg.glassfish.hk2.api.PostConstruct
-
getJobsFile
public File getJobsFile()
Description copied from interface:JobManagerThis is used to get the jobs file for a job- Specified by:
getJobsFilein interfaceJobManager- Returns:
- the location of the job file
-
addToCompletedJobs
public void addToCompletedJobs(CompletedJob job)
-
removeFromCompletedJobs
public void removeFromCompletedJobs(String id)
-
getCompletedJobsInfo
public ConcurrentHashMap<String,CompletedJob> getCompletedJobsInfo()
-
getRetryableJobsInfo
public ConcurrentHashMap<String,CheckpointHelper.CheckpointFilename> getRetryableJobsInfo()
-
checkpoint
public void checkpoint(AdminCommandContext context, Serializable data) throws IOException
Description copied from interface:JobManagerStores current command state.- Specified by:
checkpointin interfaceJobManager- Throws:
IOException
-
checkpoint
public void checkpoint(AdminCommand command, AdminCommandContext context) throws IOException
Description copied from interface:JobManagerStores current command state.- Specified by:
checkpointin interfaceJobManager- Throws:
IOException
-
checkpointAttachement
public void checkpointAttachement(String jobId, String attachId, Serializable data) throws IOException
- Throws:
IOException
-
loadCheckpointAttachement
public <T extends Serializable> T loadCheckpointAttachement(String jobId, String attachId) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
loadCheckpointData
public Serializable loadCheckpointData(String jobId) throws IOException, ClassNotFoundException
Description copied from interface:JobManagerLoad checkpoint related data.- Specified by:
loadCheckpointDatain interfaceJobManager- Throws:
IOExceptionClassNotFoundException
-
loadCheckpoint
public JobManager.Checkpoint loadCheckpoint(String jobId, Payload.Outbound outbound) throws IOException, ClassNotFoundException
- Throws:
IOExceptionClassNotFoundException
-
reapCompletedJobs
protected void reapCompletedJobs(File file)
-
event
public void event(EventListener.Event event)
Description copied from interface:EventListenerProcess a Glassfish/Payara event- Specified by:
eventin interfaceEventListener
-
-