@Override public List<JobInstance> poll(DbConn cnx, Queue queue, int headSize) { return JobInstance.select(cnx, "ji_select_poll", queue.getId(), headSize); } }
@Override public List<JobInstance> poll(DbConn cnx, Queue queue, int headSize) { return JobInstance.select(cnx, "ji_select_poll", queue.getId(), headSize); } }
@Override public List<JobInstance> poll(DbConn cnx, Queue queue, int headSize) { return JobInstance.select(cnx, "ji_select_poll", queue.getId(), headSize); } }
@Override public List<JobInstance> poll(DbConn cnx, Queue queue, int headSize) { return JobInstance.select(cnx, "ji_select_poll", queue.getId(), headSize); } }
@Override public List<JobInstance> poll(DbConn cnx, Queue queue, int headSize) { return JobInstance.select(cnx, "ji_select_poll", queue.getId(), headSize); } }
@Override public List<JobInstance> poll(DbConn cnx, Queue queue, int headSize) { return JobInstance.select(cnx, "ji_select_poll", queue.getId(), headSize); } }
public static JobInstance select_id(DbConn cnx, int id) { List<JobInstance> res = select(cnx, "ji_select_by_id", id); if (res.isEmpty()) { throw new DatabaseException("no result for query by ID for ID " + id); } if (res.size() > 1) { throw new DatabaseException("Inconsistent database! Multiple results for query by ID for ID " + id); } return res.get(0); }
/** * The polling method. Creating "queues" on the different databases can be extremely different in the different supported RDBMS, so this * method allows to fully change the polling method. <br> * <br> * Default implementation uses the ji_select_poll SQL template query and does retrieve the whole queue without using headSize, so is a * performance waste. * * @param cnx * a session without active TX. * @param queue * the queue being polled * @param headSize * upper estimate of how many slots are available - i.e. max JI which can be taken from the queue. * @return a list of JI, or an empty list. Never null. */ public List<JobInstance> poll(DbConn cnx, Queue queue, int headSize) { return JobInstance.select(cnx, "ji_select_poll", queue.getId()); } }
/** * The polling method. Creating "queues" on the different databases can be extremely different in the different supported RDBMS, so this * method allows to fully change the polling method. <br> * <br> * Default implementation uses the ji_select_poll SQL template query and does retrieve the whole queue without using headSize, so is a * performance waste. * * @param cnx * a session without active TX. * @param queue * the queue being polled * @param headSize * upper estimate of how many slots are available - i.e. max JI which can be taken from the queue. * @return a list of JI, or an empty list. Never null. */ public List<JobInstance> poll(DbConn cnx, Queue queue, int headSize) { return JobInstance.select(cnx, "ji_select_poll", queue.getId()); } }
public static JobInstance select_id(DbConn cnx, int id) { List<JobInstance> res = select(cnx, "ji_select_by_id", id); if (res.isEmpty()) { throw new DatabaseException("no result for query by ID for ID " + id); } if (res.size() > 1) { throw new DatabaseException("Inconsistent database! Multiple results for query by ID for ID " + id); } return res.get(0); }
List<JobInstance> currentJobs = JobInstance.select(cnx, "ji_select_by_queue", queue_id); if (currentJobs.isEmpty())
/** * 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(); }
/** * 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(); }