public void update(DbConn cnx) { if (this.id == null) { this.id = create(cnx, name, description, defaultQueue); } else { cnx.runUpdate("q_update_all_fields_by_id", defaultQueue, description, name, id); } } }
public void update(DbConn cnx) { if (this.id == null) { this.id = create(cnx, name, description, defaultQueue); } else { cnx.runUpdate("q_update_all_fields_by_id", defaultQueue, description, name, id); } } }
/** * Create a new queue. After creation, it is not polled by any node - see {@link #deployQueueToNode(String, int, int, String...)} for * this.<br> * The first queue created is considered to be the default queue.<br> * This must be called before starting the engines. * * @param name * must be unique. */ public JqmAsyncTester addQueue(String name) { if (hasStarted) { throw new IllegalStateException("tester has already started"); } int q = Queue.create(cnx, name, "test queue", queues.size() == 0); cnx.commit(); queues.put(name, q); return this; }
/** * Create a new queue. After creation, it is not polled by any node - see {@link #deployQueueToNode(String, int, int, String...)} for * this.<br> * The first queue created is considered to be the default queue.<br> * This must be called before starting the engines. * * @param name * must be unique. */ public JqmAsyncTester addQueue(String name) { if (hasStarted) { throw new IllegalStateException("tester has already started"); } int q = Queue.create(cnx, name, "test queue", queues.size() == 0); cnx.commit(); queues.put(name, q); return this; }
resDirectoryPath.getAbsolutePath(), "test", "INFO"); q = Queue.create(cnx, "default", "default test queue", true); // Only useful because JobDef.queue is non-null
GlobalParameter.create(cnx, "disableVerboseStartup", "true"); TestHelpers.qVip = Queue.create(cnx, "VIPQueue", "Queue for the winners", true); TestHelpers.qNormal = Queue.create(cnx, "NormalQueue", "Queue for the ordinary job", false); TestHelpers.qSlow = Queue.create(cnx, "SlowQueue", "Queue for the bad guys", false); TestHelpers.qVip2 = Queue.create(cnx, "VIPQueue2", "Queue for the winners2", false); TestHelpers.qNormal2 = Queue.create(cnx, "NormalQueue2", "Queue for the ordinary job2", false); TestHelpers.qSlow2 = Queue.create(cnx, "SlowQueue2", "Queue for the bad guys2", false); TestHelpers.qVip3 = Queue.create(cnx, "VIPQueue3", "Queue for the winners3", false); TestHelpers.qNormal3 = Queue.create(cnx, "NormalQueue3", "Queue for the ordinary job3", false); TestHelpers.qSlow3 = Queue.create(cnx, "SlowQueue3", "Queue for the bad guys3", false);
resDirectoryPath.getAbsolutePath(), "test", "INFO"); q = Queue.create(cnx, "default", "default test queue", true); // Only useful because JobDef.queue is non-null
GlobalParameter.create(cnx, "disableVerboseStartup", "true"); TestHelpers.qVip = Queue.create(cnx, "VIPQueue", "Queue for the winners", true); TestHelpers.qNormal = Queue.create(cnx, "NormalQueue", "Queue for the ordinary job", false); TestHelpers.qSlow = Queue.create(cnx, "SlowQueue", "Queue for the bad guys", false); TestHelpers.qVip2 = Queue.create(cnx, "VIPQueue2", "Queue for the winners2", false); TestHelpers.qNormal2 = Queue.create(cnx, "NormalQueue2", "Queue for the ordinary job2", false); TestHelpers.qSlow2 = Queue.create(cnx, "SlowQueue2", "Queue for the bad guys2", false); TestHelpers.qVip3 = Queue.create(cnx, "VIPQueue3", "Queue for the winners3", false); TestHelpers.qNormal3 = Queue.create(cnx, "NormalQueue3", "Queue for the ordinary job3", false); TestHelpers.qSlow3 = Queue.create(cnx, "SlowQueue3", "Queue for the bad guys3", false);
public static void upsertQueue(DbConn cnx, QueueDto dto) { if (dto.getId() != null) { cnx.runUpdate("q_update_changed_by_id", dto.isDefaultQueue(), dto.getDescription(), dto.getName(), dto.getId(), dto.isDefaultQueue(), dto.getDescription(), dto.getName()); } else { Queue.create(cnx, dto.getName(), dto.getDescription(), dto.isDefaultQueue()); } }
public static void upsertQueue(DbConn cnx, QueueDto dto) { if (dto.getId() != null) { cnx.runUpdate("q_update_changed_by_id", dto.isDefaultQueue(), dto.getDescription(), dto.getName(), dto.getId(), dto.isDefaultQueue(), dto.getDescription(), dto.getName()); } else { Queue.create(cnx, dto.getName(), dto.getDescription(), dto.isDefaultQueue()); } }
@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 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()); }
int qId = Queue.create(cnx, "testqueue", "super test queue", false);
int qId = Queue.create(cnx, "testqueue", " ", false); DeploymentParameter.create(cnx, TestHelpers.node.getId(), 3, 1, qId);
@Test public void testFifo() throws Exception { // Single thread available. 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. int i1 = JobRequest.create("jqm-test-wait", "test").addParameter("ms", "100").setPriority(null).submit(); int i2 = JobRequest.create("jqm-test-wait", "test").addParameter("ms", "100").setPriority(null).submit(); addAndStartEngine(); TestHelpers.waitFor(2, 60000, cnx); Assert.assertEquals(2, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getQueueRunningCount(cnx)); JobInstance ji1 = Query.create().setJobInstanceId(i1).run().get(0); JobInstance ji2 = Query.create().setJobInstanceId(i2).run().get(0); Assert.assertTrue(ji1.getBeganRunningDate().compareTo(ji2.getEndDate()) <= 0); }
@Test public void testHighlanderMultiNodeBug195() throws Exception int q = Queue.create(cnx, "q", "test queue", false); DeploymentParameter.create(cnx, TestHelpers.node.getId(), 1, 1, q); DeploymentParameter.create(cnx, TestHelpers.nodeMix.getId(), 1, 1, q);
int qId = Queue.create(cnx, "testqueue", " ", false); DeploymentParameter.create(cnx, TestHelpers.node.getId(), 3, 3600000, qId);
@Test public void testTakingMultipleResources() 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"); // using fully qualified RM with RM name 'thread' - not the generic // key CreationTools.createJobDef(null, true, "pyl.Wait", prms, "jqm-tests/jqm-test-pyl-nodep/target/test.jar", qId, 42, "jqm-test-wait-dual", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); CreationTools.createJobDef(null, true, "pyl.Wait", null, "jqm-tests/jqm-test-pyl-nodep/target/test.jar", qId, 42, "jqm-test-wait-single", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); cnx.commit(); int i1 = JobRequest.create("jqm-test-wait-single", "test").setPriority(null).submit(); int i2 = JobRequest.create("jqm-test-wait-dual", "test").setPriority(null).submit(); addAndStartEngine(); TestHelpers.waitForRunning(1, 60000, cnx); sleep(1); // Time to start another if case of bug... // Check only one of the two JI has started (asking for total 3 slots, only 2 available) Assert.assertEquals(0, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); Assert.assertEquals(1, TestHelpers.getQueueRunningCount(cnx)); Assert.assertEquals(2, TestHelpers.getQueueAllCount(cnx)); // Cleanup JqmClientFactory.getClient().killJob(i1); JqmClientFactory.getClient().killJob(i2); TestHelpers.waitFor(2, 1000, cnx); }
@Test public void testPriority() throws Exception { // Single thread available. 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(); // Enqueue a low priority first, then a higher priority one. The higher priority should run first. int i1 = JobRequest.create("jqm-test-wait", "test").addParameter("ms", "100").setPriority(1).submit(); int i2 = JobRequest.create("jqm-test-wait", "test").addParameter("ms", "100").setPriority(6).submit(); addAndStartEngine(); TestHelpers.waitFor(2, 60000, cnx); Assert.assertEquals(2, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getQueueRunningCount(cnx)); JobInstance ji1 = Query.create().setJobInstanceId(i1).run().get(0); JobInstance ji2 = Query.create().setJobInstanceId(i2).run().get(0); Assert.assertEquals(1, (int) ji1.getPriority()); Assert.assertEquals(6, (int) ji2.getPriority()); Assert.assertTrue(ji1.getBeganRunningDate().compareTo(ji2.getEndDate()) >= 0); }
int qId = Queue.create(cnx, "testqueue", " ", false); DeploymentParameter.create(cnx, TestHelpers.node.getId(), 40, 1, qId); // 40 threads, so not the limiting factor.