|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.sling.event.impl.jobs.stats.StatisticsImpl
org.apache.sling.event.impl.jobs.JobManagerImpl
@Service(value={JobManager.class,org.osgi.service.event.EventHandler.class,org.apache.sling.discovery.TopologyEventListener.class,java.lang.Runnable.class}) @Properties(value={@Property(name="repository.path",value="/var/eventing/jobs"),@Property(name="scheduler.period",longValue=60L),@Property(name="scheduler.concurrent",boolValue=false),@Property(name="event.topics",value={"org/apache/sling/api/resource/Resource/ADDED","org/apache/sling/event/notification/job/*","org/osgi/framework/BundleEvent/STARTED","org/osgi/framework/BundleEvent/UPDATED"})}) public class JobManagerImpl
Implementation of the job manager.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.sling.event.jobs.JobManager |
---|
JobManager.QueryType |
Constructor Summary | |
---|---|
JobManagerImpl()
|
Method Summary | |
---|---|
protected void |
activate(Map<String,Object> props)
Activate this component. |
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. |
protected void |
deactivate()
Deactivate this component. |
org.osgi.service.event.Event |
findJob(String topic,
Map<String,Object> template)
Find a job - either scheduled or active. |
Collection<Job> |
findJobs(JobManager.QueryType type,
String topic,
long limit,
Map<String,Object>... templates)
Return all jobs either running or scheduled. |
void |
finished(JobHandler info)
|
void |
forceRemoveJob(String jobId)
Cancel this job. |
Job |
getJob(String topic,
Map<String,Object> template)
Find a job - either scheduled or active. |
Job |
getJobById(String id)
|
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 our internal statistics object. |
Iterable<TopicStatistics> |
getTopicStatistics()
Return statistics information about job topics. |
TopologyCapabilities |
getTopologyCapabilities()
|
void |
handleEvent(org.osgi.service.event.Event event)
|
void |
handleTopologyEvent(org.apache.sling.discovery.TopologyEvent event)
|
boolean |
isJobProcessingEnabled()
Is job processing enabled? |
JobsIterator |
queryJobs(JobManager.QueryType type,
String topic,
long limit,
Map<String,Object>... templates)
Return all jobs either running or scheduled. |
JobsIterator |
queryJobs(JobManager.QueryType type,
String topic,
Map<String,Object>... templates)
Return all jobs either running or scheduled. |
void |
reassign(JobHandler handler)
|
boolean |
remove(JobImpl job)
Remove the job. |
boolean |
removeJob(String jobId)
Cancel this job. |
boolean |
removeJobById(String jobId)
Removes the job even if it is currently in processing. |
boolean |
reschedule(JobHandler info)
Reschedule a job. |
void |
reset()
Clear all collected statistics and set the starting time to the current time. |
void |
restart()
Restart the job manager. |
void |
run()
This method is invoked periodically by the scheduler. |
boolean |
start(JobHandler info)
Try to start the job |
protected void |
update(Map<String,Object> props)
Configure this component. |
Methods inherited from class org.apache.sling.event.impl.jobs.stats.StatisticsImpl |
---|
add, addActive, cancelledJob, clearQueued, copyFrom, decQueued, failedJob, finishedJob, getAverageProcessingTime, getAverageWaitingTime, getLastActivatedJobTime, getLastFinishedJobTime, getNumberOfActiveJobs, getNumberOfCancelledJobs, getNumberOfFailedJobs, getNumberOfFinishedJobs, getNumberOfJobs, getNumberOfProcessedJobs, getNumberOfQueuedJobs, getStartTime, incQueued |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JobManagerImpl()
Method Detail |
---|
@Activate protected void activate(Map<String,Object> props) throws org.apache.sling.api.resource.LoginException
props
- Configuration properties
org.apache.sling.api.resource.LoginException
@Modified protected void update(Map<String,Object> props)
props
- Configuration properties@Deactivate protected void deactivate()
public void run()
run
in interface Runnable
Runnable.run()
public void reset()
Statistics
reset
in interface Statistics
reset
in class StatisticsImpl
Reset this statistics and all queues.
public void restart()
JobManager
restart
in interface JobManager
JobManager.restart()
public boolean isJobProcessingEnabled()
JobManager
isJobProcessingEnabled
in interface JobManager
JobManager.isJobProcessingEnabled()
public void handleEvent(org.osgi.service.event.Event event)
handleEvent
in interface org.osgi.service.event.EventHandler
EventHandler.handleEvent(org.osgi.service.event.Event)
public void handleTopologyEvent(org.apache.sling.discovery.TopologyEvent event)
handleTopologyEvent
in interface org.apache.sling.discovery.TopologyEventListener
TopologyEventListener.handleTopologyEvent(org.apache.sling.discovery.TopologyEvent)
public Statistics getStatistics()
getStatistics
in interface JobManager
JobManager.getStatistics()
public Iterable<TopicStatistics> getTopicStatistics()
JobManager
getTopicStatistics
in interface JobManager
JobManager.getTopicStatistics()
public Queue getQueue(String name)
JobManager
getQueue
in interface JobManager
name
- The queue name
null
JobManager.getQueue(java.lang.String)
public Iterable<Queue> getQueues()
JobManager
getQueues
in interface JobManager
JobManager.getQueues()
public JobsIterator queryJobs(JobManager.QueryType type, String topic, Map<String,Object>... templates)
JobManager
queryJobs
in interface JobManager
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).
public JobsIterator queryJobs(JobManager.QueryType type, String topic, long limit, Map<String,Object>... templates)
JobManager
queryJobs
in interface JobManager
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).
public org.osgi.service.event.Event findJob(String topic, Map<String,Object> template)
JobManager
findJob
in interface JobManager
topic
- Topic is required.template
- The map acts like a template. The searched job
must match the template (AND query).
null
public boolean removeJob(String jobId)
JobManager
removeJob
in interface JobManager
jobId
- The unique identifier as found in the property JobUtil.JOB_ID
.
true
if the job could be cancelled or does not exist anymore.
false
otherwise.JobManager.removeJob(java.lang.String)
public void forceRemoveJob(String jobId)
JobManager
JobManager.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!
forceRemoveJob
in interface JobManager
jobId
- The unique identifier as found in the property JobUtil.JOB_ID
.JobManager.forceRemoveJob(java.lang.String)
public Job addJob(String topic, Map<String,Object> properties)
JobManager
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.
addJob
in interface JobManager
topic
- The required job topic.properties
- Optional job properties
null
if the job could not be created.JobManager.addJob(java.lang.String, java.util.Map)
public Job addJob(String topic, String name, Map<String,Object> properties)
JobManager
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.
addJob
in interface JobManager
topic
- The required job topic.name
- Optional unique job nameproperties
- Optional job properties
null
if the job could not be created.JobManager.addJob(java.lang.String, java.lang.String, java.util.Map)
public Job getJobByName(String name)
getJobByName
in interface JobManager
null
JobManager.getJobByName(java.lang.String)
public Job getJobById(String id)
getJobById
in interface JobManager
id
- The unique identifier from Job.getId()
null
JobManager.getJobById(java.lang.String)
public Job getJob(String topic, Map<String,Object> template)
JobManager
getJob
in interface JobManager
topic
- Topic is required.template
- The map acts like a template. The searched job
must match the template (AND query).
null
JobManager.getJob(java.lang.String, java.util.Map)
public boolean removeJobById(String jobId)
JobManager
removeJobById
in interface JobManager
jobId
- The unique identifier from Job.getId()
true
if the job could be removed or does not exist anymore.
false
otherwise.JobManager.removeJobById(java.lang.String)
public Collection<Job> findJobs(JobManager.QueryType type, String topic, long limit, Map<String,Object>... templates)
JobManager
findJobs
in interface JobManager
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).
org.apache.sling.event.jobs.JobManager#findJobs(org.apache.sling.event.jobs.JobManager.QueryType, java.lang.String, long, java.util.Map[])
public void finished(JobHandler info)
public boolean reschedule(JobHandler info)
info
- The job info
public boolean remove(JobImpl job)
info
-
public boolean start(JobHandler info)
public void reassign(JobHandler handler)
public TopologyCapabilities getTopologyCapabilities()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |