internal void UpdateProcessingItem() { // Fälle // 1. _jobInProgress ist leer // 2. _jobInProgress hat etwas in progress aber nichts Ready Gelistet // 3. _jobInProgress hat etwas in progress und Ready Gelistete elemente var foundItem = true; var jobInProgressHasChanged = false; while (foundItem) { var item = _scopeQueue.GetFirstIfSatisfiedAndSetReadyAtIsSmallerOrEqualThan(currentTime: Agent.CurrentTime, _capabilityProviderManager.GetCurrentUsedCapability()); if (item == null) { foundItem = false; continue; } if (_jobInProgress.IsSet && _jobInProgress.ResourceIsBusyUntil > item.ScopeConfirmation.GetScopeStart()) { Agent.DebugMessage(msg: $"Seems to be wrong #2", CustomLogger.JOB, LogLevel.Warn); } jobInProgressHasChanged = true; Agent.Send(instruction: Job.Instruction.ResourceWillBeReady.Create(target: item.JobAgentRef)); _jobInProgress.Add(item); Agent.DebugMessage(msg: $"Add to jobInProgress { item.Job.Name } { item.Job.Key } scope start { item.ScopeConfirmation.GetScopeStart() } setReadyAt { item.ScopeConfirmation.SetReadyAt } Has Satisfied Jobs { ((FBucket)item.Job).HasSatisfiedJob }", CustomLogger.JOB, LogLevel.Warn); _scopeQueue.RemoveJob(item); } var job = _jobInProgress.ReadyItemToProcessingItem(); //_jobInProgress.has any ready items if (!_jobInProgress.IsSet && job.IsNull()) { Agent.DebugMessage(msg: $"Start Queue Health check.", CustomLogger.JOB, LogLevel.Warn); if (_scopeQueue.QueueHealthCheck(Agent.CurrentTime)) { Agent.DebugMessage(msg: $"Queue seems unhealthy, try to requeue!", CustomLogger.JOB, LogLevel.Warn); RequeueAllRemainingJobs(); return; } ; } if (job.IsNotNull() || jobInProgressHasChanged) { RequeueIfNecessary(); } // take the next scope and make it fix if (job.IsNotNull()) { if (job.ScopeConfirmation.GetSetup() != null) { Agent.Send(instruction: Job.Instruction.RequestSetupStart.Create(message: Agent.Context.Self, target: job.JobAgentRef)); Agent.DebugMessage(msg: $"Asking for SetupStart {job.Job.Name} {job.Job.Key} at {Agent.Context.Self.Path.Name}", CustomLogger.JOB, LogLevel.Warn); } else { Agent.Send(instruction: Job.Instruction.RequestProcessingStart.Create(message: Agent.Context.Self, target: job.JobAgentRef)); Agent.DebugMessage(msg: $"Asking for Processing {job.Job.Name} {job.Job.Key} at {Agent.Context.Self.Path.Name}", CustomLogger.JOB, LogLevel.Warn); } } }