|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.sling.event.impl.jobs.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.JobStatusNotifier |
---|
JobStatusNotifier.NotifierContext |
Field Summary | |
---|---|
protected InternalQueueConfiguration |
configuration
Configuration. |
protected boolean |
isWaiting
Is the queue currently waiting(sleeping) |
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.JobStatusNotifier |
---|
CONTEXT_PROPERTY_NAME |
Constructor Summary | |
---|---|
AbstractJobQueue(String name,
InternalQueueConfiguration config,
EnvironmentComponent environment)
Start this queue |
Method Summary | |
---|---|
protected boolean |
canBeMarkedForRemoval()
|
void |
checkForUnprocessedJobs()
Periodically check for started jobs without an ack. |
void |
clear()
Remove all outstanding jobs from the queue. |
void |
close()
Close this queue. |
protected boolean |
executeJob(JobEvent info)
Process 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? |
boolean |
isMarkedForRemoval()
Check if this queue is marked for removal |
boolean |
isSuspended()
Is the queue currently suspended? |
void |
markForRemoval()
Mark this queue for removal. |
protected abstract void |
notifyFinished(JobEvent rescheduleInfo)
|
void |
process(JobEvent event)
Add a new job to the queue. |
protected abstract void |
put(JobEvent event)
Put another job into the queue. |
void |
removeAll()
Remove all outstanding jobs and delete them. |
protected abstract Collection<JobEvent> |
removeAllJobs()
Remove all events from the queue and return them. |
void |
rename(String name)
Rename this queue. |
protected abstract JobEvent |
reschedule(JobEvent 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 JobEvent |
start(JobEvent 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 JobEvent |
take()
Get another job from the queue. |
Methods inherited from class org.apache.sling.event.impl.jobs.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
Constructor Detail |
---|
public AbstractJobQueue(String name, InternalQueueConfiguration config, EnvironmentComponent environment)
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 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)
protected boolean canBeMarkedForRemoval()
public void markForRemoval()
public boolean isMarkedForRemoval()
public String getName()
getName
in interface Queue
public void process(JobEvent event)
protected boolean executeJob(JobEvent info)
protected void ignoreException(Exception e)
e
- public void rename(String name)
protected abstract JobEvent reschedule(JobEvent info)
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 supsended.
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 void put(JobEvent event)
protected abstract JobEvent take()
protected abstract boolean isEmpty()
protected abstract Collection<JobEvent> removeAllJobs()
protected abstract JobEvent start(JobEvent event)
protected abstract void notifyFinished(JobEvent rescheduleInfo)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |