Package org.mycore.services.queuedjob
Class MCRJobQueue
- All Implemented Interfaces:
Comparable<MCRShutdownHandler.Closeable>
,Iterable<MCRJob>
,Collection<MCRJob>
,Queue<MCRJob>
,MCRShutdownHandler.Closeable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static String
protected String
protected static Map<String,
MCRJobQueue> protected static boolean
Fields inherited from interface org.mycore.common.events.MCRShutdownHandler.Closeable
DEFAULT_PRIORITY
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Deletes all jobs no matter what the current state is.void
close()
does nothingelement()
removes next job.getElementOutOfOrder
(Class<? extends MCRJobAction> action, Map<String, String> params) get the specific job and alters it status toMCRJobStatus.PROCESSING
static MCRJobQueue
getInstance
(Class<? extends MCRJobAction> action) Returns an singleton instance of this class.returns a specific job from given parameters or null if not found.Returns specific jobs by the given parameters or an empty list.int
Returns the priority.iterator()
iterates over jobs of statusMCRJobStatus.NEW
does not change the status.iterator
(MCRJobStatus status) Builds iterator for jobs with givenMCRJobStatus
ornull
for all jobs.void
every attached listener is informed that something happened to the state of the queue.boolean
peek()
get next job without modifying it state toMCRJobStatus.PROCESSING
poll()
void
Shuts downMCRStalledJobResetter
and does not alter any job anymore.remove()
removes next job.int
remove
(Class<? extends MCRJobAction> action) Removes all jobs from queue of specified action.int
removes specific job from queue no matter what its current status is.int
size()
returns the current size of this queuetoString()
Methods inherited from class java.util.AbstractQueue
add, addAll
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
Methods inherited from interface org.mycore.common.events.MCRShutdownHandler.Closeable
compareTo
-
Field Details
-
INSTANCES
-
CONFIG_PREFIX
-
singleQueue
protected static boolean singleQueue -
configPrefixAdd
-
-
Method Details
-
getInstance
Returns an singleton instance of this class.- Parameters:
action
- theMCRJobAction
ornull
- Returns:
- singleton instance of this class
-
poll
-
remove
removes next job. same aspoll()
but never returns null- Specified by:
remove
in interfaceQueue<MCRJob>
- Overrides:
remove
in classAbstractQueue<MCRJob>
- Throws:
NoSuchElementException
- ifpoll()
would return null
-
peek
get next job without modifying it state toMCRJobStatus.PROCESSING
-
element
removes next job. same aspeek()
but never returns null- Specified by:
element
in interfaceQueue<MCRJob>
- Overrides:
element
in classAbstractQueue<MCRJob>
- Throws:
NoSuchElementException
- ifpeek()
would return null
-
offer
addsMCRJob
to queue and startsMCRJobMaster
if"MCR.QueuedJob.autostart"
is settrue
. alters date added to current time and status of job toMCRJobStatus.NEW
-
clear
public void clear()Deletes all jobs no matter what the current state is.- Specified by:
clear
in interfaceCollection<MCRJob>
- Overrides:
clear
in classAbstractQueue<MCRJob>
-
iterator
iterates over jobs of statusMCRJobStatus.NEW
does not change the status.- Specified by:
iterator
in interfaceCollection<MCRJob>
- Specified by:
iterator
in interfaceIterable<MCRJob>
- Specified by:
iterator
in classAbstractCollection<MCRJob>
-
iterator
Builds iterator for jobs with givenMCRJobStatus
ornull
for all jobs. -
size
public int size()returns the current size of this queue- Specified by:
size
in interfaceCollection<MCRJob>
- Specified by:
size
in classAbstractCollection<MCRJob>
-
getElementOutOfOrder
public MCRJob getElementOutOfOrder(Class<? extends MCRJobAction> action, Map<String, String> params) throws NoSuchElementExceptionget the specific job and alters it status toMCRJobStatus.PROCESSING
- Parameters:
action
- theMCRJobAction
- Throws:
NoSuchElementException
-
getJob
returns a specific job from given parameters or null if not found.- Parameters:
params
- the parameters- Returns:
- the job
-
getJobs
Returns specific jobs by the given parameters or an empty list.- Parameters:
params
- the parameters- Returns:
- the job
-
notifyListener
public void notifyListener()every attached listener is informed that something happened to the state of the queue. StartsMCRJobMaster
if"MCR.QueuedJob.autostart"
is settrue
. -
remove
removes specific job from queue no matter what its current status is.- Parameters:
action
- - the action classparams
- - parameters to get jobs- Returns:
- the number of jobs deleted
-
remove
Removes all jobs from queue of specified action.- Parameters:
action
- - the action class- Returns:
- the number of jobs deleted
-
prepareClose
public void prepareClose()Shuts downMCRStalledJobResetter
and does not alter any job anymore.- Specified by:
prepareClose
in interfaceMCRShutdownHandler.Closeable
-
close
public void close()does nothing- Specified by:
close
in interfaceMCRShutdownHandler.Closeable
-
toString
- Overrides:
toString
in classAbstractCollection<MCRJob>
- Returns:
- "MCRJobQueue"
-
getPriority
public int getPriority()Description copied from interface:MCRShutdownHandler.Closeable
Returns the priority. A Closeable with a higher priority will be closed before a Closeable with a lower priority. Default priority is 5.- Specified by:
getPriority
in interfaceMCRShutdownHandler.Closeable
-