org.apache.sling.event.jobs
Interface JobManager

All Known Implementing Classes:
JobManagerImpl

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
 Job addJob(String topic, Map<String,Object> properties)
          Add a new job If the topic is null or illegal, no job is created and null is returned.
 Job addJob(String topic, String name, Map<String,Object> properties)
          Add a new job If the topic is null or illegal, no job is created and null is returned.
 org.osgi.service.event.Event findJob(String topic, Map<String,Object> template)
          Deprecated.  
 Collection<Job> findJobs(JobManager.QueryType type, String topic, long limit, Map<String,Object>... templates)
          Return all jobs either running or scheduled.
 void forceRemoveJob(String jobId)
          Deprecated.  
 Job getJob(String topic, Map<String,Object> template)
          Find a job - either scheduled or active.
 Job getJobById(String jobId)
           
 Job getJobByName(String name)
           
 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()
          Deprecated. This method always returns true
 JobsIterator queryJobs(JobManager.QueryType type, String topic, long limit, Map<String,Object>... templates)
          Deprecated.  
 JobsIterator queryJobs(JobManager.QueryType type, String topic, Map<String,Object>... templates)
          Deprecated.  
 boolean removeJob(String jobId)
          Deprecated.  
 boolean removeJobById(String jobId)
          Removes the job even if it is currently in processing.
 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.


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!


addJob

Job addJob(String topic,
           Map<String,Object> properties)
Add a new job If the topic is null or illegal, no job is created and null is returned. A job topic is a hierarchical name separated by dashes, each part has to start with a letter, allowed characters are letters, numbers and the underscore.

Parameters:
topic - The required job topic.
properties - Optional job properties
Returns:
The new job - or null if the job could not be created.
Since:
1.2

addJob

Job addJob(String topic,
           String name,
           Map<String,Object> properties)
Add a new job If the topic is null or illegal, no job is created and null is returned. A job topic is a hierarchical name separated by dashes, each part has to start with a letter, allowed characters are letters, numbers and the underscore. This method allows to specify a job name which should uniquely identify this job. If a job with the same name is started on different instances, the job is still processed only once. However, the topology api in combination with the leader selection provides a better way for dealing with this situation and as jobs with name come with a heavy processing overhead these should be avoided.

Parameters:
topic - The required job topic.
name - Optional unique job name
properties - Optional job properties
Returns:
The new job - or null if the job could not be created.
Since:
1.2

getJobByName

Job getJobByName(String name)
Returns:
A job or null
Since:
1.2

getJobById

Job getJobById(String jobId)
Parameters:
jobId - The unique identifier from Job.getId()
Returns:
A job or null
Since:
1.2

removeJobById

boolean removeJobById(String jobId)
Removes the job even if it is currently in processing. If the job exists and is not in processing, it gets removed from the processing queue. If the job exists and is in processing, it is removed from the persistence layer, however processing is not stopped.

Parameters:
jobId - The unique identifier from Job.getId()
Returns:
true if the job could be removed or does not exist anymore. false otherwise.
Since:
1.2

getJob

Job getJob(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:
A job or null
Since:
1.2

findJobs

Collection<Job> findJobs(JobManager.QueryType type,
                         String topic,
                         long limit,
                         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.
limit - A positive number indicating the maximum number of jobs returned by the iterator. A value of zero or less indicates that all jobs should 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 collection of jobs - the collection might be empty.
Since:
1.2

queryJobs

@Deprecated
JobsIterator queryJobs(JobManager.QueryType type,
                                  String topic,
                                  Map<String,Object>... templates)
Deprecated. 

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.

queryJobs

@Deprecated
JobsIterator queryJobs(JobManager.QueryType type,
                                  String topic,
                                  long limit,
                                  Map<String,Object>... templates)
Deprecated. 

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.
limit - A positive number indicating the maximum number of jobs returned by the iterator.
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.
Since:
1.1

findJob

@Deprecated
org.osgi.service.event.Event findJob(String topic,
                                                Map<String,Object> template)
Deprecated. 

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

@Deprecated
boolean removeJob(String jobId)
Deprecated. 

Cancel this job. Canceling a job might fail if the job is currently in processing.

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

forceRemoveJob

@Deprecated
void forceRemoveJob(String jobId)
Deprecated. 

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 identifier as found in the property JobUtil.JOB_ID.

isJobProcessingEnabled

@Deprecated
boolean isJobProcessingEnabled()
Deprecated. This method always returns true

Is job processing enabled? It is possible to completely turn off job processing.



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