org.apache.sling.event.jobs
Interface JobManager


public interface JobManager

The job manager is the heart of the job event handling. It can be used to manage and monitor the queues.

Since:
3.0

Nested Class Summary
static class JobManager.QueryType
          The requested job types for the query.
 
Method Summary
 org.osgi.service.event.Event findJob(String topic, Map<String,Object> template)
          Find a job - either scheduled or active.
 void forceRemoveJob(String jobId)
          Cancel this job.
 Queue getQueue(String name)
          Return a queue with a specific name (if running)
 Iterable<Queue> getQueues()
          Return an iterator for all available queues.
 Statistics getStatistics()
          Return statistics information about all queues.
 Iterable<TopicStatistics> getTopicStatistics()
          Return statistics information about job topics.
 boolean isJobProcessingEnabled()
          Is job processing enabled?
 JobsIterator queryJobs(JobManager.QueryType type, String topic, Map<String,Object>... templates)
          Return all jobs either running or scheduled.
 boolean removeJob(String jobId)
          Cancel this job.
 void restart()
          Restart the job manager.
 

Method Detail

getStatistics

Statistics getStatistics()
Return statistics information about all queues.


getTopicStatistics

Iterable<TopicStatistics> getTopicStatistics()
Return statistics information about job topics.


getQueue

Queue getQueue(String name)
Return a queue with a specific name (if running)

Parameters:
name - The queue name
Returns:
The queue or null

getQueues

Iterable<Queue> getQueues()
Return an iterator for all available queues.


queryJobs

JobsIterator queryJobs(JobManager.QueryType type,
                       String topic,
                       Map<String,Object>... templates)
Return all jobs either running or scheduled.

Parameters:
type - Required parameter for the type: either all jobs, only queued or only started can be returned.
topic - Topic can be used as a filter, if it is non-null, only jobs with this topic will be returned.
templates - A list of filter property maps. Each map acts like a template. The searched job must match the template (AND query). By providing several maps, different filters are possible (OR query).
Returns:
A non null collection.

findJob

org.osgi.service.event.Event findJob(String topic,
                                     Map<String,Object> template)
Find a job - either scheduled or active. This method searches for an event with the given topic and filter properties. If more than one job matches, the first one found is returned which could be any of the matching jobs.

Parameters:
topic - Topic is required.
template - The map acts like a template. The searched job must match the template (AND query).
Returns:
An event or null

removeJob

boolean removeJob(String jobId)
Cancel this job. Cancelling a job might fail if the job is currently in processing.

Parameters:
jobId - The unique identifer as found in the property JobUtil.JOB_ID.
Returns:
true if the job could be cancelled or does not exist anymore. false otherwise.

forceRemoveJob

void forceRemoveJob(String jobId)
Cancel this job. This method acts like removeJob(String) with the exception that it waits for a job to finish. The job will be removed when this method returns - however this method blocks until the job is finished!

Parameters:
jobId - The unique identifer as found in the property JobUtil.JOB_ID.

restart

void restart()
Restart the job manager. This method restarts the job manager and all queues - currently processed jobs will be finished. The job manager should only be restarted if really necessary!


isJobProcessingEnabled

boolean isJobProcessingEnabled()
Is job processing enabled? It is possible to completly turn off job processing.



Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.