@Override int doWork() { jqmlogger.info("Status is: " + JqmClientFactory.getClient().getJob(id).getState()); return 0; } }
private static void getStatus(int id) { jqmlogger.info("Status is: " + JqmClientFactory.getClient().getJob(id).getState()); }
return JqmClientFactory.getClient().getJob(job.getId());
return JqmClientFactory.getClient().getJob(job.getId());
JobInstance ji = JqmClientFactory.getClient().getJob(jid); Assert.assertEquals(com.enioka.jqm.api.State.ENDED, ji.getState()); Assert.assertEquals(2, ji.getParameters().size());
@Test public void testMainTypeInjectWithFullApi() throws Exception { // Here, engine API + full API mix. int i = JqmSimpleTest.create(cnx, "pyl.EngineApiInject", "jqm-test-pyl-hibapi").setSessionId("123X").expectOk(3).run(this); Assert.assertEquals(1, JqmClientFactory.getClient().getJob(i).getMessages().size()); // 1 message per run created by payload Assert.assertEquals(100, (int) JqmClientFactory.getClient().getJob(i).getProgress()); } }
@Test public void testHistoryFields() throws Exception { CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-datetimemaven/target/test.jar", TestHelpers.qVip, 42, "MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other2", true, cnx); int i = JobRequest.create("MarsuApplication", "TestUser").setSessionID("session42").setKeyword1("k1").setKeyword2("k2").submit(); addAndStartEngine(); TestHelpers.waitFor(1, 10000, cnx); Assert.assertEquals(1, TestHelpers.getOkCount(cnx)); JobInstance h = JqmClientFactory.getClient().getJob(i); SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm"); jqmlogger.debug("enqueueDate: " + df.format(h.getEnqueueDate().getTime())); jqmlogger.debug("ExecutionDate: " + df.format(h.getBeganRunningDate().getTime())); jqmlogger.debug("EndDate: " + df.format(h.getEndDate().getTime())); Assert.assertTrue(h.getEnqueueDate() != null); Assert.assertTrue(h.getUser() != null); Assert.assertTrue(h.getEndDate() != null); Assert.assertTrue(h.getBeganRunningDate() != null); Assert.assertTrue(h.getSessionID() != null); Assert.assertEquals("session42", h.getSessionID()); JobInstance ji = Query.create().setApplicationName("MarsuApplication").run().get(0); Assert.assertEquals("ModuleMachin", ji.getDefinitionKeyword1()); Assert.assertEquals("other", ji.getDefinitionKeyword2()); Assert.assertEquals("other2", ji.getDefinitionKeyword3()); Assert.assertEquals("k1", ji.getKeyword1()); Assert.assertEquals("k2", ji.getKeyword2()); Assert.assertEquals(null, ji.getKeyword3()); }
@Test public void testRmParameterCleanup() throws Exception { // Single thread available. int qId = Queue.create(cnx, "testqueue", " ", false); DeploymentParameter.create(cnx, TestHelpers.node.getId(), 2, 1, qId); // 2 slots Map<String, String> prms = new HashMap<>(1); prms.put("com.enioka.jqm.rm.quantity.thread.consumption", "2"); prms.put("whatever", "value"); CreationTools.createJobDef(null, true, "pyl.MessagePerParameter", prms, "jqm-tests/jqm-test-pyl/target/test.jar", qId, 42, "jqm-test-kill", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); cnx.commit(); int i1 = JobRequest.create("jqm-test-kill", "test").setPriority(null).submit(); addAndStartEngine(); TestHelpers.waitFor(1, 60000, cnx); // Check only one of the two JI has started (asking for total 3 slots, only 2 available) Assert.assertEquals(1, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getQueueRunningCount(cnx)); Assert.assertEquals(0, TestHelpers.getQueueAllCount(cnx)); // Check the parameter wazs removed by the RM JobInstance ji = JqmClientFactory.getClient().getJob(i1); Assert.assertEquals(1, ji.getMessages().size()); }
@Test public void testEnqueueWithQueue() throws Exception { CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-datetimemaven/target/test.jar", TestHelpers.qVip, 42, "MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); int i = JobRequest.create("MarsuApplication", "TestUser").setQueueName("NormalQueue").submit(); addAndStartEngine(); TestHelpers.waitFor(1, 10000, cnx); JobInstance ji = JqmClientFactory.getClient().getJob(i); Assert.assertEquals("NormalQueue", ji.getQueue().getName()); }