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..94ff32e625 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 legacyCloudWorkersSubmissionsForProcessing = 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: + legacyCloudWorkerTypesList.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, + legacyCloudWorkersSubmissionsForProcessing, + sharedLockObject, + formatterServiceFactory, + remoteSubmissionsFilteringService, + legacyCloudWorkerTypesList)); + workerThreads .ToList() .ForEach(workerThread =>