@Override BookingStatus bookResource(JobInstance ji, DbConn cnx) { if (!ji.getJD().isHighlander()) { // Non-highlander JI do not need anything from this RM. return BookingStatus.BOOKED; } // Lock the definition in the DB - this is a convention for highlander JI between clients and engine. ResultSet rs = cnx.runSelect(true, "jd_select_by_id", ji.getJD().getId()); // We have the lock. Check if there are already running instances. Integer runningCount = cnx.runSelectSingle("ji_select_existing_highlander_2", Integer.class, ji.getJD().getId()); if (runningCount != 0) { // Already running, so skip this JI. cnx.closeQuietly(rs); // release the lock. return BookingStatus.FAILED; } // If here, no running instance and lock is held (release by commit done in the QP, rs is closed with connection). return BookingStatus.BOOKED; } }
@Override BookingStatus bookResource(JobInstance ji, DbConn cnx) { if (!ji.getJD().isHighlander()) { // Non-highlander JI do not need anything from this RM. return BookingStatus.BOOKED; } // Lock the definition in the DB - this is a convention for highlander JI between clients and engine. ResultSet rs = cnx.runSelect(true, "jd_select_by_id", ji.getJD().getId()); // We have the lock. Check if there are already running instances. Integer runningCount = cnx.runSelectSingle("ji_select_existing_highlander_2", Integer.class, ji.getJD().getId()); if (runningCount != 0) { // Already running, so skip this JI. cnx.closeQuietly(rs); // release the lock. return BookingStatus.FAILED; } // If here, no running instance and lock is held (release by commit done in the QP, rs is closed with connection). return BookingStatus.BOOKED; } }
private int createSchedule(JobRequest jr, DbConn cnx) { // The job def JobDef jobDef = null; try { jobDef = JobDef.select_key(cnx, jr.getApplicationName()); } catch (NonUniqueResultException ex) { jqmlogger.error("There are multiple Job definition named " + jr.getApplicationName() + ". Inconsistent configuration."); closeQuietly(cnx); throw new JqmInvalidRequestException("There are multiple Job definition named " + jr.getApplicationName()); } catch (NoResultException ex) { jqmlogger.error("Job definition named " + jr.getApplicationName() + " does not exist"); closeQuietly(cnx); throw new JqmInvalidRequestException("no job definition named " + jr.getApplicationName()); } // The queue Integer queueId = null; // No override = use JD queue. if (jr.getQueueName() != null) { // use requested key if given. queueId = cnx.runSelectSingle("q_select_by_key", 1, Integer.class, jr.getQueueName()); } // The new schedule return ScheduledJob.create(cnx, jr.getRecurrence(), jobDef.getId(), queueId, jr.getPriority(), jr.getParameters()); }
jqmlogger.trace("Job to enqueue is from JobDef " + jobDef.getId()); Map<String, String> prms = JobDefParameter.select_map(cnx, "jdprm_select_all_for_jd", jobDef.getId()); if (sj != null) int id = JobInstance.enqueue(cnx, startingState, queue_id, jobDef.getId(), runRequest.getApplication(), runRequest.getParentID(), runRequest.getModule(), runRequest.getKeyword1(), runRequest.getKeyword2(), runRequest.getKeyword3(), runRequest.getSessionID(), runRequest.getUser(), runRequest.getEmail(), jobDef.isHighlander(),