/** * Return the default client. Note this client is shared in the static context. (said otherwise: the same client is always returned * inside a same class loading context). The initialization cost is only paid at first call. * * @return the default client */ public static JqmClient getClient() { return getClient(null, null, true); }
private JqmClient getJqmClient() { return JqmClientFactory.getClient(); }
@Override int doWork() { jqmlogger.info("Will enqueue application named " + applicationName + " without parameter overloads"); jqmlogger.info("Request ID is: " + JqmClientFactory.getClient().enqueue(applicationName, "CommandLineUser")); return 0; } }
/** * The end of the fluent Query API. It simply executes the query and returns the results. */ public List<JobInstance> run() { return JqmClientFactory.getClient().getJobs(this); }
private static void enqueue(String applicationName) { jqmlogger.info("Will enqueue application named " + applicationName + " without parameter overloads"); jqmlogger.info("Request ID is: " + JqmClientFactory.getClient().enqueue(applicationName, "CommandLineUser")); }
/** * Shortcut to submit the request to the JQM cluster. Equivalent to doing<br> * <code>JqmClientFactory.getClient().enqueue(this)</code><br> * See {@link JqmClient#enqueue(JobRequest)} for details on exceptions. * * @return the ID of the job instance. */ public Integer submit() { return JqmClientFactory.getClient().enqueue(this); }
@Override int doWork() { jqmlogger.info("Status is: " + JqmClientFactory.getClient().getJob(id).getState()); return 0; } }
@Override public void killThroughClientApi() { Properties props = new Properties(); props.put("com.enioka.jqm.jdbc.contextobject", Helpers.getDb()); JqmClientFactory.getClient("uncached", props, false).killJob(this.ji.getId()); }
/** * Helper method to enqueue a new launch request. Simple JqmClientFactory.getClient().enqueue wrapper. * * @return the request ID. */ public int enqueue(String name) { return JqmClientFactory.getClient().enqueue(JobRequest.create(name, "test")); }
/** * Helper method to enqueue a new launch request. Simple JqmClientFactory.getClient().enqueue wrapper. * * @return the request ID. */ public int enqueue(String name) { return JqmClientFactory.getClient().enqueue(JobRequest.create(name, "test")); }
@Override public void killThroughClientApi() { Properties props = new Properties(); props.put("com.enioka.jqm.jdbc.contextobject", Helpers.getDb()); JqmClientFactory.getClient("uncached", props, false).killJob(this.ji.getId()); }
@Override public void execute(TaskExecutionContext context) throws RuntimeException { JobRequest jr = JobRequest.create("", "cron").setScheduleId(sj.getId()); JqmClientFactory.getClient().enqueue(jr); }
@Override public void execute(TaskExecutionContext context) throws RuntimeException { JobRequest jr = JobRequest.create("", "cron").setScheduleId(sj.getId()); JqmClientFactory.getClient().enqueue(jr); }
@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()); } }
/** * This test is DB only - no simple service use */ @Test public void testGetAllDeliverables() throws Exception { int jobId = JqmSimpleTest.create(cnx, "pyl.EngineApiSendDeliverable").addDefParameter("filepath", TestHelpers.node.getDlRepo()) .addDefParameter("fileName", "jqm-test-deliverable5.txt").run(this); List<com.enioka.jqm.api.Deliverable> tmp = JqmClientFactory.getClient().getJobDeliverables(jobId); Assert.assertEquals(1, tmp.size()); } }
@Test public void testGetProgress() throws Exception { int i = JqmSimpleTest.create(cnx, "pyl.EngineApiProgress").addWaitMargin(10000).run(this); Integer k = JqmClientFactory.getClient().getJobProgress(i); Assert.assertEquals((Integer) 50, k); }
@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 testDelJobInQueue() 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().deleteJob(i); addAndStartEngine(); Thread.sleep(1000); Assert.assertEquals(0, TestHelpers.getHistoryAllCount(cnx)); Assert.assertEquals(0, TestHelpers.getQueueAllCount(cnx)); }
@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()); }
@Test public void testExternalKill() throws Exception { Helpers.setSingleParam("internalPollingPeriodMs", "100", cnx); int i = JqmSimpleTest.create(cnx, "pyl.KillMeNot").setExternal().expectNonOk(0).expectOk(0).run(this); TestHelpers.waitForRunning(1, 20000, cnx); JqmClientFactory.getClient().killJob(i); TestHelpers.waitFor(1, 20000, cnx); Assert.assertEquals(0, TestHelpers.getOkCount(cnx)); Assert.assertEquals(1, TestHelpers.getNonOkCount(cnx)); } }