diff --git a/server/AyaNova/biz/JobsBiz.cs b/server/AyaNova/biz/JobsBiz.cs index b723b42d..01f2d1a7 100644 --- a/server/AyaNova/biz/JobsBiz.cs +++ b/server/AyaNova/biz/JobsBiz.cs @@ -254,8 +254,6 @@ namespace AyaNova.Biz ActivelyProcessing = true; try { - - //Sweep jobs table System.Diagnostics.Debug.WriteLine($"JobsBiz processing sweeper"); await CoreJobSweeper.DoSweepAsync();//run exclusively @@ -270,6 +268,8 @@ namespace AyaNova.Biz { System.Diagnostics.Debug.WriteLine($"JobsBiz processing exclusive biz job {j.Name}"); await ProcessJobAsync(j); + //Capture metrics + CoreJobMetricsSnapshot.DoJob(); } catch (Exception ex) { @@ -296,34 +296,22 @@ namespace AyaNova.Biz System.Diagnostics.Debug.WriteLine($"JobsBiz processing backup"); await CoreJobBackup.DoWorkAsync();//sb exclusive System.Diagnostics.Debug.WriteLine($"JobsBiz processing metrics snapshotter"); - + + //Capture metrics + CoreJobMetricsSnapshot.DoJob(); /////////////////////////////////////// //NON-EXCLUSIVE JOBS // - - - - //LOOKAT: Parallelize / background this block - //http://www.dotnetcurry.com/dotnet/1360/concurrent-programming-dotnet-core - - //var backgroundTask = Task.Run(() => DoComplexCalculation(42)); - //also have to deal with db object etc, I guess they'd have to instantiate themselves to avoid disposed object being used error - //This area may turn out to need a re-write in future, but I think it might only involve this block and ProcessJobAsync - //the actual individual objects that are responsible for jobs will likely not need a signature rewrite or anything (I hope) - //For now I'z hoping that no job will be so slow that it can hold up all the other jobs indefinitely. - + //These fire and forget but use a technique to bubble up exceptions anyway List sharedJobs = await GetReadyJobsNotExlusiveOnlyAsync(); foreach (OpsJob j in sharedJobs) { try { - - System.Diagnostics.Debug.WriteLine($"JobsBiz processing NON-exclusive biz job {j.Name}"); - // Task.Run(() => FireAway()); - TaskUtil.Forget(Task.Run(() => ProcessJobAsync(j))); - // await ProcessJobAsync(j, ct); + System.Diagnostics.Debug.WriteLine($"JobsBiz processing NON-exclusive biz job {j.Name}"); + TaskUtil.Forget(Task.Run(() => ProcessJobAsync(j))); } catch (Exception ex) { diff --git a/server/AyaNova/generator/Generate.cs b/server/AyaNova/generator/Generate.cs index 4b252801..f53f53cf 100644 --- a/server/AyaNova/generator/Generate.cs +++ b/server/AyaNova/generator/Generate.cs @@ -20,8 +20,8 @@ namespace AyaNova.Generator public class GeneratorService : BackgroundService { private readonly ILogger log; - // private const int MAXIMUM_MS_ALLOWED_FOR_PROCESSING_ALL_JOBS = 1 * 60 * 1000;//1 minutes TEST TEST TEST ##### -#if(DEBUG) + // private const int MAXIMUM_MS_ALLOWED_FOR_PROCESSING_ALL_JOBS = 1 * 60 * 1000;//1 minutes TEST TEST TEST ##### +#if (DEBUG) private const int GENERATE_SECONDS = 5; #else private const int GENERATE_SECONDS = 20; @@ -64,8 +64,9 @@ namespace AyaNova.Generator System.Diagnostics.Debug.WriteLine($"### GENERATE calling JobsBiz.ProcessJobs"); //Capture metrics CoreJobMetricsSnapshot.DoJob(); - //TODO: this should be big timeout and then inside the process jobs each job has it's own timeout - await JobsBiz.ProcessJobsAsync(); + await JobsBiz.ProcessJobsAsync(); + //Capture metrics again, (calling repeatedly won't increase metrics but will ensure it doesn't miss frequency of capturing) + CoreJobMetricsSnapshot.DoJob(); System.Diagnostics.Debug.WriteLine($"### GENERATE BACK FROM calling JobsBiz.ProcessJobs"); } }