Skip to content

Commit ee13d17

Browse files
Vincent PrinsVincent Prins
authored andcommitted
GET Number of active jobs
1 parent c1072c6 commit ee13d17

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

client/src/components/modals/jobs/JobModal.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
<template v-else>
3131
<p class="centerText" v-if="job.progress.untagged > 0">
3232
<template v-if="jobIndication != null">
33-
GaLAHaD is currently processing <b>{{ jobIndication }}</b> {{ jobIndication == 1 ? 'document' :
34-
'documents' }}
33+
GaLAHaD is currently processing <b>{{ jobIndication }}</b> {{ jobIndication == 1 ? 'job' :
34+
'jobs' }}
3535
</template>
3636
<template v-else>
3737
Calculating current server load...

server/src/main/kotlin/org/ivdnt/galahad/jobs/JobController.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import kotlin.io.path.createTempFile
2424
object JobController {
2525
private val queue: ArrayDeque<Job> = ArrayDeque<Job>()
2626
private var task: Task? = null
27+
val queueSize: Int get() = queue.size
2728

2829
fun queue(job: Job) {
2930
if (job.name == SOURCE_LAYER_NAME) throw SourceLayerNotATaggerException()
@@ -48,6 +49,7 @@ object JobController {
4849
queue -= task!!.job
4950
}
5051
// next document, or next job if all documents are tagged
52+
task = null
5153
start()
5254
}
5355

server/src/main/kotlin/org/ivdnt/galahad/web/controller/JobsController.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import jakarta.servlet.http.HttpServletResponse
1111
import org.ivdnt.galahad.annotations.Layer
1212
import org.ivdnt.galahad.app.JOBS_URL
1313
import org.ivdnt.galahad.app.JOB_URL
14+
import org.ivdnt.galahad.app.TAGGERS_URL
1415
import org.ivdnt.galahad.app.User
1516
import org.ivdnt.galahad.exceptions.ErrorResponse
17+
import org.ivdnt.galahad.jobs.JobController
1618
import org.ivdnt.galahad.jobs.JobMetadata
1719
import org.ivdnt.galahad.jobs.Jobs
1820
import org.ivdnt.galahad.jobs.Progress
@@ -185,4 +187,12 @@ class JobsController(
185187
@PathVariable @Parameter(description = "Corpus UUID") corpus: UUID,
186188
@PathVariable @Parameter(description = "Tagger name") job: String,
187189
): Progress = corpus.readJobs().readOrThrow(job).progress
190+
191+
@Operation(
192+
summary = "Number of active tagger jobs",
193+
description = "Get the number of active jobs. Indicates server load."
194+
)
195+
@CrossOrigin
196+
@GetMapping("$TAGGERS_URL/active")
197+
fun activeJobs(): Int = JobController.queueSize
188198
}

server/src/main/kotlin/org/ivdnt/galahad/web/controller/TaggersController.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,4 @@ class TaggersController(
6666
@GetMapping(TAGGER_HEALTH_URL)
6767
fun getTaggerHealth(@PathVariable @Parameter(description = "Tagger name") tagger: String): TaggerHealth =
6868
taggersService.taggerHealth(tagger)
69-
70-
@Operation(
71-
summary = "Number of active document jobs",
72-
description = "Get the number of documents actively being tagged, cumulative over all taggers. Indicates server load."
73-
)
74-
@CrossOrigin
75-
@GetMapping("$TAGGERS_URL/active")
76-
fun getActiveDocsAtTaggers(): Int = taggersService.numActiveDocuments()
7769
}

0 commit comments

Comments
 (0)