Last update: 2011-06-23

org.proteios.core
Class JobQueueManager

java.lang.Object
  extended by org.proteios.core.JobQueueManager

public final class JobQueueManager
extends Object

This class manages instances of job queue classes.

Version:
2.0
Author:
olle
Last modified
$Date: 2011-05-26 18:27:20 +0200 (Thu, 26 May 2011) $

Constructor Summary
protected JobQueueManager()
          JobQueueManager default constructor.
 
Method Summary
static void addAbortedJobId(int jobId)
          Add job id to the aborted job id list.
 void addJob(JobData jobData, ManageableJobQueueReadOnlyInterface jobQueueReadOnly)
          Add a job to a specific job queue.
 void addPluginExecutionRequest(int jobId, PluginExecutionRequest exec)
          Add PluginExecutionRequest entry for job specified by id.
 void addThread(int jobId, Thread thread)
          Add Thread entry for job specified by id.
protected  boolean allQueuesEmpty()
          Checks if all queues are empty.
static AbortableJobQueueReadOnlyInterface getAbortableJobQueue(int jobId)
          Get a read-only copy of the abortable job queue for a job with specific id.
static ManageableJobQueueReadOnlyInterface getJobQueue(int jobId)
          Get a read-only copy of the job queue for a job with specific id.
static List<ManageableJobQueueReadOnlyInterface> getJobQueueList()
          Get a copy of the job queue list, with ManageableJobQueueReadOnlyInterface elements.
 List<Integer> getJobsStoppedByServerShutdownList()
          Gets id values of Jobs with status EXECUTING or ABORTING that do not belong to a queue, and therefore are remnants left from a server shutdown.
static int getNumInternalJobQueues()
          Get the number of internal job queues.
 List<JobData> getPendingJobsList()
          Gets list of JobData for jobs with no end time set.
static boolean isRunning()
          Check if the job queue manager is running.
 boolean isRunningJobInBlockerChain(Job job)
          Check if a running job exists in the blocker chain for a job.
static int numberOfJobsInJobQueue(String jobQueueDescription)
          Get number of jobs in job queue specified by description.
protected  JobData pollNextJob(ManageableJobQueueReadOnlyInterface jobQueueReadOnly)
          Retrieves next (first) job in queue and removes it from the queue.
protected  void populateQueue(ManageableJobQueueInterface jobQueue)
          Populate an empty job queue with waiting jobs.
protected  void populateQueues()
          Checks if there are any jobs to be loaded in empty job queues.
 List<JobData> putJobInHighPriorityQueue(Job job)
          Put job and its non-finished blocker jobs in high priority job queue.
static void putManageableJobQueueEntry(int jobId, ManageableJobQueueInterface manageableJobQueue)
          Put entry on the job id, manageable job queue hash map.
static void removeAbortedJobId(int jobId)
          Remove job id from the aborted job id list.
static void removeManageableJobQueueEntry(int jobId)
          Remove entry from the job id, manageable job queue hash map.
 void removePluginExecutionRequest(int jobId)
          Remove PluginExecutionRequest entry for job specified by id.
 void removeThread(int jobId)
          Remove Thread entry for job specified by id.
protected  void start()
          Starts the job queue manager.
protected  void stop()
          Stops the job queue manager.
protected  void updateStatusForAbortedJobsInQueue(ManageableJobQueueReadOnlyInterface jobQueueReadOnly)
          Updates abort status for jobs in a job queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobQueueManager

protected JobQueueManager()
JobQueueManager default constructor.

Method Detail

getNumInternalJobQueues

public static int getNumInternalJobQueues()
Get the number of internal job queues.

Returns:
int The default number of internal job queus.

getJobQueueList

public static List<ManageableJobQueueReadOnlyInterface> getJobQueueList()
Get a copy of the job queue list, with ManageableJobQueueReadOnlyInterface elements.


putManageableJobQueueEntry

public static void putManageableJobQueueEntry(int jobId,
                                              ManageableJobQueueInterface manageableJobQueue)
Put entry on the job id, manageable job queue hash map.

Parameters:
jobId - int The job id.
manageableJobQueue - The manageable job queue.

removeManageableJobQueueEntry

public static void removeManageableJobQueueEntry(int jobId)
Remove entry from the job id, manageable job queue hash map.

Parameters:
jobId - int The job id.

getJobQueue

public static ManageableJobQueueReadOnlyInterface getJobQueue(int jobId)
Get a read-only copy of the job queue for a job with specific id.

Parameters:
jobId - int The job id.
Returns:
ManageableJobQueueReadOnlyInterface A read-only copy of the job queue for the job.

getAbortableJobQueue

