From ede5d1f890be127bc3d25859fb64525f25ffde5a Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Mon, 16 Oct 2023 14:19:00 +0200 Subject: [PATCH] (actor) Give process spawners more easily recognizable names. --- .../main/java/nu/marginalia/actor/Actor.java | 14 ++++++------- .../marginalia/actor/ActorControlService.java | 19 +++++++++--------- .../ConverterMonitorActor.java | 3 ++- .../CrawlerMonitorActor.java | 3 ++- .../IndexConstructorMonitorActor.java | 3 ++- .../{monitor => proc}/LoaderMonitorActor.java | 3 ++- .../ProcessLivenessMonitorActor.java | 2 +- .../templates/control/node/node-actors.hdb | 20 +++++++++++++++++++ 8 files changed, 46 insertions(+), 21 deletions(-) rename code/features-control/actors/src/main/java/nu/marginalia/actor/{monitor => proc}/ConverterMonitorActor.java (90%) rename code/features-control/actors/src/main/java/nu/marginalia/actor/{monitor => proc}/CrawlerMonitorActor.java (90%) rename code/features-control/actors/src/main/java/nu/marginalia/actor/{monitor => proc}/IndexConstructorMonitorActor.java (90%) rename code/features-control/actors/src/main/java/nu/marginalia/actor/{monitor => proc}/LoaderMonitorActor.java (89%) rename code/features-control/actors/src/main/java/nu/marginalia/actor/{monitor => proc}/ProcessLivenessMonitorActor.java (99%) diff --git a/code/features-control/actors/src/main/java/nu/marginalia/actor/Actor.java b/code/features-control/actors/src/main/java/nu/marginalia/actor/Actor.java index f5655307..10027f56 100644 --- a/code/features-control/actors/src/main/java/nu/marginalia/actor/Actor.java +++ b/code/features-control/actors/src/main/java/nu/marginalia/actor/Actor.java @@ -4,17 +4,17 @@ public enum Actor { CRAWL, RECRAWL, CONVERT_AND_LOAD, - CONVERTER_MONITOR, - LOADER_MONITOR, - CRAWLER_MONITOR, - MESSAGE_QUEUE_MONITOR, - PROCESS_LIVENESS_MONITOR, - FILE_STORAGE_MONITOR, + PROC_CONVERTER_SPAWNER, + PROC_LOADER_SPAWNER, + PROC_CRAWLER_SPAWNER, + MONITOR_MESSAGE_QUEUE, + MONITOR_PROCESS_LIVENESS, + MONITOR_FILE_STORAGE, ADJACENCY_CALCULATION, CRAWL_JOB_EXTRACTOR, EXPORT_DATA, TRUNCATE_LINK_DATABASE, - INDEX_CONSTRUCTOR_MONITOR, + PROC_INDEX_CONSTRUCTOR_SPAWNER, CONVERT, RESTORE_BACKUP; diff --git a/code/features-control/actors/src/main/java/nu/marginalia/actor/ActorControlService.java b/code/features-control/actors/src/main/java/nu/marginalia/actor/ActorControlService.java index 3c4d7f5a..ef977c74 100644 --- a/code/features-control/actors/src/main/java/nu/marginalia/actor/ActorControlService.java +++ b/code/features-control/actors/src/main/java/nu/marginalia/actor/ActorControlService.java @@ -5,6 +5,7 @@ import com.google.inject.Inject; import com.google.inject.Singleton; import lombok.SneakyThrows; import nu.marginalia.actor.monitor.*; +import nu.marginalia.actor.proc.*; import nu.marginalia.actor.prototype.AbstractActorPrototype; import nu.marginalia.actor.state.ActorStateInstance; import nu.marginalia.actor.task.*; @@ -29,7 +30,6 @@ public class ActorControlService { private final int node; @Inject public ActorControlService(MessageQueueFactory messageQueueFactory, - GsonFactory gsonFactory, BaseServiceParams baseServiceParams, ConvertActor convertActor, ConvertAndLoadActor convertAndLoadActor, @@ -50,7 +50,7 @@ public class ActorControlService { ) { this.messageQueueFactory = messageQueueFactory; this.eventLog = baseServiceParams.eventLog; - this.gson = gsonFactory.get(); + this.gson = GsonFactory.get(); this.node = baseServiceParams.configuration.node(); register(Actor.CRAWL, crawlActor); @@ -59,13 +59,14 @@ public class ActorControlService { register(Actor.RESTORE_BACKUP, restoreBackupActor); register(Actor.CONVERT_AND_LOAD, convertAndLoadActor); - register(Actor.INDEX_CONSTRUCTOR_MONITOR, indexConstructorMonitorActor); - register(Actor.CONVERTER_MONITOR, converterMonitorFSM); - register(Actor.LOADER_MONITOR, loaderMonitor); - register(Actor.CRAWLER_MONITOR, crawlerMonitorActor); - register(Actor.MESSAGE_QUEUE_MONITOR, messageQueueMonitor); - register(Actor.PROCESS_LIVENESS_MONITOR, processMonitorFSM); - register(Actor.FILE_STORAGE_MONITOR, fileStorageMonitorActor); + register(Actor.PROC_INDEX_CONSTRUCTOR_SPAWNER, indexConstructorMonitorActor); + register(Actor.PROC_CONVERTER_SPAWNER, converterMonitorFSM); + register(Actor.PROC_LOADER_SPAWNER, loaderMonitor); + register(Actor.PROC_CRAWLER_SPAWNER, crawlerMonitorActor); + + register(Actor.MONITOR_MESSAGE_QUEUE, messageQueueMonitor); + register(Actor.MONITOR_PROCESS_LIVENESS, processMonitorFSM); + register(Actor.MONITOR_FILE_STORAGE, fileStorageMonitorActor); register(Actor.ADJACENCY_CALCULATION, triggerAdjacencyCalculationActor); register(Actor.CRAWL_JOB_EXTRACTOR, crawlJobExtractorActor); diff --git a/code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/ConverterMonitorActor.java b/code/features-control/actors/src/main/java/nu/marginalia/actor/proc/ConverterMonitorActor.java similarity index 90% rename from code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/ConverterMonitorActor.java rename to code/features-control/actors/src/main/java/nu/marginalia/actor/proc/ConverterMonitorActor.java index f39d21d7..53b73460 100644 --- a/code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/ConverterMonitorActor.java +++ b/code/features-control/actors/src/main/java/nu/marginalia/actor/proc/ConverterMonitorActor.java @@ -1,8 +1,9 @@ -package nu.marginalia.actor.monitor; +package nu.marginalia.actor.proc; import com.google.inject.Inject; import com.google.inject.Singleton; import nu.marginalia.actor.ActorStateFactory; +import nu.marginalia.actor.monitor.AbstractProcessSpawnerActor; import nu.marginalia.control.process.ProcessService; import nu.marginalia.mq.persistence.MqPersistence; import nu.marginalia.mqapi.ProcessInboxNames; diff --git a/code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/CrawlerMonitorActor.java b/code/features-control/actors/src/main/java/nu/marginalia/actor/proc/CrawlerMonitorActor.java similarity index 90% rename from code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/CrawlerMonitorActor.java rename to code/features-control/actors/src/main/java/nu/marginalia/actor/proc/CrawlerMonitorActor.java index c431a25c..0251d74c 100644 --- a/code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/CrawlerMonitorActor.java +++ b/code/features-control/actors/src/main/java/nu/marginalia/actor/proc/CrawlerMonitorActor.java @@ -1,8 +1,9 @@ -package nu.marginalia.actor.monitor; +package nu.marginalia.actor.proc; import com.google.inject.Inject; import com.google.inject.Singleton; import nu.marginalia.actor.ActorStateFactory; +import nu.marginalia.actor.monitor.AbstractProcessSpawnerActor; import nu.marginalia.control.process.ProcessService; import nu.marginalia.mq.persistence.MqPersistence; import nu.marginalia.mqapi.ProcessInboxNames; diff --git a/code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/IndexConstructorMonitorActor.java b/code/features-control/actors/src/main/java/nu/marginalia/actor/proc/IndexConstructorMonitorActor.java similarity index 90% rename from code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/IndexConstructorMonitorActor.java rename to code/features-control/actors/src/main/java/nu/marginalia/actor/proc/IndexConstructorMonitorActor.java index a62a4741..1013fef7 100644 --- a/code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/IndexConstructorMonitorActor.java +++ b/code/features-control/actors/src/main/java/nu/marginalia/actor/proc/IndexConstructorMonitorActor.java @@ -1,8 +1,9 @@ -package nu.marginalia.actor.monitor; +package nu.marginalia.actor.proc; import com.google.inject.Inject; import com.google.inject.Singleton; import nu.marginalia.actor.ActorStateFactory; +import nu.marginalia.actor.monitor.AbstractProcessSpawnerActor; import nu.marginalia.control.process.ProcessService; import nu.marginalia.mq.persistence.MqPersistence; import nu.marginalia.mqapi.ProcessInboxNames; diff --git a/code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/LoaderMonitorActor.java b/code/features-control/actors/src/main/java/nu/marginalia/actor/proc/LoaderMonitorActor.java similarity index 89% rename from code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/LoaderMonitorActor.java rename to code/features-control/actors/src/main/java/nu/marginalia/actor/proc/LoaderMonitorActor.java index 2c34e6dd..69f88542 100644 --- a/code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/LoaderMonitorActor.java +++ b/code/features-control/actors/src/main/java/nu/marginalia/actor/proc/LoaderMonitorActor.java @@ -1,8 +1,9 @@ -package nu.marginalia.actor.monitor; +package nu.marginalia.actor.proc; import com.google.inject.Inject; import com.google.inject.Singleton; import nu.marginalia.actor.ActorStateFactory; +import nu.marginalia.actor.monitor.AbstractProcessSpawnerActor; import nu.marginalia.control.process.ProcessService; import nu.marginalia.mq.persistence.MqPersistence; import nu.marginalia.mqapi.ProcessInboxNames; diff --git a/code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/ProcessLivenessMonitorActor.java b/code/features-control/actors/src/main/java/nu/marginalia/actor/proc/ProcessLivenessMonitorActor.java similarity index 99% rename from code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/ProcessLivenessMonitorActor.java rename to code/features-control/actors/src/main/java/nu/marginalia/actor/proc/ProcessLivenessMonitorActor.java index 85fe463b..bd29a335 100644 --- a/code/features-control/actors/src/main/java/nu/marginalia/actor/monitor/ProcessLivenessMonitorActor.java +++ b/code/features-control/actors/src/main/java/nu/marginalia/actor/proc/ProcessLivenessMonitorActor.java @@ -1,4 +1,4 @@ -package nu.marginalia.actor.monitor; +package nu.marginalia.actor.proc; import com.google.inject.Inject; import com.google.inject.Singleton; diff --git a/code/services-core/control-service/src/main/resources/templates/control/node/node-actors.hdb b/code/services-core/control-service/src/main/resources/templates/control/node/node-actors.hdb index ca857189..93f754cc 100644 --- a/code/services-core/control-service/src/main/resources/templates/control/node/node-actors.hdb +++ b/code/services-core/control-service/src/main/resources/templates/control/node/node-actors.hdb @@ -37,6 +37,26 @@ {{> control/partials/actors-table }} +
+

Actors

+

+ Actors are programs that primarily run within the executor services that keep their state on the + message queue. +

+

Monitors

+ MONITOR_ actors perform maintenance duties, clean up stale events and heartbeats, + that sort of thing, typically waking up once a minute or so to perform some task. +

Process Spawners

+ PROC_..._SPAWNER actors launch and observe independent processes, such as the crawler or loader. + They eavesdrop on the message queue for message to their corresponding process, and when such a message is detected, + the process is launched. Turning off these actors will terminate the associated process and set their instructions + messages to status dead, ensuring they will not re-spawn automatically. +

Programs

+ There are other actors that act to orchestrate processing flows in the system. They enable long-running tasks + such as crawling to survive a system shutdown or some form of error. +

+ +