-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from VEuPathDB/broken-job-list
List failed jobs
- Loading branch information
Showing
4 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...in/kotlin/org/veupathdb/lib/compute/platform/intern/db/queries/select/list-failed-jobs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.veupathdb.lib.compute.platform.intern.db.queries.select | ||
|
||
import org.veupathdb.lib.compute.platform.intern.db.model.JobRecord | ||
import org.veupathdb.lib.compute.platform.intern.db.util.stream | ||
import java.sql.Connection | ||
import java.sql.ResultSet | ||
import java.util.stream.Stream | ||
|
||
private const val SQL = """ | ||
SELECT | ||
job_id | ||
, status | ||
, queue | ||
, config | ||
, input_files | ||
, created | ||
, last_accessed | ||
, grabbed | ||
, finished | ||
FROM | ||
compute.jobs | ||
WHERE | ||
status = 'failed' | ||
ORDER BY | ||
created ASC | ||
""" | ||
|
||
/** | ||
* Fetches a stream over all the jobs in the database currently in the | ||
* `failed` status, ordered by job creation date ascending. | ||
* | ||
* The returned stream wraps the live database [ResultSet] and **MUST** be | ||
* closed when the caller is done with it. | ||
* | ||
* @param con Open database connection that will be used to execute the query. | ||
* | ||
* @return A stream over the `in-progress` jobs in the database. | ||
* | ||
* **WARNING**: The returned stream **MUST** be closed on completion to avoid DB | ||
* connection leaks. | ||
*/ | ||
internal fun ListFailedJobs(con: Connection): Stream<JobRecord> { | ||
// Nothing is closed in this method as the caller is responsible for closing | ||
// the returned stream (which will close the connection, statement, and | ||
// result-set) | ||
return con.createStatement().executeQuery(SQL).stream().map(ResultSet::toJobRow) | ||
} |