public static AbortableJobQueueReadOnlyInterface getAbortableJobQueue(int jobId)
Get a read-only copy of the abortable job queue for a job with specific id.

Parameters:
jobId - int The job id.
Returns:
AbortableJobQueueReadOnlyInterface A read-only copy of the abortable job queue for the job.

numberOfJobsInJobQueue

public static int numberOfJobsInJobQueue(String jobQueueDescription)
Get number of jobs in job queue specified by description.

Parameters:
jobQueueDescription - String Description defining job queue.
Returns:
int The number of jobs in the specified job queue.

addJob

public void addJob(JobData jobData,
                   ManageableJobQueueReadOnlyInterface jobQueueReadOnly)
Add a job to a specific job queue.

Parameters:
jobData - JobData The job data.
jobQueueReadOnly - ManageableJobQueueReadOnlyInterface The manageable job queue.

addAbortedJobId

public static void addAbortedJobId(int jobId)
Add job id to the aborted job id list.

Parameters:
jobId - The job id to add to the aborted job id list.

removeAbortedJobId

public static void removeAbortedJobId(int jobId)
Remove job id from the aborted job id list.

Parameters:
jobId - int The job id to remove from the aborted job id list.

addPluginExecutionRequest

public void addPluginExecutionRequest(int jobId,
                                      PluginExecutionRequest exec)
Add PluginExecutionRequest entry for job specified by id.

Parameters:
jobId - The job id.
exec - The PluginExecutionRequest.

removePluginExecutionRequest

public void removePluginExecutionRequest(int jobId)
Remove PluginExecutionRequest entry for job specified by id.

Parameters:
jobId - The job id.

addThread

public void addThread(int jobId,
                      Thread thread)
Add Thread entry for job specified by id.

Parameters:
jobId - The job id.
thread - The thread.

removeThread

public void removeThread(int jobId)
Remove Thread entry for job specified by id.

Parameters:
jobId - The job id.

isRunning

public static boolean isRunning()
Check if the job queue manager is running.

Returns:
TRUE if the job queue manager is running, FALSE otherwise
See Also:
start(), stop()

start

protected void start()
              throws BaseException
Starts the job queue manager.

Throws:
BaseException - If the job queue manager cannot be started

stop

protected void stop()
             throws BaseException
Stops the job queue manager. If the job queue manager is not running this method does nothing.

Throws:
BaseException - If the job queue manager cannot be stopped.
See Also:
start(), isRunning()

allQueuesEmpty

protected boolean allQueuesEmpty()
Checks if all queues are empty.

Returns:
boolean True if all queues are empty, else false.

populateQueues

protected void populateQueues()
Checks if there are any jobs to be loaded in empty job queues.


populateQueue

protected void populateQueue(ManageableJobQueueInterface jobQueue)
Populate an empty job queue with waiting jobs.

Parameters:
jobQueue - ManageableJobQueueInterface The job queue to populate.

putJobInHighPriorityQueue

public List<JobData> putJobInHighPriorityQueue(Job job)
Put job and its non-finished blocker jobs in high priority job queue.

Parameters:
job - Job The job to put in a queue.
Returns:
List List of jobData for jobs moved to queue.

updateStatusForAbortedJobsInQueue

protected void updateStatusForAbortedJobsInQueue(ManageableJobQueueReadOnlyInterface jobQueueReadOnly)
Updates abort status for jobs in a job queue.

Parameters:
jobQueueReadOnly - ManageableJobQueueReadOnlyInterface The job queue to update the jobs' abort status for.

pollNextJob

protected JobData pollNextJob(ManageableJobQueueReadOnlyInterface jobQueueReadOnly)
Retrieves next (first) job in queue and removes it from the queue.

Parameters:
jobQueueReadOnly - ManageableJobQueueReadOnlyInterface The job queue to update the jobs' abort status for.
Returns:
JobData The job data at the head of the queue, or null if job queue was not found.

getJobsStoppedByServerShutdownList

public List<Integer> getJobsStoppedByServerShutdownList()
Gets id values of Jobs with status EXECUTING or ABORTING that do not belong to a queue, and therefore are remnants left from a server shutdown.

Returns:
List List of id values for executing or aborting jobs.

getPendingJobsList

public List<JobData> getPendingJobsList()
Gets list of JobData for jobs with no end time set.

Returns:
List List of JobData for jobs with no end time set.

isRunningJobInBlockerChain

public boolean isRunningJobInBlockerChain(Job job)
Check if a running job exists in the blocker chain for a job. A running job is defined as a job that is either executing or aborting.

Parameters:
job - Job The job to be checked.
Returns:
boolean Returns true if a running job exists in the chain, else false.

Last update: 2011-06-23