/** * Helper query (directly uses {@link Query}). Gives the count of all ended (KO and OK) job instances. */ public int getHistoryAllCount() { return Query.create().run().size(); }
/** * Helper query (directly uses {@link Query}). Gives the count of all ended (KO and OK) job instances. */ public int getHistoryAllCount() { return Query.create().run().size(); }
/** * Helper query (directly uses {@link Query}). Gives the count of all OK-ended job instances. */ public int getOkCount() { return Query.create().addStatusFilter(State.ENDED).run().size(); }
/** * Helper query (directly uses {@link Query}). Gives the count of all OK-ended job instances. */ public int getOkCount() { return Query.create().addStatusFilter(State.ENDED).run().size(); }
/** * Helper query (directly uses {@link Query}). Gives the count of all non-OK-ended job instances. */ public int getNonOkCount() { return Query.create().addStatusFilter(State.CRASHED).addStatusFilter(State.KILLED).run().size(); }
/** * Helper query (directly uses {@link Query}). Gives the count of all non-ended (waiting in queue, running...) job instances. */ public int getQueueAllCount() { return Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).run().size(); }
/** * Helper query (directly uses {@link Query}). Gives the count of all non-ended (waiting in queue, running...) job instances. */ public int getQueueAllCount() { return Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).run().size(); }
/** * Helper query (directly uses {@link Query}). Gives the count of all non-OK-ended job instances. */ public int getNonOkCount() { return Query.create().addStatusFilter(State.CRASHED).addStatusFilter(State.KILLED).run().size(); }
@Override public List<com.enioka.jqm.api.JobInstance> getJobs() { return Query.create().setQueryHistoryInstances(true).setQueryLiveInstances(true).run(); }
@Override public List<com.enioka.jqm.api.JobInstance> getActiveJobs() { return Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).addSortAsc(Sort.ID).run(); }
@Override public List<com.enioka.jqm.api.JobInstance> getUserActiveJobs(String user) { if (user == null || user.isEmpty()) { throw new JqmInvalidRequestException("user cannot be null or empty"); } return Query.create().setUser(user).setQueryHistoryInstances(false).setQueryLiveInstances(true).addSortAsc(Sort.ID).run(); }
protected void displayAllHistoryTable() { java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("HH:mm:ss.SSS"); jqmlogger.debug("=========================================================================================="); for (JobInstance h : Query.create().run()) { jqmlogger.debug("JobInstance Id: " + h.getId() + " | " + h.getState() + " | JD: " + h.getApplicationName() + " | " + h.getQueueName() + " | enqueue: " + format.format(h.getEnqueueDate().getTime()) + " | exec: " + (h.getBeganRunningDate() != null ? format.format(h.getBeganRunningDate().getTime()) : null) + " | end: " + (h.getEndDate() != null ? format.format(h.getEndDate().getTime()) : null)); } jqmlogger.debug("=========================================================================================="); } }
@Test public void testSendProgress() throws Exception { JqmSimpleTest.create(cnx, "pyl.EngineApiProgress").addWaitMargin(10000).run(this); List<JobInstance> res = Query.create().run(); Assert.assertEquals((Integer) 50, res.get(0).getProgress()); }
/** * A parent job can wait for all its children - then its end date should be after the end date of the children. */ @Test public void testWaitChildren() throws Exception { JqmSimpleTest.create(cnx, "pyl.EngineApiWaitAll").expectOk(6).run(this); List<JobInstance> jj = Query.create().addSortAsc(Sort.ID).addStatusFilter(State.ENDED).run(); Calendar parentEnd = jj.get(0).getEndDate(); for (int i = 1; i < 6; i++) { Assert.assertTrue(parentEnd.after(jj.get(i).getEndDate())); } }
@Test public void testKillJob() throws Exception { int i = JqmSimpleTest.create(cnx, "pyl.KillMe").expectOk(0).addWaitTime(3000).run(this); JqmClientFactory.getClient().killJob(i); TestHelpers.waitFor(1, 3000, cnx); List<JobInstance> res = Query.create().run(); Assert.assertEquals(1, res.size()); Assert.assertEquals(State.CRASHED, res.get(0).getState()); }
@Test public void testMainTypeInject() throws Exception { JqmSimpleTest.create(cnx, "pyl.EngineApiInject").setSessionId("123X").expectOk(3).run(this); Assert.assertEquals(3, (int) cnx.runSelectSingle("message_select_count_all", Integer.class)); Assert.assertEquals(100, (int) Query.create().run().get(0).getProgress()); }
@Test public void testRunnableInject() throws Exception { JqmSimpleTest.create(cnx, "pyl.EngineApiInjectThread").expectOk(3).run(this); Assert.assertEquals(3, (int) cnx.runSelectSingle("message_select_count_all", Integer.class)); Assert.assertEquals(100, (int) Query.create().addSortAsc(Sort.ID).run().get(0).getProgress()); }
@Test public void testChangeQueue() 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").submit(); JqmClientFactory.getClient().setJobQueue(i, TestHelpers.qSlow); addAndStartEngine(); TestHelpers.waitFor(1, 10000, cnx); List<JobInstance> res = Query.create().addSortAsc(Sort.DATEENQUEUE).run(); Assert.assertEquals(1, res.size()); Assert.assertEquals(State.ENDED, res.get(0).getState()); Assert.assertEquals("SlowQueue", res.get(0).getQueue().getName()); }
@Test public void testCancelJob() 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").submit(); JqmClientFactory.getClient().cancelJob(i); JobRequest.create("MarsuApplication", "TestUser").submit(); addAndStartEngine(); TestHelpers.waitFor(2, 5000, cnx); List<JobInstance> res = Query.create().addSortAsc(Sort.DATEENQUEUE).run(); Assert.assertEquals(2, res.size()); Assert.assertEquals(State.CANCELLED, res.get(0).getState()); Assert.assertEquals(State.ENDED, res.get(1).getState()); }
@Test public void testDisabledPayload() throws Exception { int jd = CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-datetimemaven/target/test.jar", TestHelpers.qVip, 42, "MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other", true, cnx); cnx.runUpdate("jd_update_set_enabled_by_id", false, jd); cnx.commit(); JobRequest.create("MarsuApplication", "TestUser").submit(); addAndStartEngine(); TestHelpers.waitFor(1, 10000, cnx); Assert.assertEquals(1, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); Assert.assertEquals(-1, (int) Query.create().run().get(0).getProgress()); }