Reduced logging and replaced with controller
This commit is contained in:
parent
880285e238
commit
27f45ded91
@ -0,0 +1,18 @@
|
|||||||
|
package no.iktdev.mediaprocessing.coordinator.controller
|
||||||
|
|
||||||
|
import no.iktdev.mediaprocessing.coordinator.Coordinator
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
|
import org.springframework.stereotype.Controller
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(path = ["/polls"])
|
||||||
|
class PollController(@Autowired var coordinator: Coordinator) {
|
||||||
|
|
||||||
|
@GetMapping()
|
||||||
|
fun polls(): String {
|
||||||
|
val stat = coordinator.getActivePolls()
|
||||||
|
return "Active Polls ${stat.active}/${stat.total}"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -45,21 +45,23 @@ abstract class EventCoordinator<T : EventImpl, E : EventsManagerImpl<T>> {
|
|||||||
|
|
||||||
abstract fun getActiveTaskMode(): ActiveMode
|
abstract fun getActiveTaskMode(): ActiveMode
|
||||||
|
|
||||||
|
private var activePolls: Int = 0
|
||||||
|
data class PollStats(val active: Int, val total: Int)
|
||||||
|
fun getActivePolls(): PollStats {
|
||||||
|
return PollStats(active = activePolls, total = referencePool.values.size)
|
||||||
|
}
|
||||||
|
|
||||||
private fun onEventGroupsReceived(eventGroup: List<List<T>>) {
|
private fun onEventGroupsReceived(eventGroup: List<List<T>>) {
|
||||||
val egRefIds = eventGroup.map { it.first().referenceId() }
|
val egRefIds = eventGroup.map { it.first().referenceId() }
|
||||||
val orphanedReferences = referencePool.filter { !it.value.isActive }.filter { id -> id.key !in egRefIds }.map { it.key }
|
val orphanedReferences = referencePool.filter { !it.value.isActive }.filter { id -> id.key !in egRefIds }.map { it.key }
|
||||||
orphanedReferences.forEach { id -> referencePool.remove(id) }
|
orphanedReferences.forEach { id -> referencePool.remove(id) }
|
||||||
|
|
||||||
val activePolls = referencePool.values.filter { it.isActive }.size
|
activePolls = referencePool.values.filter { it.isActive }.size
|
||||||
if (orphanedReferences.isNotEmpty() && referencePool.isEmpty()) {
|
if (orphanedReferences.isNotEmpty() && referencePool.isEmpty()) {
|
||||||
log.info { "Last active references removed from pull pool, " }
|
log.info { "Last active references removed from pull pool, " }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventGroup.isNotEmpty()) {
|
if (eventGroup.isEmpty()) {
|
||||||
log.info { "Active polls $activePolls/${referencePool.values.size}" }
|
|
||||||
} else {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user