Test
This commit is contained in:
parent
ac2baa5787
commit
066781edb9
@ -41,10 +41,10 @@ class InputDirectoryWatcher(@Autowired var coordinator: Coordinator): FileWatche
|
||||
private val logger = KotlinLogging.logger {}
|
||||
val watcherChannel = SharedConfig.incomingContent.asWatchChannel()
|
||||
val queue = FileWatcherQueue()
|
||||
val io = Coroutines.io()
|
||||
final val io = Coroutines.io()
|
||||
|
||||
init {
|
||||
io.launch {
|
||||
suspend fun startWatcher() {
|
||||
log.info { "Starting Watcher" }
|
||||
watcherChannel.consumeEach {
|
||||
if (it.file == SharedConfig.incomingContent) {
|
||||
logger.info { "IO Watcher ${it.kind} on ${it.file.absolutePath}" }
|
||||
@ -66,7 +66,16 @@ class InputDirectoryWatcher(@Autowired var coordinator: Coordinator): FileWatche
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
log.info { "Reached end of watcherChannel" }
|
||||
}
|
||||
|
||||
final fun runCoroutine() {
|
||||
io.launch { startWatcher() }
|
||||
.invokeOnCompletion { runCoroutine() }
|
||||
}
|
||||
|
||||
init {
|
||||
runCoroutine()
|
||||
}
|
||||
|
||||
private fun addFile(file: File): Boolean {
|
||||
|
||||
@ -85,7 +85,7 @@ class Coordinator(): CoordinatorBase<PersistentProcessDataMessage, PersistentEve
|
||||
}
|
||||
}
|
||||
|
||||
fun readAllAvailableInQueue() {
|
||||
private fun readAllAvailableInQueue() {
|
||||
val messages = eventManager.getProcessEventsClaimable()
|
||||
io.launch {
|
||||
messages.forEach {
|
||||
@ -117,7 +117,16 @@ class Coordinator(): CoordinatorBase<PersistentProcessDataMessage, PersistentEve
|
||||
|
||||
}
|
||||
|
||||
fun readAllMessagesFor(referenceId: String, eventId: String) {
|
||||
/**
|
||||
* If we get double events at the same time, this would be the case
|
||||
*/
|
||||
fun readNextAvailableMessageWithEvent(kafkaEvents: KafkaEvents) {
|
||||
val messages = eventManager.getProcessEventsClaimable().firstOrNull { it.event == kafkaEvents }?.let {
|
||||
readAllMessagesFor(referenceId = it.referenceId, eventId = it.eventId)
|
||||
}
|
||||
}
|
||||
|
||||
private fun readAllMessagesFor(referenceId: String, eventId: String) {
|
||||
val messages = eventManager.getProcessEventsClaimable()
|
||||
createTasksBasedOnEventsAndPersistence(referenceId, eventId, messages)
|
||||
}
|
||||
|
||||
@ -16,6 +16,10 @@ class ClaimsService() {
|
||||
@Autowired
|
||||
lateinit var coordinator: Coordinator
|
||||
|
||||
|
||||
/**
|
||||
* If this serivce calls for readback all on the coordinator, it will cause a full on crash, as it
|
||||
*/
|
||||
@Scheduled(fixedDelay = (300_000))
|
||||
fun validateClaims() {
|
||||
val expiredClaims = eventManager.getProcessEventsWithExpiredClaim()
|
||||
@ -31,9 +35,9 @@ class ClaimsService() {
|
||||
}
|
||||
it
|
||||
}
|
||||
released.forEach {
|
||||
/*released.forEach {
|
||||
log.info { "Sending released ${it.referenceId} ${it.event} into queue" }
|
||||
coordinator.readAllMessagesFor(it.referenceId, it.eventId)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@ -209,6 +209,7 @@ class EncodeService(@Autowired override var coordinator: Coordinator, @Autowired
|
||||
|
||||
fun clearWorker() {
|
||||
this.runner = null
|
||||
coordinator.readNextAvailableMessageWithEvent(KafkaEvents.EventWorkEncodeCreated)
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
|
||||
@ -188,6 +188,7 @@ class ExtractService(@Autowired override var coordinator: Coordinator, @Autowire
|
||||
|
||||
fun clearWorker() {
|
||||
this.runner = null
|
||||
coordinator.readNextAvailableMessageWithEvent(KafkaEvents.EventWorkExtractCreated)
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
|
||||
Loading…
Reference in New Issue
Block a user