/// <summary>
        ///     Adds a job that has been sent to a client to the job maintenance engine.
        /// </summary>
        /// <param name="j"></param>
        /// <param name="request"></param>
        private void MaintainJobStatus(Job j, JobRequest request)
        {
            DateTime        dueDate = DateTime.Now + TimeSpan.FromSeconds(request.JobHandleTimeoutSeconds);
            JobTimeoutModel model   = new JobTimeoutModel(j.JobId, dueDate, request);

            JobMaintenanceHelper.AddJob(model);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Starts engine health checck thread.
 /// </summary>
 public static void StartMonitorThread()
 {
     MonitorThread = new Thread(() => {
         int sleepCount = 0;
         while (!TokenSource.IsCancellationRequested)
         {
             Thread.Sleep(TimeSpan.FromSeconds(1));
             // Check health every minute
             if (++sleepCount > 60)
             {
                 sleepCount = 0;
                 // Check MMM controller
                 if (Program.MagnumBiDispatchController == null ||
                     !Program.MagnumBiDispatchController.Running)
                 {
                     Log.Warning("Engine health check failed, reconnecting.");
                     try {
                         Program.MagnumBiDispatchController?.Shutdown();
                         Program.CreateAndConnectEngine();
                     } catch (Exception e) {
                         Log.Error("Engine health check failed to reconnect!", e);
                     }
                 }
                 // Check job timeout thread
                 if (JobMaintenanceHelper.JobTimeoutThread == null ||
                     !JobMaintenanceHelper.JobTimeoutThread.IsAlive)
                 {
                     Log.Warning("Job Timeout Thread not running. Restarting thread.");
                     JobMaintenanceHelper.StartJobTimeoutThread();
                 }
             }
         }
     })
     {
         IsBackground = true,
         Name         = "Monitor"
     };
     MonitorThread.Start();
 }