public final class JobManager extends java.lang.Object implements DBClassListener, java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
static int |
GLOBAL_ENVIRONMENT_RUN_LIMIT
the environment run limit
|
Modifier and Type | Method and Description |
---|---|
DBJob |
bid(java.lang.String queues,
DBJobManagerSession session,
long blockMS,
java.lang.String[] types)
bid for a job in a queue
|
static int |
calulatedRunLimit()
get the global run limit.
|
static void |
check()
check the configuration
|
static boolean |
checkDependants(DBJob job)
check the dependents have completed.
|
DBJobManagerSession |
checkSession()
check the session.
|
void |
closeAll()
close all the queues.
|
static void |
configure(java.lang.String fileName,
int refreshSeconds)
load the configuration of the JobManager from an XML file.
|
void |
disableQueue(java.lang.String code)
Disable a queue.
|
void |
enableQueue(java.lang.String code)
Enable a queue.
|
void |
eventJobCompleted()
A job has been completed.
|
void |
eventObjectCreated(GlobalKey createdKey,
VirtualDB layer)
Watch for jobs being created.
|
void |
eventObjectDeleted(GlobalKey deletedKey,
VirtualDB layer)
A job has been deleted.
|
void |
eventObjectModified(GlobalKey modifiedKey,
VirtualDB layer)
A job was modified.
|
long |
executeOrQueue(DBJob job)
execute a job
|
void |
filterQueue(java.lang.String code,
java.lang.String filter)
filter queue
|
static JobManager |
find(VirtualDB layer)
Find the JobManager for this layer.
|
static long |
findMaxProcessBeatMS(VirtualDB layer)
Get the MaxProcessBeat time in milliseconds.
|
DBJob[] |
getActiveJobsByCode(java.lang.String code)
The list of Jobs being processed or waiting to be processed
|
long |
getCheckDeadJobsCount()
get the check of the dead job count
|
java.lang.String |
getFilter(java.lang.String queueCode)
The filter for this queue.
|
static int |
getGlobalDataBaseRunCount()
get the global run count
|
static int |
getGlobalProgramRunCount()
get the global program run count
|
VirtualDB |
getLayer()
The layer for this job manager.
|
long |
getQueueBidDelayPerJob(java.lang.String queueCode)
The max pause time for this queue.
|
long |
getQueueMaxPause(java.lang.String queueCode)
The max pause time for this queue.
|
int |
getQueueSlots(java.lang.String queueCode)
The number of slots open for this queue.
|
int |
getRunningJobs(java.lang.String queueCode)
The number of jobs running for this queue.
|
boolean |
isEnableQueue(java.lang.String code)
is a queue enable.
|
void |
join()
Join to this job manager
|
static JobManager[] |
list()
The list of job managers.
|
void |
loadOtherQueues()
load the other queues.
|
void |
openQueue(java.lang.String code,
int slots)
Open a queue.
|
void |
openQueue(java.lang.String code,
int slots,
long maxPause,
java.lang.String filter,
java.lang.String bidDelayPerJob)
Open a queue.
|
void |
reanimatePreviousJob()
When the job manager restarts it will check for previously running jobs for a
job manager with the same name.
|
void |
run()
loop checking for jobs.
|
static int |
setGlobalDataBaseRunLimit(int limit)
set the global database run limit
|
static int |
setGlobalProgramRunLimit(int limit)
set the global program run limit
|
boolean |
startJob(DBJob job)
start a job
|
void |
waitForChange(long msecs)
wait for a change to the queue
|
public static final int GLOBAL_ENVIRONMENT_RUN_LIMIT
public static int getGlobalDataBaseRunCount()
public static int setGlobalDataBaseRunLimit(int limit)
limit
- the limitpublic static int getGlobalProgramRunCount()
public static int setGlobalProgramRunLimit(int limit)
limit
- the limit -1 is NO limit@CheckReturnValue @Nonnegative public static int calulatedRunLimit()
public long getCheckDeadJobsCount()
public void filterQueue(java.lang.String code, java.lang.String filter) throws java.lang.Exception
code
- The queue codefilter
- the filer to use on this queue.java.lang.Exception
- a serious errorpublic void openQueue(@Nonnull java.lang.String code, int slots) throws java.lang.Exception
code
- The queue codeslots
- The number of slotsjava.lang.Exception
- a serious errorpublic void openQueue(@Nonnull java.lang.String code, int slots, long maxPause, @Nullable java.lang.String filter, @Nullable java.lang.String bidDelayPerJob) throws java.lang.Exception
maxPause
- pause for a period of timecode
- The queue codeslots
- The number of slotsfilter
- the filter of the queuebidDelayPerJob
- how long to pausejava.lang.Exception
- a serious errorpublic void disableQueue(java.lang.String code) throws java.lang.Exception
code
- The queue code or '*' for all queues currently openedjava.lang.Exception
- a serious errorpublic void enableQueue(java.lang.String code) throws java.lang.Exception
code
- The queue code or '*' for all queues currently openedjava.lang.Exception
- a serious errorpublic boolean isEnableQueue(java.lang.String code) throws java.lang.Exception
code
- the queue codejava.lang.Exception
- a serious errorpublic static JobManager find(@Nonnull VirtualDB layer) throws java.lang.InterruptedException
layer
- The layer to fetch the job manager for.java.lang.InterruptedException
- if we timeout.public void eventObjectCreated(GlobalKey createdKey, VirtualDB layer)
eventObjectCreated
in interface DBClassListener
createdKey
- The created joblayer
- The layer on which is created.public void eventObjectDeleted(@Nonnull GlobalKey deletedKey, @Nonnull VirtualDB layer)
eventObjectDeleted
in interface DBClassListener
deletedKey
- The deleted joblayer
- The layer that the job was deleted in.public void eventObjectModified(GlobalKey modifiedKey, VirtualDB layer)
eventObjectModified
in interface DBClassListener
modifiedKey
- The modified joblayer
- The layer in which the job was modified.public void eventJobCompleted()
public VirtualDB getLayer()
public void join()
public void run()
run
in interface java.lang.Runnable
public void waitForChange(long msecs) throws java.lang.InterruptedException
msecs
- the milliseconds to wait.java.lang.InterruptedException
- a problempublic DBJob bid(java.lang.String queues, DBJobManagerSession session, @Nonnegative long blockMS, java.lang.String[] types) throws java.lang.Exception
types
- The types to filter onblockMS
- block for now long ?session
- the sessionqueues
- The queue to bid forjava.lang.Exception
- a serious problempublic int getRunningJobs(java.lang.String queueCode)
queueCode
- The queue codepublic DBJob[] getActiveJobsByCode(java.lang.String code) throws java.lang.Exception
code
- Code to search forjava.lang.Exception
- A serious errorpublic void closeAll()
@Nullable public java.lang.String getFilter(@Nonnull java.lang.String queueCode)
queueCode
- The queue codepublic int getQueueSlots(@Nonnull java.lang.String queueCode)
queueCode
- The queue codepublic long getQueueMaxPause(@Nonnull java.lang.String queueCode)
queueCode
- The queue codepublic long getQueueBidDelayPerJob(@Nonnull java.lang.String queueCode)
queueCode
- The queue codepublic void reanimatePreviousJob()
public boolean startJob(@Nonnull DBJob job) throws java.lang.Exception
job
- the job to runjava.lang.Exception
- A serious problempublic static boolean checkDependants(@Nonnull DBJob job) throws java.lang.Exception
job
- the job to checkjava.lang.Exception
- a serious problempublic long executeOrQueue(@Nonnull DBJob job) throws java.lang.Exception
job
- the job to runjava.lang.Exception
- A serious problempublic static void configure(java.lang.String fileName, int refreshSeconds) throws java.lang.Exception
<layer name='aspc_engine' > <queue name='default' slots='3' /> </layer>
refreshSeconds
- check the configuration file every X seconds.fileName
- configure the job managers.java.lang.Exception
- a serious problempublic static void check()
@Nonnull public static JobManager[] list()
public void loadOtherQueues() throws java.lang.Exception
java.lang.Exception
- a serious problempublic DBJobManagerSession checkSession() throws java.lang.Exception
java.lang.Exception
- A serious problem occurspublic static long findMaxProcessBeatMS(@Nonnull VirtualDB layer) throws java.lang.Exception
layer
- VirtualDBjava.lang.Exception
- A serious problem occursstSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.