public ActiveEstimatedTask(ActiveEstimatedTask task) : base(task) { var t = task.Clone() as ActiveEstimatedTask; State = t.State; IsUrgent = t.IsUrgent; MonopolizeResource = t.MonopolizeResource; Estimation = t.Estimation; }
public object Clone() { var result = new ActiveEstimatedTask(this as TaskScheduler.BaseTask); result.State = State; result.IsUrgent = IsUrgent; result.MonopolizeResource = MonopolizeResource; result.Estimation = Estimation == null ? null : Estimation.Clone() as ActiveEstimation; return result; }
private static double GetTime(EstimatedWorkflow workflow, ActiveEstimatedTask t) { var parent = workflow.Tasks.Single(wt => wt.Id == t.Id); var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max(d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time); var nodesWaitingTime = t.Estimation.NodesTimings.Max(n => n.GetAvailabilityTime()); var waitingTime = Math.Max(depsWaitingTime, nodesWaitingTime); return(waitingTime + t.Estimation.Result.Time); }
public object Clone() { var result = new ActiveEstimatedTask(this as TaskScheduler.BaseTask); result.State = State; result.IsUrgent = IsUrgent; result.MonopolizeResource = MonopolizeResource; result.Estimation = Estimation == null ? null : Estimation.Clone() as ActiveEstimation; return(result); }
protected double FullTaskTime(ActiveEstimatedTask task, EstimatedUrgentWorkflow workflow) { var parent = workflow.Tasks.Single(wt => wt.Id == task.Id); var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max( d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time); var nodesWaitingTime = GetNodesAvailabilityTimeForUrgentTask(task, workflow); //t.First().Estimation.NodesTimings.Max(n => n.AvailabilityTime); var waitingTime = Math.Max(depsWaitingTime, nodesWaitingTime); return(waitingTime + task.Estimation.Result.Time); }
protected virtual double GetNodesAvailabilityTimeForUrgentTask(ActiveEstimatedTask task, EstimatedUrgentWorkflow workflow) { return(task.Estimation.NodesTimings.Max(n => { var lTask = n.LaunchedTask; var result = lTask != null && (lTask.IsUrgent || !task.IgnoreNonUrgent) ? lTask.Estimation.Result.Time : 0; var td = new LaunchDestination() { ResourceName = n.ResourceName, NodeNames = new[] { n.NodeName } }; result += workflow.ActiveTasks.Where(t => t.IsUrgent && t.State == TaskScheduler.TaskState.SCHEDULED && t.IsOlderThan(task) && t.Estimation.Destination.IsLike(td)).Sum(t => t.Estimation.Result.Time); return result; } )); }
internal virtual ActiveEstimatedTask ChooseTask(EstimatedUrgentWorkflow workflow, UrgentPlan plan) { var seq = ChooseSequence(workflow, plan); var prevInstance = ExtractTask(seq, plan); var parent = workflow.Tasks.Single(t => t.Id == prevInstance.Id); var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max(d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time); prevInstance.Estimation.LaunchTime = Math.Max(depsWaitingTime, GetNodesAvailabilityTimeForUrgentTask(prevInstance, workflow)); prevInstance.State = prevInstance.Estimation.LaunchTime > TaskScheduler.E || prevInstance.Estimation.NodesTimings.Any(w => w.GetAvailabilityTime(plan.IgnoreNonUrgentTasks) > TaskScheduler.E) ? TaskScheduler.TaskState.SCHEDULED : TaskScheduler.TaskState.LAUNCHED; var clonedInstance = new ActiveEstimatedTask(prevInstance) { IsUrgent = true }; foreach (var node in prevInstance.Estimation.NodesTimings) { node.AssignTask(clonedInstance); } plan.Plan.Add(clonedInstance); parent.ScheduledInstance = clonedInstance; return(clonedInstance); }
private List<ActiveEstimatedTask> processUnscheduledWfsSeq(Tuple<string, IEnumerable<ActiveEstimatedTask>, IEnumerable<EstimatedTask>, IEnumerable<TasksDepenendency>> wf, ResourceEstimation[] est) { var result = new List<ActiveEstimatedTask>(); // foreach (var wf in wfs) //{ // Should be empty, i.e. we mustn't get here if we have a wf with active tasks var runningOrScheduledTasks = wf.Item2; var notScheduledTasks = wf.Item3; var dependencies = wf.Item4; List<ActiveEstimatedTask> schedTasks = null; schedTasks = new List<ActiveEstimatedTask>(); int localTaskID = 0; try { foreach (var task in notScheduledTasks) { localTaskID = Convert.ToInt32(task.Parameters["id"]) - 1; //logger.Info("Local task id: " + localTaskID); //logger.Info(" NodeName: " + est[localTaskID].Resource.Nodes[0].DNSName); ActiveEstimatedTask taskToAdd = new ActiveEstimatedTask(); taskToAdd.ApplicationName = task.ApplicationName; taskToAdd.WFid = task.WFid; taskToAdd.Id = task.Id; taskToAdd.IsUrgent = false; taskToAdd.Parameters = new Dictionary<string, string>(task.Parameters); //This state must be the same for all tasks. Correct conversion will be done in ExecutionBroker //taskToAdd.State = TaskScheduler.TaskState.LAUNCHED; taskToAdd.State = TaskScheduler.TaskState.SCHEDULED; taskToAdd.Estimation = new ActiveEstimation() { Destination = new LaunchDestination() { ResourceName = est[localTaskID].Resource.Name, NodeNames = new string[] { est[localTaskID].Resource.Nodes[0].DNSName } }, Resource = new Resource() { Name = est[localTaskID].Resource.Name, Nodes = new Node[] { est[localTaskID].Resource.Nodes[0] }, Parameters = task.Parameters, }, LaunchTime = est[localTaskID].Result.CalculationTime, Result = est[localTaskID].Result }; schedTasks.Add(taskToAdd); } result.AddRange(schedTasks); //logger.Info("Scheduled tasks count: " + schedTasks.Count); } catch (Exception ex) { logger.ErrorException("Exception in processUnscheduledWfsSeq", ex); } return result; //var schedTasks = notScheduledTasks.Select(task => new ActiveEstimatedTask() //{ // ApplicationName = task.ApplicationName, // WFid = task.WFid, // Id = task.Id, // IsUrgent = false, // Parameters = new Dictionary<string, string>(task.Parameters), // //This state must be the same for all tasks. Correct conversion will be done in ExecutionBroker // State = TaskScheduler.TaskState.LAUNCHED, // Estimation = new ActiveEstimation() // { // Destination = new LaunchDestination() // { // ResourceName = est[localTaskID].Resource.Name, // NodeNames = new string[] { est[localTaskID].Resource.Nodes[0].DNSName }, // }, // Resource = new Resource() // { // Name = est[localTaskID].Resource.Name, // Nodes = new Node[] { est[localTaskID].Resource.Nodes[0] }, // Parameters = task.Parameters, // }, // LaunchTime = est[localTaskID].Result.CalculationTime, // Result = est[localTaskID].Result, // }, //}).ToList(); }
public bool IsOlderThan(ActiveEstimatedTask other) { return other == null || Id < other.Id; }
protected virtual double GetNodesAvailabilityTimeForUrgentTask(ActiveEstimatedTask task, EstimatedUrgentWorkflow workflow) { return task.Estimation.NodesTimings.Max(n => { var lTask = n.LaunchedTask; var result = lTask != null && (lTask.IsUrgent || !task.IgnoreNonUrgent) ? lTask.Estimation.Result.Time : 0; var td = new LaunchDestination() { ResourceName = n.ResourceName, NodeNames = new[] { n.NodeName } }; result += workflow.ActiveTasks.Where(t => t.IsUrgent && t.State == TaskScheduler.TaskState.SCHEDULED && t.IsOlderThan(task) && t.Estimation.Destination.IsLike(td)).Sum(t => t.Estimation.Result.Time); return result; } ); }
protected double FullTaskTime(ActiveEstimatedTask task, EstimatedUrgentWorkflow workflow) { var parent = workflow.Tasks.Single(wt => wt.Id == task.Id); var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max( d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time); var nodesWaitingTime = GetNodesAvailabilityTimeForUrgentTask(task, workflow); //t.First().Estimation.NodesTimings.Max(n => n.AvailabilityTime); var waitingTime = Math.Max(depsWaitingTime, nodesWaitingTime); return waitingTime + task.Estimation.Result.Time; }
internal virtual ActiveEstimatedTask ChooseTask(EstimatedUrgentWorkflow workflow, UrgentPlan plan) { var seq = ChooseSequence(workflow, plan); var prevInstance = ExtractTask(seq, plan); var parent = workflow.Tasks.Single(t => t.Id == prevInstance.Id); var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max(d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time); prevInstance.Estimation.LaunchTime = Math.Max(depsWaitingTime, GetNodesAvailabilityTimeForUrgentTask(prevInstance, workflow)); prevInstance.State = prevInstance.Estimation.LaunchTime > TaskScheduler.E || prevInstance.Estimation.NodesTimings.Any(w => w.GetAvailabilityTime(plan.IgnoreNonUrgentTasks) > TaskScheduler.E) ? TaskScheduler.TaskState.SCHEDULED : TaskScheduler.TaskState.LAUNCHED; var clonedInstance = new ActiveEstimatedTask(prevInstance) { IsUrgent = true }; foreach (var node in prevInstance.Estimation.NodesTimings) { node.AssignTask(clonedInstance); } plan.Plan.Add(clonedInstance); parent.ScheduledInstance = clonedInstance; return clonedInstance; }
private static double GetTime(EstimatedWorkflow workflow, ActiveEstimatedTask t) { var parent = workflow.Tasks.Single(wt => wt.Id == t.Id); var depsWaitingTime = parent.RequiresDependencies.Count == 0 ? 0 : parent.RequiresDependencies.Max(d => d.ScheduledInstance.Estimation.LaunchTime + d.ScheduledInstance.Estimation.Result.Time); var nodesWaitingTime = t.Estimation.NodesTimings.Max(n => n.GetAvailabilityTime()); var waitingTime = Math.Max(depsWaitingTime, nodesWaitingTime); return waitingTime + t.Estimation.Result.Time; }
public bool IsOlderThan(ActiveEstimatedTask other) { return(other == null || Id < other.Id); }