@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; } }
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); }
/** * 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 start() { log.info("Starting payload"); EntityManagerFactory emf = Persistence.createEntityManagerFactory("marsu-pu"); EntityManager em = emf.createEntityManager(); log.info("Running query"); em.createQuery("SELECT e from Entity e"); if (this.getParameters().size() == 0) { log.info("Queuing again - with parameter and through the full API"); JobRequest jd = new JobRequest("jqm-test-em", "marsu"); jd.addParameter("stop", "1"); JqmClientFactory.getClient().enqueue(jd); } log.info("End of payload"); } }
@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 testQuery() throws Exception { CreationTools.createJobDef(null, true, "pyl.KillMe", null, "jqm-tests/jqm-test-pyl/target/test.jar", TestHelpers.qNormal, 42, "jqm-test-kill", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); cnx.commit(); JqmClientFactory.getClient().enqueue("jqm-test-kill", "test"); JqmClientFactory.getClient().enqueue("jqm-test-kill", "test"); JqmClientFactory.getClient().enqueue("jqm-test-kill", "test"); JqmClientFactory.getClient().enqueue("jqm-test-kill", "test"); JqmClientFactory.getClient().enqueue("jqm-test-kill", "test"); jqmlogger.debug("COUNT RUNNING " + cnx.runSelectSingle("ji_select_count_running", Integer.class)); jqmlogger.debug("COUNT ALL " + cnx.runSelectSingle("ji_select_count_all", Integer.class)); Assert.assertEquals(0, Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false) .addStatusFilter(com.enioka.jqm.api.State.RUNNING).addStatusFilter(com.enioka.jqm.api.State.ENDED).run().size()); Assert.assertEquals(5, Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false) .addStatusFilter(com.enioka.jqm.api.State.SUBMITTED).run().size()); }
@Test public void testHighlanderenqueueEngineDead() 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", true, cnx); JobRequest j = new JobRequest("MarsuApplication", "TestUser"); JqmClientFactory.getClient().enqueue(j); JqmClientFactory.getClient().enqueue(j); addAndStartEngine(); TestHelpers.waitFor(1, 10000, cnx); Assert.assertEquals(1, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); }
@Test public void testProvidedApi() throws Exception { CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-providedapi/target/test.jar", TestHelpers.qVip, 42, "MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other", true, cnx); // Create an empty lib directory just to be sure no dependencies will be resolved. FileUtils.forceMkdir(new File("../jqm-tests/jqm-test-providedapi/target/lib")); JobRequest j = new JobRequest("MarsuApplication", "TestUser"); JqmClientFactory.getClient().enqueue(j); addAndStartEngine(); TestHelpers.waitFor(1, 10000, cnx); Assert.assertEquals(1, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); }
@Test public void testLongName() throws Exception { CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-datetimemaven/target/test.jar", TestHelpers.qVip, 42, "Marsu-Application-nnnnnnnn-nnnnnn-nnnnnnnnnn-nnNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNnn-nnnnnnnnn", null, "Franquin", "ModuleMachin", "other", "other", true, cnx); JobRequest j = new JobRequest("Marsu-Application-nnnnnnnn-nnnnnn-nnnnnnnnnn-nnNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNnn-nnnnnnnnn", "TestUser"); JqmClientFactory.getClient().enqueue(j); addAndStartEngine(); TestHelpers.waitFor(1, 10000, cnx); Assert.assertEquals(1, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); }
public void testDbFailureUnderLoadWithExternalDb() throws Exception { // Many starting jobs simultaneously cnx.runUpdate("dp_update_threads_by_id", 50, TestHelpers.dpVip.getId()); cnx.commit(); TestHelpers.setNodesLogLevel("INFO", cnx); CreationTools.createJobDef(null, true, "pyl.Nothing", null, "jqm-tests/jqm-test-pyl-nodep/target/test.jar", TestHelpers.qVip, -1, "TestJqmApplication", "appFreeName", "TestModule", "kw1", "kw2", "kw3", false, cnx); JobRequest j = new JobRequest("TestJqmApplication", "TestUser"); for (int i = 0; i < 1000; i++) { JqmClientFactory.getClient().enqueue(j); } addAndStartEngine(); // TestHelpers.waitFor(ji, 120000, this.getNewDbSession()); this.sleep(1000); }
@Override public Integer enqueue(String applicationName, String user, String mail, String sessionId, String application, String module, String keyword1, String keyword2, String keyword3, Map<String, String> parameters) { JobRequest jr = new JobRequest(applicationName, user, mail); jr.setApplicationName(applicationName); jr.setUser(user == null ? ji.getUserName() : user); jr.setEmail(mail); jr.setSessionID(sessionId == null ? this.ji.getSessionID() : sessionId); jr.setApplication(application == null ? this.ji.getJD().getApplication() : application); jr.setModule(module == null ? this.ji.getJD().getModule() : module); jr.setKeyword1(keyword1); jr.setKeyword2(keyword2); jr.setKeyword3(keyword3); jr.setParentID(this.ji.getId()); if (parameters != null) { jr.setParameters(parameters); } return getJqmClient().enqueue(jr); }
@Override public Integer enqueue(String applicationName, String user, String mail, String sessionId, String application, String module, String keyword1, String keyword2, String keyword3, Map<String, String> parameters) { JobRequest jr = new JobRequest(applicationName, user, mail); jr.setApplicationName(applicationName); jr.setUser(user == null ? ji.getUserName() : user); jr.setEmail(mail); jr.setSessionID(sessionId == null ? this.ji.getSessionID() : sessionId); jr.setApplication(application == null ? this.ji.getJD().getApplication() : application); jr.setModule(module == null ? this.ji.getJD().getModule() : module); jr.setKeyword1(keyword1); jr.setKeyword2(keyword2); jr.setKeyword3(keyword3); jr.setParentID(this.ji.getId()); if (parameters != null) { jr.setParameters(parameters); } return getJqmClient().enqueue(jr); }
@Test public void testJobWithPersistenceUnitAndEngineApiAndXmlParams() throws Exception { CreationTools.createDatabaseProp("jdbc/test", "org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:testdbmarsu", "SA", "", cnx, "SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS", null); CreationTools.createDatabaseProp("jdbc/jqm2", "org.hsqldb.jdbcDriver", "jdbc:hsqldb:hsql://localhost/testdbengine", "SA", "", cnx, "SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS", null); cnx.commit(); XmlJobDefParser.parse("target/payloads/jqm-test-xml/xmlstop.xml", cnx); cnx.commit(); JobRequest j = new JobRequest("CompatHibApi", "TestUser"); JqmClientFactory.getClient().enqueue(j); addAndStartEngine(); TestHelpers.waitFor(1, 10000, cnx); Assert.assertEquals(1, TestHelpers.getOkCount(cnx)); }
@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 testDbFailureUnderLoad() throws Exception { // Many starting jobs simultaneously cnx.runUpdate("dp_update_threads_by_id", 50, TestHelpers.dpVip.getId()); cnx.commit(); TestHelpers.setNodesLogLevel("INFO", cnx); CreationTools.createJobDef(null, true, "pyl.Nothing", null, "jqm-tests/jqm-test-pyl-nodep/target/test.jar", TestHelpers.qVip, -1, "TestJqmApplication", "appFreeName", "TestModule", "kw1", "kw2", "kw3", false, cnx); JobRequest j = new JobRequest("TestJqmApplication", "TestUser"); for (int i = 0; i < 1000; i++) { JqmClientFactory.getClient().enqueue(j); } addAndStartEngine(); this.sleep(1); jqmlogger.info("Stopping db"); simulateDbFailure(); TestHelpers.waitFor(1000, 120000, this.getNewDbSession()); Assert.assertEquals(1000, TestHelpers.getOkCount(this.getNewDbSession())); // Assert.assertTrue(this.engines.get("localhost").isAllPollersPolling()); } }
@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)); }
public void testNoDuplicateLaunchesUnderLoad() throws Exception { // Many starting jobs simultaneously cnx.runUpdate("dp_update_threads_by_id", 50, TestHelpers.dpVip.getId()); cnx.commit(); TestHelpers.setNodesLogLevel("INFO", cnx); CreationTools.createJobDef(null, true, "pyl.Nothing", null, "jqm-tests/jqm-test-pyl-nodep/target/test.jar", TestHelpers.qVip, -1, "TestJqmApplication", "appFreeName", "TestModule", "kw1", "kw2", "kw3", false, cnx); JobRequest j = new JobRequest("TestJqmApplication", "TestUser"); int ji = 0; for (int i = 0; i < 1000; i++) { ++ji; JqmClientFactory.getClient().enqueue(j); } addAndStartEngine(); TestHelpers.waitFor(ji, 120000, this.getNewDbSession()); this.sleep(3); Assert.assertEquals(1000, TestHelpers.getHistoryAllCount(cnx)); } }