/** * Create an History object from a {@link JobInstance}. (if it does not exist, exception). * */ public static void create(DbConn cnx, int launchId, State finalState, Calendar endDate) { JobInstance ji = JobInstance.select_id(cnx, launchId); create(cnx, ji, finalState, endDate); } }
/** * Create an History object from a {@link JobInstance}. (if it does not exist, exception). * */ public static void create(DbConn cnx, int launchId, State finalState, Calendar endDate) { JobInstance ji = JobInstance.select_id(cnx, launchId); create(cnx, ji, finalState, endDate); } }
/** * Part of the endOfRun process that needs the database. May be deferred if the database is not available. */ void endOfRunDb() { DbConn cnx = null; try { cnx = Helpers.getNewDbSession(); // Done: put inside history & remove instance from queue. History.create(cnx, this.ji, this.resultStatus, endDate); jqmlogger.trace("An History was just created for job instance " + this.ji.getId()); cnx.runUpdate("ji_delete_by_id", this.ji.getId()); cnx.commit(); } catch (RuntimeException e) { endBlockDbFailureAnalysis(e); } finally { Helpers.closeQuietly(cnx); } }
/** * Part of the endOfRun process that needs the database. May be deferred if the database is not available. */ void endOfRunDb() { DbConn cnx = null; try { cnx = Helpers.getNewDbSession(); // Done: put inside history & remove instance from queue. History.create(cnx, this.ji, this.resultStatus, endDate); jqmlogger.trace("An History was just created for job instance " + this.ji.getId()); cnx.runUpdate("ji_delete_by_id", this.ji.getId()); cnx.commit(); } catch (RuntimeException e) { endBlockDbFailureAnalysis(e); } finally { Helpers.closeQuietly(cnx); } }
/** * To be called at node startup - it purges all job instances associated to this node. * * @param cnx * @param node */ private void purgeDeadJobInstances(DbConn cnx, Node node) { for (JobInstance ji : JobInstance.select(cnx, "ji_select_by_node", node.getId())) { try { cnx.runSelectSingle("history_select_state_by_id", String.class, ji.getId()); } catch (NoResultException e) { History.create(cnx, ji, State.CRASHED, Calendar.getInstance()); Message.create(cnx, "Job was supposed to be running at server startup - usually means it was killed along a server by an admin or a crash", ji.getId()); } cnx.runUpdate("ji_delete_by_id", ji.getId()); } cnx.commit(); }
History.create(cnx, idJob, State.CANCELLED, null); JobInstance.delete_id(cnx, idJob); cnx.commit();
/** * To be called at node startup - it purges all job instances associated to this node. * * @param cnx * @param node */ private void purgeDeadJobInstances(DbConn cnx, Node node) { for (JobInstance ji : JobInstance.select(cnx, "ji_select_by_node", node.getId())) { try { cnx.runSelectSingle("history_select_state_by_id", String.class, ji.getId()); } catch (NoResultException e) { History.create(cnx, ji, State.CRASHED, Calendar.getInstance()); Message.create(cnx, "Job was supposed to be running at server startup - usually means it was killed along a server by an admin or a crash", ji.getId()); } cnx.runUpdate("ji_delete_by_id", ji.getId()); } cnx.commit(); }