public static Int32 CompareTasksByCost( AgentTask A, AgentTask B ) { if( ( A.Specification != null ) && ( B.Specification != null ) ) { return A.Specification.Cost.CompareTo( B.Specification.Cost ); } return 0; }
public static Int32 CompareTasksByAssignTime( AgentTask A, AgentTask B ) { return A.AssignTime.CompareTo( B.AssignTime ); }
private void UpdateTaskStateAsRequeued( AgentTask RunningTask ) { // A task is killed or rejected when a connection is closed and it still has // pending or running tasks assigned to it. Simply requeue the tasks for // another agent to pick up. RunningTask.StopTime = DateTime.UtcNow; RunningTasks.Remove( RunningTask.Specification.TaskGuid ); RunningTask.CurrentOwner.RunningTasks.Remove( RunningTask.Specification.TaskGuid ); // Update stats if( RunningTask.CurrentOwner is RemoteConnection ) { TaskCountRemote--; } // Reset a couple states before requeueing RunningTask.CurrentState = new AgentTaskState( RunningTask.Specification.JobGuid, RunningTask.Specification.TaskGuid, EJobTaskState.TASK_STATE_IDLE ); RunningTask.CurrentOwner = null; PendingTasks.Push( RunningTask ); TaskCountRequeue++; // With the killed task requeued, check for reservations to see // if anyone else can take the task on right away CheckForReservations(); }
private void UpdateTaskStateAsFailure( AgentTask RunningTask ) { TaskFailureCount++; RunningTask.StopTime = DateTime.UtcNow; RunningTasks.Remove( RunningTask.Specification.TaskGuid ); RunningTask.CurrentOwner.RunningTasks.Remove( RunningTask.Specification.TaskGuid ); RetiredTasks.Enqueue( RunningTask ); }