/** * See {@link #getNode()} */ public void setNode(final Node node) { this.n = node; this.node_id = node.getId(); }
/** * See {@link #getNode()} */ public void setNode(final Node node) { this.n = node; this.node_id = node.getId(); }
public static DeploymentParameter create(DbConn cnx, Node node, Integer nbThread, Integer pollingInterval, Integer queueId) { return create(cnx, node.getId(), nbThread, pollingInterval, queueId); }
public static DeploymentParameter create(DbConn cnx, Node node, Integer nbThread, Integer pollingInterval, Integer queueId) { return create(cnx, node.getId(), nbThread, pollingInterval, queueId); }
@Override public String getWebApiLocalUrl(DbConn cnx) { // Do not use port from engine.getNode, as it may have been set AFTER engine startup. Node node = Node.select_single(cnx, "node_select_by_id", this.engine.getNode().getId()); boolean useSsl = Boolean.parseBoolean(GlobalParameter.getParameter(cnx, "enableWsApiSsl", "false")); return (useSsl ? "https://localhost:" : "http://localhost:") + node.getPort(); } }
@Override public String getWebApiLocalUrl(DbConn cnx) { // Do not use port from engine.getNode, as it may have been set AFTER engine startup. Node node = Node.select_single(cnx, "node_select_by_id", this.engine.getNode().getId()); boolean useSsl = Boolean.parseBoolean(GlobalParameter.getParameter(cnx, "enableWsApiSsl", "false")); return (useSsl ? "https://localhost:" : "http://localhost:") + node.getPort(); } }
@Override public long getCumulativeJobInstancesCount() { DbConn em2 = Helpers.getNewDbSession(); try { return em2.runSelectSingle("history_select_count_for_poller", Long.class, this.queue.getId(), this.engine.getNode().getId()); } finally { Helpers.closeQuietly(em2); } }
@Before public void before() throws IOException { Helpers.setSingleParam("disableWsApi", "false", cnx); Helpers.setSingleParam("enableWsApiAuth", "false", cnx); File jar = FileUtils.listFiles(new File("../jqm-ws/target/"), new String[] { "war" }, false).iterator().next(); FileUtils.copyFile(jar, new File("./webapp/jqm-ws.war")); addAndStartEngine(); TestHelpers.node = Node.select_single(cnx, "node_select_by_id", TestHelpers.node.getId()); }
@Override public long getCumulativeJobInstancesCount() { DbConn em2 = Helpers.getNewDbSession(); try { return em2.runSelectSingle("history_select_count_for_poller", Long.class, this.queue.getId(), this.engine.getNode().getId()); } finally { Helpers.closeQuietly(em2); } }
@Override public float getJobsFinishedPerSecondLastMinute() { DbConn em2 = Helpers.getNewDbSession(); try { return em2.runSelectSingle("history_select_count_last_mn_for_poller", Float.class, this.queue.getId(), this.engine.getNode().getId()); } finally { Helpers.closeQuietly(em2); } }
@Override public float getJobsFinishedPerSecondLastMinute() { DbConn em2 = Helpers.getNewDbSession(); try { return em2.runSelectSingle("history_select_count_last_mn_for_poller", Float.class, this.queue.getId(), this.engine.getNode().getId()); } finally { Helpers.closeQuietly(em2); } }
@Override public void resume() { DbConn cnx = null; try { cnx = Helpers.getNewDbSession(); cnx.runUpdate("node_update_enabled_by_id", Boolean.TRUE, node.getId()); cnx.commit(); } finally { Helpers.closeQuietly(cnx); } refreshConfiguration(); }
@Override public void pause() { DbConn cnx = null; try { cnx = Helpers.getNewDbSession(); cnx.runUpdate("node_update_enabled_by_id", Boolean.FALSE, node.getId()); cnx.commit(); } finally { Helpers.closeQuietly(cnx); } refreshConfiguration(); }
@Override public void pause() { DbConn cnx = null; try { cnx = Helpers.getNewDbSession(); cnx.runUpdate("node_update_enabled_by_id", Boolean.FALSE, node.getId()); cnx.commit(); } finally { Helpers.closeQuietly(cnx); } refreshConfiguration(); }
@Test public void testRemoteStop() throws Exception { Helpers.setSingleParam("internalPollingPeriodMs", "10", cnx); addAndStartEngine(); cnx.runUpdate("node_update_stop_by_id", TestHelpers.node.getId()); cnx.commit(); TestHelpers.waitFor(2, 3000, cnx); Assert.assertFalse(engines.get("localhost").areAllPollersPolling()); engines.clear(); }
@Test public void testTemplate() throws Exception { NodeDto template = MetaService.getNode(cnx, TestHelpers.nodeMix.getId()); template.setPort(123); MetaService.upsertNode(cnx, template); cnx.commit(); NodeDto target = MetaService.getNode(cnx, TestHelpers.node.getId()); Assert.assertEquals(3, MetaService.getNodeQueueMappings(cnx, target.getId()).size()); // Capital letter -> should be ignored. Main.runCommand(new String[] { "Install-NodeTemPlate", "-t", TestHelpers.nodeMix.getName(), "-n", TestHelpers.node.getName() }); target = MetaService.getNode(cnx, TestHelpers.node.getId()); Assert.assertEquals(template.getPort(), target.getPort()); Assert.assertEquals(1, MetaService.getNodeQueueMappings(cnx, target.getId()).size()); } }
@Test public void testPauseResume() throws Exception { cnx.runUpdate("node_update_enabled_by_id", false, TestHelpers.node.getId()); cnx.commit(); // Submit request => nothing should happen JqmSimpleTest.create(cnx, "pyl.PckMain", "jqm-test-pyl-nodep").addWaitTime(3000).expectNonOk(0).expectOk(0).run(this); // Resume => JI should be run and end OK this.engines.get("localhost").resume(); TestHelpers.waitFor(1, 5000, cnx); Assert.assertEquals(1, TestHelpers.getOkCount(cnx)); } }
@Test(expected = JqmInvalidRequestException.class) public void testPriorityLimits() { int qId = Queue.create(cnx, "testqueue", " ", false); DeploymentParameter.create(cnx, TestHelpers.node.getId(), 1, 1, qId); CreationTools.createJobDef(null, true, "pyl.Wait", null, "jqm-tests/jqm-test-pyl-nodep/target/test.jar", qId, 42, "jqm-test-wait", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); cnx.commit(); // No priority = FIFO queue. JobRequest.create("jqm-test-wait", "test").addParameter("ms", "100").setPriority(Integer.MAX_VALUE).submit(); }
@Test public void testStartupCleanupAttr() throws Exception { CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-em/target/test.jar", TestHelpers.qVip, 42, "jqm-test-em", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); // Create a running job that should be cleaned at startup int i = JqmClientFactory.getClient().enqueue("jqm-test-em", "test"); cnx.runUpdate("ji_update_status_by_id", TestHelpers.node.getId(), i); cnx.commit(); addAndStartEngine(); Assert.assertEquals(0, TestHelpers.getQueueAllCount(cnx)); Assert.assertEquals(1, TestHelpers.getHistoryAllCount(cnx)); Assert.assertEquals(1, TestHelpers.getNonOkCount(cnx)); }
@Test public void testStartupCleanupRunning() throws Exception { CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-em/target/test.jar", TestHelpers.qVip, 42, "jqm-test-em", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); /// Create a running job that should be cleaned at startup int i1 = JqmClientFactory.getClient().enqueue("jqm-test-em", "test"); cnx.runUpdate("ji_update_status_by_id", TestHelpers.node.getId(), i1); cnx.runUpdate("jj_update_run_by_id", i1); cnx.commit(); addAndStartEngine(); Assert.assertEquals(0, TestHelpers.getQueueAllCount(cnx)); Assert.assertEquals(1, TestHelpers.getHistoryAllCount(cnx)); Assert.assertEquals(1, TestHelpers.getNonOkCount(cnx)); }