/** * Create the query cache (with db-specific queries) */ private void initQueries() { DbConn cnx = getConn(); adapter.prepare(p, cnx._cnx); cnx.close(); }
public static JobInstance run(int jobInstanceId) { jqmlogger.debug("Single runner was asked to start with ID " + jobInstanceId); DbConn cnx = Helpers.getNewDbSession(); com.enioka.jqm.model.JobInstance jr = com.enioka.jqm.model.JobInstance.select_id(cnx, jobInstanceId); cnx.close(); if (jr == null) { throw new IllegalArgumentException("There is no JobRequest by ID " + jobInstanceId); } return run(jr); }
public static JobInstance run(int jobInstanceId) { jqmlogger.debug("Single runner was asked to start with ID " + jobInstanceId); DbConn cnx = Helpers.getNewDbSession(); com.enioka.jqm.model.JobInstance jr = com.enioka.jqm.model.JobInstance.select_id(cnx, jobInstanceId); cnx.close(); if (jr == null) { throw new IllegalArgumentException("There is no JobRequest by ID " + jobInstanceId); } return run(jr); }
/** * Create the query cache (with db-specific queries) */ private void initQueries() { DbConn cnx = getConn(); adapter.prepare(p, cnx._cnx); cnx.close(); }
InternalPoller(JqmEngine e) { this.engine = e; DbConn cnx = Helpers.getNewDbSession(); // Get configuration data this.node = this.engine.getNode(); this.step = Long.parseLong(GlobalParameter.getParameter(cnx, "internalPollingPeriodMs", "60000")); cnx.close(); }
InternalPoller(JqmEngine e) { this.engine = e; DbConn cnx = Helpers.getNewDbSession(); // Get configuration data this.node = this.engine.getNode(); this.step = Long.parseLong(GlobalParameter.getParameter(cnx, "internalPollingPeriodMs", "60000")); cnx.close(); }
@Override public void run() { Thread.currentThread().setName("JQM single runner;killerloop;" + jobId); DbConn cnx = null; while (!Thread.interrupted()) { cnx = Helpers.getNewDbSession(); com.enioka.jqm.model.JobInstance job = com.enioka.jqm.model.JobInstance.select_id(cnx, jobId); cnx.close(); if (job != null && job.getInstruction().equals(com.enioka.jqm.model.Instruction.KILL)) { jqmlogger.debug( "Job " + jobId + " has received a kill order. It's JVM will be killed after a grace shutdown period"); System.exit(1); // Launch the exit hook. break; } try { Thread.sleep(poll); } catch (InterruptedException e) { break; } } } };
private void close() { s.stop(); s.shutdown(); cnx.close(); JqmClientFactory.resetClient(); JqmClientFactory.setProperties(new Properties()); }
@Override public void run() { Thread.currentThread().setName("JQM single runner;killerloop;" + jobId); DbConn cnx = null; while (!Thread.interrupted()) { cnx = Helpers.getNewDbSession(); com.enioka.jqm.model.JobInstance job = com.enioka.jqm.model.JobInstance.select_id(cnx, jobId); cnx.close(); if (job != null && job.getInstruction().equals(com.enioka.jqm.model.Instruction.KILL)) { jqmlogger.debug( "Job " + jobId + " has received a kill order. It's JVM will be killed after a grace shutdown period"); System.exit(1); // Launch the exit hook. break; } try { Thread.sleep(poll); } catch (InterruptedException e) { break; } } } };
private void close() { s.stop(); s.shutdown(); cnx.close(); JqmClientFactory.resetClient(); JqmClientFactory.setProperties(new Properties()); }
/** * Stops all engines. Only returns when engines are fully stopped. */ public void stop() { if (!hasStarted) { throw new IllegalStateException("cannot stop a tester which has not started"); } for (JqmEngineOperations op : this.engines.values()) { op.stop(); } JqmClientFactory.resetClient(); cnx.close(); s.stop(); waitDbStop(); s = null; hasStarted = false; this.engines.clear(); }
/** * Stops all engines. Only returns when engines are fully stopped. */ public void stop() { if (!hasStarted) { throw new IllegalStateException("cannot stop a tester which has not started"); } for (JqmEngineOperations op : this.engines.values()) { op.stop(); } JqmClientFactory.resetClient(); cnx.close(); s.stop(); waitDbStop(); s = null; hasStarted = false; this.engines.clear(); }
public CronScheduler(JqmEngine e) { this.node = e.getNode(); DbConn cnx = Helpers.getNewDbSession(); this.schedulerKeepAlive = Integer.parseInt(GlobalParameter.getParameter(cnx, "schedulerKeepAlive", "30000")); boolean shouldStart = !Boolean.parseBoolean(GlobalParameter.getParameter(cnx, "disableScheduler", "false")); if (!shouldStart) { jqmlogger.info("Scheduling functions are disabled"); return; } try { cnx.runUpdate("w_insert", this.node.getId()); cnx.commit(); jqmlogger.debug("This node is the first scheduling node to start inside the cluster"); } catch (DatabaseException ex) { // Ignore it (UK error). It means the line already exists inside the database. } cnx.close(); // Start the thread t = new Thread(this); t.start(); }
public CronScheduler(JqmEngine e) { this.node = e.getNode(); DbConn cnx = Helpers.getNewDbSession(); this.schedulerKeepAlive = Integer.parseInt(GlobalParameter.getParameter(cnx, "schedulerKeepAlive", "30000")); boolean shouldStart = !Boolean.parseBoolean(GlobalParameter.getParameter(cnx, "disableScheduler", "false")); if (!shouldStart) { jqmlogger.info("Scheduling functions are disabled"); return; } try { cnx.runUpdate("w_insert", this.node.getId()); cnx.commit(); jqmlogger.debug("This node is the first scheduling node to start inside the cluster"); } catch (DatabaseException ex) { // Ignore it (UK error). It means the line already exists inside the database. } cnx.close(); // Start the thread t = new Thread(this); t.start(); }
@Override public Long getRunTimeSeconds() { if (this.ji.getExecutionDate() == null) { DbConn cnx = Helpers.getNewDbSession(); this.ji.setExecutionDate(cnx.runSelectSingle("ji_select_execution_date_by_id", Calendar.class, this.ji.getId())); cnx.close(); } if (this.ji.getExecutionDate() == null) { return 0L; } return (Calendar.getInstance().getTimeInMillis() - this.ji.getExecutionDate().getTimeInMillis()) / 1000; }
@Override public Long getRunTimeSeconds() { if (this.ji.getExecutionDate() == null) { DbConn cnx = Helpers.getNewDbSession(); this.ji.setExecutionDate(cnx.runSelectSingle("ji_select_execution_date_by_id", Calendar.class, this.ji.getId())); cnx.close(); } if (this.ji.getExecutionDate() == null) { return 0L; } return (Calendar.getInstance().getTimeInMillis() - this.ji.getExecutionDate().getTimeInMillis()) / 1000; }
@After public void afterTest() { jqmlogger.debug("*** Cleaning after test " + testName.getMethodName()); for (String k : engines.keySet()) { JqmEngineOperations e = engines.get(k); e.stop(); } engines.clear(); for (DbConn cnx : cnxs) { cnx.close(); } cnxs.clear(); // Java 6 GC being rather inefficient, we must run it multiple times to correctly collect Jetty-created class loaders and avoid // permgen issues System.runFinalization(); System.gc(); System.runFinalization(); System.gc(); System.gc(); }
cnx.close();
@Test public void testImportJobdefWithQueue() { // Init the default queue (don't start the engine!) Helpers.updateConfiguration(cnx); XmlJobDefParser.parse("target/payloads/jqm-test-xml/xmltestnewqueue.xml", cnx); cnx.commit(); List<JobDef> jd = JobDef.select(cnx, "jd_select_all"); Assert.assertEquals(2, jd.size()); // Was the queue created (and only once)? Queue q = Queue.select_key(cnx, "NewQueue"); Assert.assertEquals("Created from a jobdef import. Description should be set later", q.getDescription()); cnx.close(); }