/** * The single job ID which identifies this specific schedule. It can later be parsed via * {@link ScheduleJobId#ScheduleJobId(String)}. * * @return job ID */ public JobId getJobId() { return new ScheduleJobId(this.jobName, this.jobGroup); }
/** * Returns a managed entity of the scheduled job. * * @param jobId * * @return a managed entity, attached to this bean's entity manager */ private OperationScheduleEntity findOperationScheduleEntity(ScheduleJobId jobId) { Query query = entityManager.createNamedQuery(OperationScheduleEntity.QUERY_FIND_BY_JOB_ID); String jobName = jobId.getJobName(); query.setParameter("jobName", jobName); String jobGroup = jobId.getJobGroup(); query.setParameter("jobGroup", jobGroup); OperationScheduleEntity operationScheduleEntity = (OperationScheduleEntity) query.getSingleResult(); return operationScheduleEntity; }
ScheduleJobId jobIdObject = new ScheduleJobId(jobId); String jobName = jobIdObject.getJobName(); String jobGroup = jobIdObject.getJobGroup();
ScheduleJobId jobIdObject = new ScheduleJobId(jobId); String jobName = jobIdObject.getJobName(); String jobGroup = jobIdObject.getJobGroup();
private int getOperationScheduleEntityId(JobDetail jobDetail) { JobDataMap jobDataMap = jobDetail.getJobDataMap(); Object entityIdObj = jobDataMap.get(OperationJob.DATAMAP_INT_ENTITY_ID); int entityId; if (entityIdObj != null) { // for jobs created using RHQ 4.0 or later, the map will contain an entityId entry entityId = Integer.valueOf((String) entityIdObj); } else { // for jobs created prior to upgrading to RHQ 4.0, the map will not contain an entityId entry, // so we'll need to lookup the entity id from the DB. String jobName = jobDetail.getName(); String jobGroup = jobDetail.getGroup(); ScheduleJobId jobId = new ScheduleJobId(jobName, jobGroup); OperationScheduleEntity operationScheduleEntity = findOperationScheduleEntity(jobId); entityId = operationScheduleEntity.getId(); } return entityId; }
protected void updateOperationScheduleEntity(JobDetail jobDetail, Date nextFireTime, OperationManagerLocal operationManager) { try { String jobName = jobDetail.getName(); String jobGroup = jobDetail.getGroup(); ScheduleJobId jobId = new ScheduleJobId(jobName, jobGroup); if (nextFireTime == null) { operationManager.deleteOperationScheduleEntity(jobId); } else { operationManager.updateOperationScheduleEntity(jobId, nextFireTime.getTime()); } } catch (Exception e) { // do not abort the execution of the job, just log an error // this schedule entity is just a tracking entity and if it fails to update or delete // its not a fatal error. But this is still bad - it means we'll have a row that either // exists but shouldn't or has an old next fire time (and queries relying on it will not // produce proper results). But again, this should not effect the actual operation invocation. LogFactory.getLog(OperationJob.class).error("Failed to update schedule entity for job: " + jobDetail, e); } }