org.quartz.utils.Key Java Examples

The following examples show how to use org.quartz.utils.Key. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
public Key[] selectVolatileTriggers(Connection conn) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_VOLATILE_TRIGGERS));
        setBoolean(ps, 1, true);
        rs = ps.executeQuery();

        ArrayList list = new ArrayList();
        while (rs.next()) {
            String triggerName = rs.getString(COL_TRIGGER_NAME);
            String groupName = rs.getString(COL_TRIGGER_GROUP);
            list.add(new Key(triggerName, groupName));
        }
        Object[] oArr = list.toArray();
        Key[] kArr = new Key[oArr.length];
        System.arraycopy(oArr, 0, kArr, 0, oArr.length);
        return kArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
Example #2
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
public Key[] selectMisfiredTriggersInState(Connection conn, String state,
        long ts) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_MISFIRED_TRIGGERS_IN_STATE));
        ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
        ps.setString(2, state);
        rs = ps.executeQuery();

        ArrayList list = new ArrayList();
        while (rs.next()) {
            String triggerName = rs.getString(COL_TRIGGER_NAME);
            String groupName = rs.getString(COL_TRIGGER_GROUP);
            list.add(new Key(triggerName, groupName));
        }
        Object[] oArr = list.toArray();
        Key[] kArr = new Key[oArr.length];
        System.arraycopy(oArr, 0, kArr, 0, oArr.length);
        return kArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
Example #3
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
/**
 * <p>
 * Select all of the triggers in a given state.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param state
 *          the state the triggers must be in
 * @return an array of trigger <code>Key</code> s
 */
public Key[] selectTriggersInState(Connection conn, String state)
    throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_TRIGGERS_IN_STATE));
        ps.setString(1, state);
        rs = ps.executeQuery();

        ArrayList list = new ArrayList();
        while (rs.next()) {
            list.add(new Key(rs.getString(1), rs.getString(2)));
        }

        Key[] sArr = (Key[]) list.toArray(new Key[list.size()]);
        return sArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
Example #4
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
/**
 * <p>
 * Get the names of all of the triggers that have misfired.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @return an array of <code>{@link
 * org.quartz.utils.Key}</code> objects
 */
public Key[] selectMisfiredTriggers(Connection conn, long ts)
    throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_MISFIRED_TRIGGERS));
        ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
        rs = ps.executeQuery();

        ArrayList list = new ArrayList();
        while (rs.next()) {
            String triggerName = rs.getString(COL_TRIGGER_NAME);
            String groupName = rs.getString(COL_TRIGGER_GROUP);
            list.add(new Key(triggerName, groupName));
        }
        Object[] oArr = list.toArray();
        Key[] kArr = new Key[oArr.length];
        System.arraycopy(oArr, 0, kArr, 0, oArr.length);
        return kArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
Example #5
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
public List selectStatefulJobsOfTriggerGroup(Connection conn,
        String groupName) throws SQLException {
    ArrayList jobList = new ArrayList();
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn
                .prepareStatement(rtp(SELECT_STATEFUL_JOBS_OF_TRIGGER_GROUP));
        ps.setString(1, groupName);
        setBoolean(ps, 2, true);
        rs = ps.executeQuery();

        while (rs.next()) {
            jobList.add(new Key(rs.getString(COL_JOB_NAME), rs
                    .getString(COL_JOB_GROUP)));
        }
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }

    return jobList;
}
 
Example #6
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
/**
 * <p>
 * Select the trigger that will be fired at the given fire time.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param fireTime
 *          the time that the trigger will be fired
 * @return a <code>{@link org.quartz.utils.Key}</code> representing the
 *         trigger that will be fired at the given fire time, or null if no
 *         trigger will be fired at that time
 */
public Key selectTriggerForFireTime(Connection conn, long fireTime)
    throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        ps = conn.prepareStatement(rtp(SELECT_TRIGGER_FOR_FIRE_TIME));
        ps.setString(1, STATE_WAITING);
        ps.setBigDecimal(2, new BigDecimal(String.valueOf(fireTime)));
        rs = ps.executeQuery();

        if (rs.next()) {
            return new Key(rs.getString(COL_TRIGGER_NAME), rs
                    .getString(COL_TRIGGER_GROUP));
        } else {
            return null;
        }
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
Example #7
Source File: JobStoreSupport.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
protected boolean removeJob(Connection conn, SchedulingContext ctxt,
        String jobName, String groupName, boolean activeDeleteSafe)
    throws JobPersistenceException {

    try {
        Key[] jobTriggers = getDelegate().selectTriggerNamesForJob(conn,
                jobName, groupName);
        for (int i = 0; i < jobTriggers.length; ++i) {
            deleteTriggerAndChildren(
                conn, jobTriggers[i].getName(), jobTriggers[i].getGroup());
        }

        return deleteJobAndChildren(conn, ctxt, jobName, groupName);
    } catch (SQLException e) {
        throw new JobPersistenceException("Couldn't remove job: "
                + e.getMessage(), e);
    }
}
 
