|
||||||||||
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.queues.AbstractJobQueue
public abstract class AbstractJobQueue
The job blocking queue extends the blocking queue by some functionality for the job event handling.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.sling.event.impl.jobs.deprecated.JobStatusNotifier |
---|
JobStatusNotifier.NotifierContext |
Field Summary | |
---|---|
protected InternalQueueConfiguration |
configuration
Configuration. |
protected boolean |
isWaiting
Is the queue currently waiting(sleeping) |
protected boolean |
isWaitingForNext
Marker flag if the queue is waiting for another element (= empty) |
protected org.slf4j.Logger |
logger
The logger. |
protected String |
queueName
The queue name. |
protected boolean |
running
Are we still running? |
Fields inherited from interface org.apache.sling.event.impl.jobs.deprecated.JobStatusNotifier |
---|
CONTEXT_PROPERTY_NAME |
Constructor Summary | |
---|---|
AbstractJobQueue(String name,
InternalQueueConfiguration config,
JobConsumerManager jobConsumerManager,
org.osgi.service.event.EventAdmin eventAdmin)
Start this queue |
Method Summary | |
---|---|
protected boolean |
canBeClosed()
Check whether this queue can be closed |
void |
checkForUnprocessedJobs()
Periodically check for started jobs without an acknowledge. |
void |
clear()
Remove all outstanding jobs from the queue. |
void |
close()
Close this queue. |
protected boolean |
executeJob(JobHandler handler)
Execute a job |
boolean |
finishedJob(org.osgi.service.event.Event job,
boolean shouldReschedule)
Notify that the job is finished. |
InternalQueueConfiguration |
getConfiguration()
Return the queue configuration |
String |
getName()
Get the name of the job queue. |
Object |
getState(String key)
For monitoring purposes and possible extensions from the different queue types. |
String |
getStateInfo()
Return some information about the current state of the queue. |
Statistics |
getStatistics()
Return statistics information about this queue. |
protected void |
ignoreException(Exception e)
Helper method which just logs the exception in debug mode. |
protected abstract boolean |
isEmpty()
Is the queue empty? |
protected boolean |
isOutdated()
Is the queue outdated? |
boolean |
isSuspended()
Is the queue currently suspended? |
protected abstract void |
notifyFinished(JobHandler rescheduleInfo)
|
void |
outdate()
Outdate this queue. |
void |
process(JobHandler handler)
Add a new job to the queue. |
protected abstract void |
put(JobHandler event)
Put another job into the queue. |
void |
removeAll()
Remove all outstanding jobs and delete them. |
protected abstract Collection<JobHandler> |
removeAllJobs()
Remove all events from the queue and return them. |
protected abstract JobHandler |
reschedule(JobHandler info)
Reschedule a job. |
void |
resume()
Resume a suspended queue. |
boolean |
sendAcknowledge(org.osgi.service.event.Event job)
Send an acknowledge message that someone is processing the job. |
void |
start()
Start the job queue. |
protected abstract JobHandler |
start(JobHandler event)
|
void |
suspend()
Suspend the queue - when a queue is suspended it stops processing jobs - however already started jobs are finished (but not rescheduled). |
protected abstract JobHandler |
take()
Get another job from the queue. |
boolean |
tryToClose()
Check if the queue can be closed |
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, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.slf4j.Logger logger
protected final InternalQueueConfiguration configuration
protected volatile String queueName
protected volatile boolean running
protected volatile boolean isWaiting
protected boolean isWaitingForNext
Constructor Detail |
---|
public AbstractJobQueue(String name, InternalQueueConfiguration config, JobConsumerManager jobConsumerManager, org.osgi.service.event.EventAdmin eventAdmin)
name
- The queue nameconfig
- The queue configurationenvironment
- The environment componentMethod Detail |
---|
public String getStateInfo()
Queue
getStateInfo
in interface Queue
Queue.getStateInfo()
public void start()
public InternalQueueConfiguration getConfiguration()
getConfiguration
in interface Queue
public void close()
public boolean tryToClose()
protected boolean canBeClosed()
public void checkForUnprocessedJobs()
public boolean sendAcknowledge(org.osgi.service.event.Event job)
JobStatusNotifier
sendAcknowledge
in interface JobStatusNotifier
job
- The job.
true
if the ack is ok, false
otherwise (e.g. if
someone else already send an ack for this job.JobStatusNotifier.sendAcknowledge(org.osgi.service.event.Event)
public boolean finishedJob(org.osgi.service.event.Event job, boolean shouldReschedule)
JobStatusNotifier
false
indicates an error
during the processing. If the job should be rescheduled, true
indicates
that the job could be rescheduled. If an error occurs or the number of retries is
exceeded, false
will be returned.
finishedJob
in interface JobStatusNotifier
job
- The job.shouldReschedule
- Should the event be rescheduled?
true
if everything went fine, false
otherwise.JobStatusNotifier.finishedJob(org.osgi.service.event.Event, boolean)
public String getName()
getName
in interface Queue
public void process(JobHandler handler)
protected boolean executeJob(JobHandler handler)
protected void ignoreException(Exception e)
e
- protected boolean isOutdated()
public void outdate()
public Statistics getStatistics()
Queue
getStatistics
in interface Queue
Queue.getStatistics()
public void resume()
Queue
Queue.suspend()
. If the queue is not
suspended, calling this method has no effect.
Depending on the queue implementation, if a job failed a job queue might
sleep for a configured time, before a new job is processed. By calling this
method, the job queue can be woken up and force an immediate reprocessing.
This feature is only supported by ordered queues at the moment. If a queue
does not support this feature, calling this method has only an effect if
the queue is really suspended.
resume
in interface Queue
Queue.resume()
public void suspend()
Queue
Queue.resume()
.
suspend
in interface Queue
Queue.suspend()
public boolean isSuspended()
Queue
isSuspended
in interface Queue
Queue.isSuspended()
public void removeAll()
Queue
removeAll
in interface Queue
Queue.removeAll()
public void clear()
Queue
clear
in interface Queue
Queue.clear()
public Object getState(String key)
Queue
getState
in interface Queue
Queue.getState(java.lang.String)
protected abstract JobHandler reschedule(JobHandler info)
protected abstract void put(JobHandler event)
protected abstract JobHandler take()
protected abstract boolean isEmpty()
protected abstract Collection<JobHandler> removeAllJobs()
protected abstract JobHandler start(JobHandler event)
protected abstract void notifyFinished(JobHandler rescheduleInfo)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |