Skip to content

Commit

Permalink
prevent overwriting jobs from other instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxcapades committed Nov 9, 2022
1 parent c67cbb7 commit 4006345
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "org.veupathdb.lib"
version = "1.3.4"
version = "1.3.5"

repositories {
mavenLocal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ object AsyncPlatform {
*
* @throws IllegalArgumentException If the given [queue] value is not a valid
* queue ID/name.
*
* @throws IllegalStateException If the ID of the given job already exists and
* belongs to another instance of this service.
*/
@JvmStatic
fun submitJob(queue: String, job: JobSubmission) {
Expand All @@ -119,6 +122,16 @@ object AsyncPlatform {
if (queue !in JobQueues)
throw IllegalArgumentException("Attempted to submit a job to nonexistent queue '$queue'.")

// Lookup the job to see if it already exists.
getJob(job.jobID)
// If it does exist
?.also {
// And it is not owned by this service instance
if (!it.owned)
// Throw an exception
throw IllegalStateException("Attempted to submit a job that would overwrite an existing job owned by another campus (${job.jobID})")
}

// Record the new job in the database
QueueDB.submitJob(queue, job.jobID, job.config?.toString(), job.inputs.keys)

Expand Down

0 comments on commit 4006345

Please sign in to comment.