Example #8
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
public Key[] selectVolatileJobs(Connection conn) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_VOLATILE_JOBS));
        setBoolean(ps, 1, true);
        rs = ps.executeQuery();

        ArrayList list = new ArrayList();
        while (rs.next()) {
            String triggerName = rs.getString(COL_JOB_NAME);
            String groupName = rs.getString(COL_JOB_GROUP);
            list.add(new Key(triggerName, groupName));
        }
        Object[] oArr = list.toArray();
        Key[] kArr = new Key[oArr.length];
        System.arraycopy(oArr, 0, kArr, 0, oArr.length);
        return kArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
Example #9
Source File: JobChainingJobListener.java    From AsuraFramework with Apache License 2.0 6 votes vote down vote up
public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {

        Key sj = (Key) chainLinks.get(context.getJobDetail().getKey());

        if(sj == null) {
            return;
        }

        getLog().info("Job '" + context.getJobDetail().getFullName() + "' will now chain to Job '" + sj + "'");

        try {
            if(context.getJobDetail().isVolatile() || context.getTrigger().isVolatile()) {
                context.getScheduler().triggerJobWithVolatileTrigger(sj.getName(), sj.getGroup());
            } else {
                context.getScheduler().triggerJob(sj.getName(), sj.getGroup());
            }
        } catch(SchedulerException se) {
            getLog().error("Error encountered during chaining to Job '" + sj + "'", se);
        }
    }
 
Example #10
Source File: TriggerBuilder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Produce the <code>Trigger</code>.
 * 
 * @return a Trigger that meets the specifications of the builder.
 */
@SuppressWarnings("unchecked")
public T build() {

    if(scheduleBuilder == null)
        scheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
    MutableTrigger trig = scheduleBuilder.build();
    
    trig.setCalendarName(calendarName);
    trig.setDescription(description);
    trig.setStartTime(startTime);
    trig.setEndTime(endTime);
    if(key == null)
        key = new TriggerKey(Key.createUniqueName(null), null);
    trig.setKey(key); 
    if(jobKey != null)
        trig.setJobKey(jobKey);
    trig.setPriority(priority);
    
    if(!jobDataMap.isEmpty())
        trig.setJobDataMap(jobDataMap);
    
    return (T) trig;
}
 
Example #11
Source File: JobBuilder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Produce the <code>JobDetail</code> instance defined by this 
 * <code>JobBuilder</code>.
 * 
 * @return the defined JobDetail.
 */
public JobDetail build() {

    JobDetailImpl job = new JobDetailImpl();
    
    job.setJobClass(jobClass);
    job.setDescription(description);
    if(key == null)
        key = new JobKey(Key.createUniqueName(null), null);
    job.setKey(key); 
    job.setDurability(durability);
    job.setRequestsRecovery(shouldRecover);
    
    
    if(!jobDataMap.isEmpty())
        job.setJobDataMap(jobDataMap);
    
    return job;
}
 
Example #12
Source File: JobChainingJobListener.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * Add a chain mapping - when the Job identified by the first key completes
 * the job identified by the second key will be triggered.
 *
 * @param firstJob a Key with the name and group of the first job
 * @param secondJob a Key with the name and group of the follow-up job
 */
public void addJobChainLink(Key firstJob, Key secondJob) {

    if(firstJob == null || secondJob == null) {
        throw new IllegalArgumentException("Key cannot be null!");
    }

    if(firstJob.getName() == null || secondJob.getName() == null) {
        throw new IllegalArgumentException("Key cannot have a null name!");
    }

    chainLinks.put(firstJob, secondJob);
}
 
Example #13
Source File: JobParamsDetail.java    From spring-batch-rest with Apache License 2.0 5 votes vote down vote up
public JobParamsDetail(JobDetail jobDetail) {

		this.setJobClass(jobDetail.getJobClass());
		this.setDescription(jobDetail.getDescription());
		if (jobDetail.getKey() == null)
			this.setKey(new JobKey(Key.createUniqueName(null), null));
		this.setKey(jobDetail.getKey());
		this.setDurability(jobDetail.isDurable());
		this.setRequestsRecovery(jobDetail.requestsRecovery());

		if (!jobDetail.getJobDataMap().isEmpty())
			this.setJobDataMap(jobDetail.getJobDataMap());
	}
 
Example #14
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * Get the names of all of the triggers in the given states that have
 * misfired - according to the given timestamp.  No more than count will
 * be returned.
 * </p>
 * 
 * @param conn The DB Connection
 * @param count The most misfired triggers to return, negative for all
 * @param resultList Output parameter.  A List of 
 *      <code>{@link org.quartz.utils.Key}</code> objects.  Must not be null.
 *          
 * @return Whether there are more misfired triggers left to find beyond
 *         the given count.
 */
public boolean selectMisfiredTriggersInStates(Connection conn, String state1, String state2,
    long ts, int count, List resultList) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_MISFIRED_TRIGGERS_IN_STATES));
        ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
        ps.setString(2, state1);
        ps.setString(3, state2);
        rs = ps.executeQuery();

        boolean hasReachedLimit = false;
        while (rs.next() && (hasReachedLimit == false)) {
            if (resultList.size() == count) {
                hasReachedLimit = true;
            } else {
                String triggerName = rs.getString(COL_TRIGGER_NAME);
                String groupName = rs.getString(COL_TRIGGER_GROUP);
                resultList.add(new Key(triggerName, groupName));
            }
        }
        
        return hasReachedLimit;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
Example #15
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * Get the names of all of the triggers in the given group and state that
 * have misfired.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @return an array of <code>{@link
 * org.quartz.utils.Key}</code> objects
 */
public Key[] selectMisfiredTriggersInGroupInState(Connection conn,
        String groupName, String state, long ts) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn
                .prepareStatement(rtp(SELECT_MISFIRED_TRIGGERS_IN_GROUP_IN_STATE));
        ps.setBigDecimal(1, new BigDecimal(String.valueOf(ts)));
        ps.setString(2, groupName);
        ps.setString(3, state);
        rs = ps.executeQuery();

        ArrayList list = new ArrayList();
        while (rs.next()) {
            String triggerName = rs.getString(COL_TRIGGER_NAME);
            list.add(new Key(triggerName, groupName));
        }
        Object[] oArr = list.toArray();
        Key[] kArr = new Key[oArr.length];
        System.arraycopy(oArr, 0, kArr, 0, oArr.length);
        return kArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
Example #16
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * Get the names of all of the triggers associated with the given job.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param jobName
 *          the name of the job
 * @param groupName
 *          the group containing the job
 * @return an array of <code>{@link
 * org.quartz.utils.Key}</code> objects
 */
public Key[] selectTriggerNamesForJob(Connection conn, String jobName,
        String groupName) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        ps = conn.prepareStatement(rtp(SELECT_TRIGGERS_FOR_JOB));
        ps.setString(1, jobName);
        ps.setString(2, groupName);
        rs = ps.executeQuery();

        ArrayList list = new ArrayList(10);
        while (rs.next()) {
            String trigName = rs.getString(COL_TRIGGER_NAME);
            String trigGroup = rs.getString(COL_TRIGGER_GROUP);
            list.add(new Key(trigName, trigGroup));
        }
        Object[] oArr = list.toArray();
        Key[] kArr = new Key[oArr.length];
        System.arraycopy(oArr, 0, kArr, 0, oArr.length);
        return kArr;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
Example #17
Source File: ExistsByKeyAction.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
public boolean execute(final ODatabaseDocumentTx db, final Key key) {
  checkNotNull(db);
  checkNotNull(key);

  List<ODocument> results = db.command(new OSQLSynchQuery<>(query))
      .execute(key.getName(), key.getGroup());

  return results.get(0).<Long>field("count") == 1;
}
 
Example #18
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * Select the next trigger which will fire to fire between the two given timestamps 
 * in ascending order of fire time, and then descending by priority.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @param noLaterThan
 *          highest value of <code>getNextFireTime()</code> of the triggers (exclusive)
 * @param noEarlierThan 
 *          highest value of <code>getNextFireTime()</code> of the triggers (inclusive)
 *          
 * @return A (never null, possibly empty) list of the identifiers (Key objects) of the next triggers to be fired.
 */
