This commit is contained in:
bskjon 2024-07-19 00:16:01 +02:00
parent a74e39ed1e
commit 4a47823b09
3 changed files with 31 additions and 40 deletions

50
.idea/workspace.xml generated
View File

@ -34,10 +34,9 @@
</loaded-modules> </loaded-modules>
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="83cd22eb-7f21-4585-9fdf-9cf3ac59698d" name="Changes" comment="v3 25"> <list default="true" id="83cd22eb-7f21-4585-9fdf-9cf3ac59698d" name="Changes" comment="v3 26">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/apps/coordinator/src/main/kotlin/no/iktdev/mediaprocessing/coordinator/EventsManager.kt" beforeDir="false" afterPath="$PROJECT_DIR$/apps/coordinator/src/main/kotlin/no/iktdev/mediaprocessing/coordinator/EventsManager.kt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/apps/coordinator/src/main/kotlin/no/iktdev/mediaprocessing/coordinator/CoordinatorEventCoordinator.kt" beforeDir="false" afterPath="$PROJECT_DIR$/apps/coordinator/src/main/kotlin/no/iktdev/mediaprocessing/coordinator/CoordinatorEventCoordinator.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/apps/coordinator/src/main/kotlin/no/iktdev/mediaprocessing/coordinator/tasksV2/listeners/CoverFromMetadataTaskListener.kt" beforeDir="false" afterPath="$PROJECT_DIR$/apps/coordinator/src/main/kotlin/no/iktdev/mediaprocessing/coordinator/tasksV2/listeners/CoverFromMetadataTaskListener.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/shared/eventi/src/main/kotlin/no/iktdev/eventi/implementations/EventCoordinator.kt" beforeDir="false" afterPath="$PROJECT_DIR$/shared/eventi/src/main/kotlin/no/iktdev/eventi/implementations/EventCoordinator.kt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/shared/eventi/src/main/kotlin/no/iktdev/eventi/implementations/EventCoordinator.kt" beforeDir="false" afterPath="$PROJECT_DIR$/shared/eventi/src/main/kotlin/no/iktdev/eventi/implementations/EventCoordinator.kt" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -200,7 +199,7 @@
"JUnit.All in MediaProcessing.executor": "Run", "JUnit.All in MediaProcessing.executor": "Run",
"Kotlin.ConverterApplicationKt.executor": "Run", "Kotlin.ConverterApplicationKt.executor": "Run",
"Kotlin.CoordinatorApplicationKt.executor": "Run", "Kotlin.CoordinatorApplicationKt.executor": "Run",
"Kotlin.Env - CoordinatorApplicationKt.executor": "Debug", "Kotlin.Env - CoordinatorApplicationKt.executor": "Run",
"Kotlin.EventiApplicationKt.executor": "Run", "Kotlin.EventiApplicationKt.executor": "Run",
"Kotlin.ProcesserApplicationKt.executor": "Run", "Kotlin.ProcesserApplicationKt.executor": "Run",
"Kotlin.UIApplicationKt.executor": "Run", "Kotlin.UIApplicationKt.executor": "Run",
@ -382,6 +381,7 @@
<env name="METADATA_TIMEOUT" value="0" /> <env name="METADATA_TIMEOUT" value="0" />
<env name="SUPPORTING_EXECUTABLE_FFMPEG" value="G:\MediaProcessingPlayground\ffmpeg.exe" /> <env name="SUPPORTING_EXECUTABLE_FFMPEG" value="G:\MediaProcessingPlayground\ffmpeg.exe" />
<env name="SUPPORTING_EXECUTABLE_FFPROBE" value="G:\MediaProcessingPlayground\ffprobe.exe" /> <env name="SUPPORTING_EXECUTABLE_FFPROBE" value="G:\MediaProcessingPlayground\ffprobe.exe" />
<env name="DISABLE_PRODUCE" value="true" />
</envs> </envs>
<option name="MAIN_CLASS_NAME" value="no.iktdev.mediaprocessing.coordinator.CoordinatorApplicationKt" /> <option name="MAIN_CLASS_NAME" value="no.iktdev.mediaprocessing.coordinator.CoordinatorApplicationKt" />
<module name="MediaProcessing.apps.coordinator.main" /> <module name="MediaProcessing.apps.coordinator.main" />
@ -417,13 +417,6 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1712771068889</updated> <updated>1712771068889</updated>
</task> </task>
<task id="LOCAL00141" summary="Fix">
<option name="closed" value="true" />
<created>1719738757568</created>
<option name="number" value="LOCAL00141" />
<option name="presentableId" value="LOCAL00141" />
<updated>1719738757569</updated>
</task>
<task id="LOCAL00142" summary="Fix"> <task id="LOCAL00142" summary="Fix">
<option name="closed" value="true" /> <option name="closed" value="true" />
<created>1719739977381</created> <created>1719739977381</created>
@ -760,7 +753,14 @@
<option name="presentableId" value="LOCAL00189" /> <option name="presentableId" value="LOCAL00189" />
<updated>1721329940691</updated> <updated>1721329940691</updated>
</task> </task>
<option name="localTasksCounter" value="190" /> <task id="LOCAL00190" summary="v3 26">
<option name="closed" value="true" />
<created>1721338554955</created>
<option name="number" value="LOCAL00190" />
<option name="presentableId" value="LOCAL00190" />
<updated>1721338554955</updated>
</task>
<option name="localTasksCounter" value="191" />
<servers /> <servers />
</component> </component>
<component name="UnloadedModulesList"> <component name="UnloadedModulesList">
@ -780,7 +780,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="v3" />
<MESSAGE value="v3 2" /> <MESSAGE value="v3 2" />
<MESSAGE value="v3 3" /> <MESSAGE value="v3 3" />
<MESSAGE value="v3 4" /> <MESSAGE value="v3 4" />
@ -805,7 +804,8 @@
<MESSAGE value="v3 23" /> <MESSAGE value="v3 23" />
<MESSAGE value="v3 24" /> <MESSAGE value="v3 24" />
<MESSAGE value="v3 25" /> <MESSAGE value="v3 25" />
<option name="LAST_COMMIT_MESSAGE" value="v3 25" /> <MESSAGE value="v3 26" />
<option name="LAST_COMMIT_MESSAGE" value="v3 26" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
@ -1109,27 +1109,7 @@
<option name="timeStamp" value="353" /> <option name="timeStamp" value="353" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="kotlin-line"> <line-breakpoint enabled="true" type="kotlin-line">
<url>file://$PROJECT_DIR$/shared/eventi/src/main/kotlin/no/iktdev/eventi/implementations/EventCoordinator.kt</url> <condition expression="incomingEvent.referenceId() == &quot;add9da6f-44a1-4ed2-99cd-cb23ce1800c0&quot; &amp;&amp; incomingEvent.eventId() == &quot;f5c5e2cc-f502-4ecc-af57-d1f1b5994983&quot;" language="kotlin" custom="import no.iktdev.eventi.data.eventId,import no.iktdev.eventi.data.referenceId" />
<line>47</line>
<properties>
<option name="lambda-ordinal" value="-1" />
</properties>
<option name="timeStamp" value="356" />
</line-breakpoint>
<line-breakpoint enabled="true" type="kotlin-line">
<url>file://$PROJECT_DIR$/shared/eventi/src/main/kotlin/no/iktdev/eventi/implementations/EventCoordinator.kt</url>
<line>64</line>
<properties>
<option name="lambda-ordinal" value="-1" />
</properties>
<option name="timeStamp" value="358" />
</line-breakpoint>
<line-breakpoint enabled="true" type="kotlin-line">
<url>file://$PROJECT_DIR$/shared/eventi/src/main/kotlin/no/iktdev/eventi/implementations/EventCoordinator.kt</url>
<line>54</line>
<option name="timeStamp" value="359" />
</line-breakpoint>
<line-breakpoint enabled="true" type="kotlin-line">
<url>file://$PROJECT_DIR$/apps/coordinator/src/main/kotlin/no/iktdev/mediaprocessing/coordinator/tasksV2/listeners/CoverFromMetadataTaskListener.kt</url> <url>file://$PROJECT_DIR$/apps/coordinator/src/main/kotlin/no/iktdev/mediaprocessing/coordinator/tasksV2/listeners/CoverFromMetadataTaskListener.kt</url>
<line>35</line> <line>35</line>
<option name="timeStamp" value="360" /> <option name="timeStamp" value="360" />

