private Integer highlanderMode(JobDef jd, DbConn cnx) if (!jd.isHighlander())
@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; } }
addTextElementToParentElement(jobDefinition, "highlander", j.isHighlander() ? "true" : "false");
addTextElementToParentElement(jobDefinition, "highlander", j.isHighlander() ? "true" : "false");
tmp.setCanBeRestarted(jd.isCanBeRestarted()); tmp.setDescription(jd.getDescription()); tmp.setHighlander(jd.isHighlander()); tmp.setKeyword1(jd.getKeyword1()); tmp.setKeyword2(jd.getKeyword2());
runRequest.getKeyword3(), runRequest.getSessionID(), runRequest.getUser(), runRequest.getEmail(), jobDef.isHighlander(), sj != null || runRequest.getRunAfter() != null, runRequest.getRunAfter(), priority, Instruction.RUN, prms);
@Test public void testXmlParser() { // Init the default queue (don't start the engine!) Helpers.updateConfiguration(cnx); XmlJobDefParser.parse("target/payloads/jqm-test-xml/xmltest.xml", cnx); cnx.commit(); List<JobDef> jd = JobDef.select(cnx, "jd_select_all"); JobDef fibo = JobDef.select_key(cnx, "Fibo"); Assert.assertEquals(2, jd.size()); Assert.assertEquals("Fibo", fibo.getApplicationName()); Assert.assertEquals(true, fibo.isCanBeRestarted()); Assert.assertEquals("com.enioka.jqm.tests.App", fibo.getJavaClassName()); Assert.assertEquals(TestHelpers.qVip, fibo.getQueue()); Assert.assertEquals("ApplicationTest", fibo.getApplication()); Assert.assertEquals("TestModuleRATONLAVEUR", fibo.getModule()); Assert.assertEquals(false, fibo.isHighlander()); Assert.assertEquals("1", fibo.getParametersMap(cnx).get("p1")); Assert.assertEquals("2", fibo.getParametersMap(cnx).get("p2")); Assert.assertEquals("com.enioka.jqm.tests.App", fibo.getJavaClassName()); Assert.assertEquals("com.enioka.jqm.tests.App", fibo.getJavaClassName()); }
/** * Create an History object from a {@link JobInstance}. * */ public static void create(DbConn cnx, JobInstance ji, State finalState, Calendar endDate) { JobDef jd = ji.getJD(); Node n = ji.getNode(); Queue q = ji.getQ(); if (endDate == null) { cnx.runUpdate("history_insert", ji.getId(), jd.getApplication(), jd.getApplicationName(), ji.getAttributionDate(), ji.getEmail(), ji.getCreationDate(), ji.getExecutionDate(), jd.isHighlander(), ji.getApplication(), ji.getKeyword1(), ji.getKeyword2(), ji.getKeyword3(), ji.getModule(), jd.getKeyword1(), jd.getKeyword2(), jd.getKeyword3(), jd.getModule(), n == null ? null : n.getName(), ji.getParentId(), ji.getProgress(), q == null ? null : q.getName(), 0, ji.getSessionID(), finalState.toString(), ji.getUserName(), ji.getJdId(), n == null ? null : n.getId(), ji.getQueue(), ji.isFromSchedule(), ji.getPriority()); } else { cnx.runUpdate("history_insert_with_end_date", ji.getId(), jd.getApplication(), jd.getApplicationName(), ji.getAttributionDate(), ji.getEmail(), endDate, ji.getCreationDate(), ji.getExecutionDate(), jd.isHighlander(), ji.getApplication(), ji.getKeyword1(), ji.getKeyword2(), ji.getKeyword3(), ji.getModule(), jd.getKeyword1(), jd.getKeyword2(), jd.getKeyword3(), jd.getModule(), n.getName(), ji.getParentId(), ji.getProgress(), q.getName(), 0, ji.getSessionID(), finalState.toString(), ji.getUserName(), ji.getJdId(), ji.getNode().getId(), ji.getQueue(), ji.isFromSchedule(), ji.getPriority()); } }
/** * Create an History object from a {@link JobInstance}. * */ public static void create(DbConn cnx, JobInstance ji, State finalState, Calendar endDate) { JobDef jd = ji.getJD(); Node n = ji.getNode(); Queue q = ji.getQ(); if (endDate == null) { cnx.runUpdate("history_insert", ji.getId(), jd.getApplication(), jd.getApplicationName(), ji.getAttributionDate(), ji.getEmail(), ji.getCreationDate(), ji.getExecutionDate(), jd.isHighlander(), ji.getApplication(), ji.getKeyword1(), ji.getKeyword2(), ji.getKeyword3(), ji.getModule(), jd.getKeyword1(), jd.getKeyword2(), jd.getKeyword3(), jd.getModule(), n == null ? null : n.getName(), ji.getParentId(), ji.getProgress(), q == null ? null : q.getName(), 0, ji.getSessionID(), finalState.toString(), ji.getUserName(), ji.getJdId(), n == null ? null : n.getId(), ji.getQueue(), ji.isFromSchedule(), ji.getPriority()); } else { cnx.runUpdate("history_insert_with_end_date", ji.getId(), jd.getApplication(), jd.getApplicationName(), ji.getAttributionDate(), ji.getEmail(), endDate, ji.getCreationDate(), ji.getExecutionDate(), jd.isHighlander(), ji.getApplication(), ji.getKeyword1(), ji.getKeyword2(), ji.getKeyword3(), ji.getModule(), jd.getKeyword1(), jd.getKeyword2(), jd.getKeyword3(), jd.getModule(), n.getName(), ji.getParentId(), ji.getProgress(), q.getName(), 0, ji.getSessionID(), finalState.toString(), ji.getUserName(), ji.getJdId(), ji.getNode().getId(), ji.getQueue(), ji.isFromSchedule(), ji.getPriority()); } }
Assert.assertEquals("other2", fibo.getKeyword2()); Assert.assertEquals(null, fibo.getKeyword3()); Assert.assertEquals(false, fibo.isHighlander()); Assert.assertEquals("Isolation", fibo.getClassLoader(cnx).getName()); Assert.assertEquals(true, fibo.getClassLoader().isChildFirst());