public List selectTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan)
    throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;
    List nextTriggers = new LinkedList();
    try {
        ps = conn.prepareStatement(rtp(SELECT_NEXT_TRIGGER_TO_ACQUIRE));
        
        // Try to give jdbc driver a hint to hopefully not pull over 
        // more than the few rows we actually need.
        ps.setFetchSize(5);
        ps.setMaxRows(5);
        
        ps.setString(1, STATE_WAITING);
        ps.setBigDecimal(2, new BigDecimal(String.valueOf(noLaterThan)));
        ps.setBigDecimal(3, new BigDecimal(String.valueOf(noEarlierThan)));
        rs = ps.executeQuery();
        
        while (rs.next() && nextTriggers.size() < 5) {
            nextTriggers.add(new Key(
                    rs.getString(COL_TRIGGER_NAME),
                    rs.getString(COL_TRIGGER_GROUP)));
        }
        
        return nextTriggers;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }      
}
 
Example #19
Source File: DeleteEntityByKeyAction.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
public boolean execute(final ODatabaseDocumentTx db, final Key key) {
  checkNotNull(db);
  checkNotNull(key);

  int records = db.command(new OCommandSQL(query))
      .execute(key.getName(), key.getGroup());

  return records == 1;
}
 
Example #20
Source File: JobStoreSupport.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * Removes all volatile data.
 * </p>
 * 
 * @throws JobPersistenceException
 *           if jobs could not be recovered
 */
protected void cleanVolatileTriggerAndJobs(Connection conn)
    throws JobPersistenceException {
    try {
        // find volatile jobs & triggers...
        Key[] volatileTriggers = getDelegate().selectVolatileTriggers(conn);
        Key[] volatileJobs = getDelegate().selectVolatileJobs(conn);

        for (int i = 0; i < volatileTriggers.length; i++) {
            removeTrigger(conn, null, volatileTriggers[i].getName(),
                    volatileTriggers[i].getGroup());
        }
        getLog().info(
                "Removed " + volatileTriggers.length
                        + " Volatile Trigger(s).");

        for (int i = 0; i < volatileJobs.length; i++) {
            removeJob(conn, null, volatileJobs[i].getName(),
                    volatileJobs[i].getGroup(), true);
        }
        getLog().info(
                "Removed " + volatileJobs.length + " Volatile Job(s).");

        // clean up any fired trigger entries
        getDelegate().deleteVolatileFiredTriggers(conn);

    } catch (Exception e) {
        throw new JobPersistenceException("Couldn't clean volatile data: "
                + e.getMessage(), e);
    }
}
 
Example #21
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
public List selectInstancesFiredTriggerRecords(Connection conn,
        String instanceName) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        List lst = new LinkedList();

        ps = conn.prepareStatement(rtp(SELECT_INSTANCES_FIRED_TRIGGERS));
        ps.setString(1, instanceName);
        rs = ps.executeQuery();

        while (rs.next()) {
            FiredTriggerRecord rec = new FiredTriggerRecord();

            rec.setFireInstanceId(rs.getString(COL_ENTRY_ID));
            rec.setFireInstanceState(rs.getString(COL_ENTRY_STATE));
            rec.setFireTimestamp(rs.getLong(COL_FIRED_TIME));
            rec.setSchedulerInstanceId(rs.getString(COL_INSTANCE_NAME));
            rec.setTriggerIsVolatile(getBoolean(rs, COL_IS_VOLATILE));
            rec.setTriggerKey(new Key(rs.getString(COL_TRIGGER_NAME), rs
                    .getString(COL_TRIGGER_GROUP)));
            if (!rec.getFireInstanceState().equals(STATE_ACQUIRED)) {
                rec.setJobIsStateful(getBoolean(rs, COL_IS_STATEFUL));
                rec.setJobRequestsRecovery(rs
                        .getBoolean(COL_REQUESTS_RECOVERY));
                rec.setJobKey(new Key(rs.getString(COL_JOB_NAME), rs
                        .getString(COL_JOB_GROUP)));
            }
            rec.setPriority(rs.getInt(COL_PRIORITY));
            lst.add(rec);
        }

        return lst;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
Example #22
Source File: ReadEntityByKeyAction.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Nullable
public EntityT execute(final ODatabaseDocumentTx db, final Key key) {
  checkNotNull(db);
  checkNotNull(key);

  List<ODocument> results = db.command(new OSQLSynchQuery<>(query))
      .execute(key.getName(), key.getGroup());

  if (results.isEmpty()) {
    return null;
  }
  return adapter.readEntity(results.get(0));
}
 
Example #23
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
/**
 * <p>
 * Select the states of all fired-trigger records for a given job, or job
 * group if job name is <code>null</code>.
 * </p>
 * 
 * @return a List of FiredTriggerRecord objects.
 */