View File

@ -27,7 +27,6 @@ class Coordinator(
) : EventCoordinator<Event, EventsManager>() { ) : EventCoordinator<Event, EventsManager>() {
init { init {
pullDelay.set(100)
} }
public fun startProcess(file: File, type: ProcessType) { public fun startProcess(file: File, type: ProcessType) {

View File

@ -14,7 +14,7 @@ abstract class EventCoordinator<T : EventImpl, E : EventsManagerImpl<T>> {
abstract var applicationContext: ApplicationContext abstract var applicationContext: ApplicationContext
abstract var eventManager: E abstract var eventManager: E
val pullDelay: AtomicLong = AtomicLong(5000) val pullDelay: AtomicLong = AtomicLong(1000)
//private val listeners: MutableList<EventListener<T>> = mutableListOf() //private val listeners: MutableList<EventListener<T>> = mutableListOf()
@ -86,10 +86,17 @@ abstract class EventCoordinator<T : EventImpl, E : EventsManagerImpl<T>> {
log.debug { "New pull on database" } log.debug { "New pull on database" }
val events = eventManager.readAvailableEvents() val events = eventManager.readAvailableEvents()
onEventGroupsReceived(events) onEventGroupsReceived(events)
if (events.isNotEmpty()) {
pullDelay.set(500)
} else {
pullDelay.set(2500)
}
referencePool.values.awaitAll()
} }
waitForConditionOrTimeout(pullDelay.get()) { newEventProduced }.also { waitForConditionOrTimeout(pullDelay.get()) {
newEventProduced = false newEventProduced
} }
newEventProduced = false
} }
} }
} }
@ -114,11 +121,16 @@ abstract class EventCoordinator<T : EventImpl, E : EventsManagerImpl<T>> {
return eventListeners return eventListeners
} }
var doNotProduce = System.getenv("DISABLE_PRODUCE").toBoolean() ?: false
/** /**
* @return true if its stored * @return true if its stored
*/ */
fun produceNewEvent(event: T): Boolean { fun produceNewEvent(event: T): Boolean {
if (doNotProduce) {
newEventProduced = true
return true
}
val isStored = eventManager.storeEvent(event) val isStored = eventManager.storeEvent(event)
if (isStored) { if (isStored) {
log.info { "Stored event: ${event.eventType}" } log.info { "Stored event: ${event.eventType}" }