jobstorecmt.java
来自「Quartz 是个开源的作业调度框架」· Java 代码 · 共 1,470 行 · 第 1/4 页
JAVA
1,470 行
* groups.
* </p>
*
* <p>
* If there are no known group names, the result should be a zero-length
* array (not <code>null</code>).
* </p>
*/
public String[] getTriggerGroupNames(SchedulingContext ctxt)
throws JobPersistenceException {
Connection conn = getConnection();
try {
// no locks necessary for read...
return getTriggerGroupNames(conn, ctxt);
} finally {
closeConnection(conn);
}
}
/**
* <p>
* Get the names of all of the <code>{@link org.quartz.Calendar}</code> s
* in the <code>JobStore</code>.
* </p>
*
* <p>
* If there are no Calendars in the given group name, the result should be
* a zero-length array (not <code>null</code>).
* </p>
*/
public String[] getCalendarNames(SchedulingContext ctxt)
throws JobPersistenceException {
Connection conn = getConnection();
try {
// no locks necessary for read...
return getCalendarNames(conn, ctxt);
} finally {
closeConnection(conn);
}
}
/**
* <p>
* Get all of the Triggers that are associated to the given Job.
* </p>
*
* <p>
* If there are no matches, a zero-length array should be returned.
* </p>
*/
public Trigger[] getTriggersForJob(SchedulingContext ctxt, String jobName,
String groupName) throws JobPersistenceException {
Connection conn = getConnection();
try {
// no locks necessary for read...
return getTriggersForJob(conn, ctxt, jobName, groupName);
} finally {
closeConnection(conn);
}
}
/**
* <p>
* Get the current state of the identified <code>{@link Trigger}</code>.
* </p>
*
* @see Trigger#STATE_NORMAL
* @see Trigger#STATE_PAUSED
* @see Trigger#STATE_COMPLETE
* @see Trigger#STATE_ERROR
* @see Trigger#STATE_NONE
*/
public int getTriggerState(SchedulingContext ctxt, String triggerName,
String groupName) throws JobPersistenceException {
Connection conn = getConnection();
try {
// no locks necessary for read...
return getTriggerState(conn, ctxt, triggerName, groupName);
} finally {
closeConnection(conn);
}
}
//---------------------------------------------------------------------------
// trigger state manipulation methods
//---------------------------------------------------------------------------
/**
* <p>
* Pause the <code>{@link org.quartz.Trigger}</code> with the given name.
* </p>
*
* @see #resumeTrigger(SchedulingContext, String, String)
*/
public void pauseTrigger(SchedulingContext ctxt, String triggerName,
String groupName) throws JobPersistenceException {
Connection conn = getConnection();
boolean transOwner = false;
try {
getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);
transOwner = true;
//getLockHandler().obtainLock(conn, LOCK_JOB_ACCESS);
pauseTrigger(conn, ctxt, triggerName, groupName);
} finally {
try {
releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
} finally {
closeConnection(conn);
}
}
}
/**
* <p>
* Pause all of the <code>{@link org.quartz.Trigger}s</code> in the
* given group.
* </p>
*
* @see #resumeTriggerGroup(SchedulingContext, String)
*/
public void pauseTriggerGroup(SchedulingContext ctxt, String groupName)
throws JobPersistenceException {
Connection conn = getConnection();
boolean transOwner = false;
try {
getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);
transOwner = true;
//getLockHandler().obtainLock(conn, LOCK_JOB_ACCESS);
pauseTriggerGroup(conn, ctxt, groupName);
} finally {
try {
releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
} finally {
closeConnection(conn);
}
}
}
/**
* <p>
* Pause the <code>{@link org.quartz.Job}</code> with the given name - by
* pausing all of its current <code>Trigger</code>s.
* </p>
*
* @see #resumeJob(SchedulingContext, String, String)
*/
public void pauseJob(SchedulingContext ctxt, String jobName,
String groupName) throws JobPersistenceException {
Connection conn = getConnection();
boolean transOwner = false;
try {
getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);
transOwner = true;
//getLockHandler().obtainLock(conn, LOCK_JOB_ACCESS);
Trigger[] triggers = getTriggersForJob(conn, ctxt, jobName,
groupName);
for (int j = 0; j < triggers.length; j++) {
pauseTrigger(conn, ctxt, triggers[j].getName(), triggers[j]
.getGroup());
}
} finally {
try {
releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
} finally {
closeConnection(conn);
}
}
}
/**
* <p>
* Pause all of the <code>{@link org.quartz.Job}s</code> in the given
* group - by pausing all of their <code>Trigger</code>s.
* </p>
*
* @see #resumeJobGroup(SchedulingContext, String)
*/
public void pauseJobGroup(SchedulingContext ctxt, String groupName)
throws JobPersistenceException {
Connection conn = getConnection();
boolean transOwner = false;
try {
getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);
transOwner = true;
//getLockHandler().obtainLock(conn, LOCK_JOB_ACCESS);
String[] jobNames = getJobNames(conn, ctxt, groupName);
for (int i = 0; i < jobNames.length; i++) {
Trigger[] triggers = getTriggersForJob(conn, ctxt, jobNames[i],
groupName);
for (int j = 0; j < triggers.length; j++) {
pauseTrigger(conn, ctxt, triggers[j].getName(), triggers[j]
.getGroup());
}
}
} finally {
try {
releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
} finally {
closeConnection(conn);
}
}
}
/**
* <p>
* Resume (un-pause) the <code>{@link org.quartz.Trigger}</code> with the
* given name.
* </p>
*
* <p>
* If the <code>Trigger</code> missed one or more fire-times, then the
* <code>Trigger</code>'s misfire instruction will be applied.
* </p>
*
* @see #pauseTrigger(SchedulingContext, String, String)
*/
public void resumeTrigger(SchedulingContext ctxt, String triggerName,
String groupName) throws JobPersistenceException {
Connection conn = getConnection();
boolean transOwner = false;
try {
getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);
transOwner = true;
//getLockHandler().obtainLock(conn, LOCK_JOB_ACCESS);
resumeTrigger(conn, ctxt, triggerName, groupName);
} finally {
try {
releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
} finally {
closeConnection(conn);
}
}
}
/**
* <p>
* Resume (un-pause) all of the <code>{@link org.quartz.Trigger}s</code>
* in the given group.
* </p>
*
* <p>
* If any <code>Trigger</code> missed one or more fire-times, then the
* <code>Trigger</code>'s misfire instruction will be applied.
* </p>
*
* @see #pauseTriggerGroup(SchedulingContext, String)
*/
public void resumeTriggerGroup(SchedulingContext ctxt, String groupName)
throws JobPersistenceException {
Connection conn = getConnection();
boolean transOwner = false;
try {
getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);
transOwner = true;
//getLockHandler().obtainLock(conn, LOCK_JOB_ACCESS);
resumeTriggerGroup(conn, ctxt, groupName);
} finally {
try {
releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
} finally {
closeConnection(conn);
}
}
}
/**
* <p>
* Resume (un-pause) the <code>{@link org.quartz.Job}</code> with the
* given name.
* </p>
*
* <p>
* If any of the <code>Job</code>'s<code>Trigger</code> s missed one
* or more fire-times, then the <code>Trigger</code>'s misfire
* instruction will be applied.
* </p>
*
* @see #pauseJob(SchedulingContext, String, String)
*/
public void resumeJob(SchedulingContext ctxt, String jobName,
String groupName) throws JobPersistenceException {
Connection conn = getConnection();
boolean transOwner = false;
try {
getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);
transOwner = true;
//getLockHandler().obtainLock(conn, LOCK_JOB_ACCESS);
Trigger[] triggers = getTriggersForJob(conn, ctxt, jobName,
groupName);
for (int j = 0; j < triggers.length; j++) {
resumeTrigger(conn, ctxt, triggers[j].getName(), triggers[j]
.getGroup());
}
} finally {
try {
releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
} finally {
closeConnection(conn);
}
}
}
/**
* <p>
* Resume (un-pause) all of the <code>{@link org.quartz.Job}s</code> in
* the given group.
* </p>
*
* <p>
* If any of the <code>Job</code> s had <code>Trigger</code> s that
* missed one or more fire-times, then the <code>Trigger</code>'s
* misfire instruction will be applied.
* </p>
*
* @see #pauseJobGroup(SchedulingContext, String)
*/
public void resumeJobGroup(SchedulingContext ctxt, String groupName)
throws JobPersistenceException {
Connection conn = getConnection();
boolean transOwner = false;
try {
getLockHandler().obtainLock(conn, LOCK_TRIGGER_ACCESS);
transOwner = true;
//getLockHandler().obtainLock(conn, LOCK_JOB_ACCESS);
String[] jobNames = getJobNames(conn, ctxt, groupName);
for (int i = 0; i < jobNames.length; i++) {
Trigger[] triggers = getTriggersForJob(conn, ctxt, jobNames[i],
groupName);
for (int j = 0; j < triggers.length; j++) {
resumeTrigger(conn, ctxt, triggers[j].getName(),
triggers[j].getGroup());
}
}
} finally {
try {
releaseLock(conn, LOCK_TRIGGER_ACCESS, transOwner);
} finally {
closeConnection(conn);
}
}
}
/**
* <p>
* Pause all triggers - equivalent of calling <code>pauseTriggerGroup(group)</code>
* on every group.
* </p>
*
* <p>
* When <code>resumeAll()</code> is called (to un-pause), trigger misfire
* instructions WILL be applied.
* </p>
*
* @see #resumeAll(SchedulingContext)
* @see #pauseTriggerGroup(SchedulingContext, String)
*/
public void pauseAll(SchedulingContext ctxt) throws JobPersistenceException {
Connection conn = getConnection();
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?