From 10e7899e42914cbcf951c2229bc941b9c0734b9f Mon Sep 17 00:00:00 2001 From: Georgi Georgiev Date: Wed, 14 Feb 2024 16:26:33 +0200 Subject: [PATCH 1/3] Added new worker type for cloud legacy workers --- OJS.Workers.Common/Models/WorkerType.cs | 5 +++++ OJS.Workers.Common/Settings.cs | 5 +++++ OJS.Workers/LocalWorkerServiceBase.cs | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/OJS.Workers.Common/Models/WorkerType.cs b/OJS.Workers.Common/Models/WorkerType.cs index a72dec2a2a..bf7a234a26 100644 --- a/OJS.Workers.Common/Models/WorkerType.cs +++ b/OJS.Workers.Common/Models/WorkerType.cs @@ -1,10 +1,15 @@ namespace OJS.Workers.Common.Models { + /// + /// Subset of workers on which a submission is to be executed. + /// Stored in database, so be careful with changing values. + /// public enum WorkerType { Default = 0, Legacy = 1, Local = 2, Alpha = 3, + LegacyCloud = 4, } } \ No newline at end of file diff --git a/OJS.Workers.Common/Settings.cs b/OJS.Workers.Common/Settings.cs index 10ade3264f..970927dda5 100644 --- a/OJS.Workers.Common/Settings.cs +++ b/OJS.Workers.Common/Settings.cs @@ -240,6 +240,11 @@ public static class Settings .Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => x.Trim()); + public static IEnumerable LegacyCloudWorkerEndpoints => SettingsHelper.GetSetting("LegacyCloudWorkerEndpoints") + .Split(';') + .Where(x => !string.IsNullOrWhiteSpace(x)) + .Select(x => x.Trim()); + public static string PostgreSqlMasterDbConnectionString => SettingsHelper.GetSetting("PostgreSqlMasterDbConnectionString"); diff --git a/OJS.Workers/LocalWorkerServiceBase.cs b/OJS.Workers/LocalWorkerServiceBase.cs index c2d26286e0..ef6d1c6edb 100644 --- a/OJS.Workers/LocalWorkerServiceBase.cs +++ b/OJS.Workers/LocalWorkerServiceBase.cs @@ -88,11 +88,13 @@ private void SpawnSubmissionProcessorsAndThreads() var localWorkerSubmissionsForProcessing = new ConcurrentQueue(); var legacyWorkersSubmissionsForProcessing = new ConcurrentQueue(); var alphaWorkersSubmissionsForProcessing = new ConcurrentQueue(); + var legaxyCloudWorkersSubmissionsForProcessing = new ConcurrentQueue(); var sharedLockObject = new object(); var legacyWorkerTypesList = new List { WorkerType.Legacy }; var alphaWorkerTypesList = new List { WorkerType.Alpha }; var localWorkerTypesList = new List { WorkerType.Local }; + var legacyCloudWorkerTypesList = new List { WorkerType.LegacyCloud }; var isEnumParsed = Enum.TryParse(Settings.DefaultWorkerType, false, out WorkerType defaultWorkerType); if (!isEnumParsed) @@ -112,6 +114,9 @@ private void SpawnSubmissionProcessorsAndThreads() case WorkerType.Local: localWorkerTypesList.Add(WorkerType.Default); break; + case WorkerType.LegacyCloud: + localWorkerTypesList.Add(WorkerType.Default); + break; default: this.Logger.Fatal("Wrong default worker type"); throw new InvalidOperationException(); @@ -133,7 +138,8 @@ private void SpawnSubmissionProcessorsAndThreads() workerThreads.AddRange(this.GetRemoteWorkers( Settings.RemoteWorkerEndpoints, legacyWorkersSubmissionsForProcessing, - sharedLockObject, formatterServiceFactory, + sharedLockObject, + formatterServiceFactory, remoteSubmissionsFilteringService, legacyWorkerTypesList)); @@ -145,6 +151,14 @@ private void SpawnSubmissionProcessorsAndThreads() remoteSubmissionsFilteringService, alphaWorkerTypesList)); + workerThreads.AddRange(this.GetRemoteWorkers( + Settings.LegacyCloudWorkerEndpoints, + legacyWorkersSubmissionsForProcessing, + sharedLockObject, + formatterServiceFactory, + remoteSubmissionsFilteringService, + legacyCloudWorkerTypesList)); + workerThreads .ToList() .ForEach(workerThread => From abb57d426a52a363ae035024dd882ff6d1504226 Mon Sep 17 00:00:00 2001 From: Georgi Georgiev Date: Wed, 14 Feb 2024 16:39:42 +0200 Subject: [PATCH 2/3] Fixed bug --- OJS.Workers/LocalWorkerServiceBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OJS.Workers/LocalWorkerServiceBase.cs b/OJS.Workers/LocalWorkerServiceBase.cs index ef6d1c6edb..008d34e68b 100644 --- a/OJS.Workers/LocalWorkerServiceBase.cs +++ b/OJS.Workers/LocalWorkerServiceBase.cs @@ -88,7 +88,7 @@ private void SpawnSubmissionProcessorsAndThreads() var localWorkerSubmissionsForProcessing = new ConcurrentQueue(); var legacyWorkersSubmissionsForProcessing = new ConcurrentQueue(); var alphaWorkersSubmissionsForProcessing = new ConcurrentQueue(); - var legaxyCloudWorkersSubmissionsForProcessing = new ConcurrentQueue(); + var legacyCloudWorkersSubmissionsForProcessing = new ConcurrentQueue(); var sharedLockObject = new object(); var legacyWorkerTypesList = new List { WorkerType.Legacy }; @@ -153,7 +153,7 @@ private void SpawnSubmissionProcessorsAndThreads() workerThreads.AddRange(this.GetRemoteWorkers( Settings.LegacyCloudWorkerEndpoints, - legacyWorkersSubmissionsForProcessing, + legacyCloudWorkersSubmissionsForProcessing, sharedLockObject, formatterServiceFactory, remoteSubmissionsFilteringService, From bd450d0d65e045a8543b3929e2f44b5406235368 Mon Sep 17 00:00:00 2001 From: Georgi Georgiev Date: Mon, 11 Mar 2024 10:29:32 +0200 Subject: [PATCH 3/3] Fixed bug with Default worker type --- OJS.Workers/LocalWorkerServiceBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OJS.Workers/LocalWorkerServiceBase.cs b/OJS.Workers/LocalWorkerServiceBase.cs index 008d34e68b..94ff32e625 100644 --- a/OJS.Workers/LocalWorkerServiceBase.cs +++ b/OJS.Workers/LocalWorkerServiceBase.cs @@ -115,7 +115,7 @@ private void SpawnSubmissionProcessorsAndThreads() localWorkerTypesList.Add(WorkerType.Default); break; case WorkerType.LegacyCloud: - localWorkerTypesList.Add(WorkerType.Default); + legacyCloudWorkerTypesList.Add(WorkerType.Default); break; default: this.Logger.Fatal("Wrong default worker type");