public List selectFiredTriggerRecordsByJob(Connection conn, String jobName,
        String groupName) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        List lst = new LinkedList();

        if (jobName != null) {
            ps = conn.prepareStatement(rtp(SELECT_FIRED_TRIGGERS_OF_JOB));
            ps.setString(1, jobName);
            ps.setString(2, groupName);
        } else {
            ps = conn
                    .prepareStatement(rtp(SELECT_FIRED_TRIGGERS_OF_JOB_GROUP));
            ps.setString(1, groupName);
        }
        rs = ps.executeQuery();

        while (rs.next()) {
            FiredTriggerRecord rec = new FiredTriggerRecord();

            rec.setFireInstanceId(rs.getString(COL_ENTRY_ID));
            rec.setFireInstanceState(rs.getString(COL_ENTRY_STATE));
            rec.setFireTimestamp(rs.getLong(COL_FIRED_TIME));
            rec.setPriority(rs.getInt(COL_PRIORITY));
            rec.setSchedulerInstanceId(rs.getString(COL_INSTANCE_NAME));
            rec.setTriggerIsVolatile(getBoolean(rs, COL_IS_VOLATILE));
            rec.setTriggerKey(new Key(rs.getString(COL_TRIGGER_NAME), rs
                    .getString(COL_TRIGGER_GROUP)));
            if (!rec.getFireInstanceState().equals(STATE_ACQUIRED)) {
                rec.setJobIsStateful(getBoolean(rs, COL_IS_STATEFUL));
                rec.setJobRequestsRecovery(rs
                        .getBoolean(COL_REQUESTS_RECOVERY));
                rec.setJobKey(new Key(rs.getString(COL_JOB_NAME), rs
                        .getString(COL_JOB_GROUP)));
            }
            lst.add(rec);
        }

        return lst;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }

}
 
Example #24
Source File: StdJDBCDelegate.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
/**
 * <p>
 * Select the states of all fired-trigger records for a given trigger, or
 * trigger group if trigger name is <code>null</code>.
 * </p>
 * 
 * @return a List of FiredTriggerRecord objects.
 */
public List selectFiredTriggerRecords(Connection conn, String triggerName,
        String groupName) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        List lst = new LinkedList();

        if (triggerName != null) {
            ps = conn.prepareStatement(rtp(SELECT_FIRED_TRIGGER));
            ps.setString(1, triggerName);
            ps.setString(2, groupName);
        } else {
            ps = conn.prepareStatement(rtp(SELECT_FIRED_TRIGGER_GROUP));
            ps.setString(1, groupName);
        }
        rs = ps.executeQuery();

        while (rs.next()) {
            FiredTriggerRecord rec = new FiredTriggerRecord();

            rec.setFireInstanceId(rs.getString(COL_ENTRY_ID));
            rec.setFireInstanceState(rs.getString(COL_ENTRY_STATE));
            rec.setFireTimestamp(rs.getLong(COL_FIRED_TIME));
            rec.setPriority(rs.getInt(COL_PRIORITY));
            rec.setSchedulerInstanceId(rs.getString(COL_INSTANCE_NAME));
            rec.setTriggerIsVolatile(getBoolean(rs, COL_IS_VOLATILE));
            rec.setTriggerKey(new Key(rs.getString(COL_TRIGGER_NAME), rs
                    .getString(COL_TRIGGER_GROUP)));
            if (!rec.getFireInstanceState().equals(STATE_ACQUIRED)) {
                rec.setJobIsStateful(getBoolean(rs, COL_IS_STATEFUL));
                rec.setJobRequestsRecovery(rs
                        .getBoolean(COL_REQUESTS_RECOVERY));
                rec.setJobKey(new Key(rs.getString(COL_JOB_NAME), rs
                        .getString(COL_JOB_GROUP)));
            }
            lst.add(rec);
        }

        return lst;
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }
}
 
Example #25
Source File: FormatTool.java    From quartz-glass with Apache License 2.0 4 votes vote down vote up
public String descKey(Key<?> key) {
    return html(Keys.desc(key));
}
 
Example #26
Source File: Keys.java    From quartz-glass with Apache License 2.0 4 votes vote down vote up
public static String desc(Key<?> key) {
    return key.getGroup().equals(Scheduler.DEFAULT_GROUP) ? key.getName() : key.toString();
}
 
Example #27
Source File: FiredTriggerRecord.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
public Key getJobKey() {
    return jobKey;
}
 
Example #28
Source File: FiredTriggerRecord.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
public Key getTriggerKey() {
    return triggerKey;
}
 
Example #29
Source File: FiredTriggerRecord.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
public void setJobKey(Key key) {
    jobKey = key;
}
 
Example #30
Source File: FiredTriggerRecord.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
public void setTriggerKey(Key key) {
    triggerKey = key;
}