public object Clone() { var result = new NodeAvailabilityTime(); result.DestinedTasks.AddRange(result.DestinedTasks); result.Node = Node; return(result); }
public static List <IEnumerable <ActiveEstimatedTask> > MakeOverallEstimations(EstimatedWorkflow workflow, NodeAvailabilityTime[] wrappers) { var estimatedTasks = new List <IEnumerable <ActiveEstimatedTask> >(workflow.Tasks.Count); for (var i = 0; i < workflow.Tasks.Count; i++) { var task = workflow.Tasks[i]; estimatedTasks.Add(new List <ActiveEstimatedTask>()); for (var j = 0; j < task.Estimations.Length; j++) { var estimation = task.Estimations[j]; var nodesNumber = Int32.Parse(estimation.Result.Parameters.Single(p => p.Name == NodesCountExtractor.NODES).NewValue); var coresNumber = Int32.Parse(estimation.Result.Parameters.Single(p => p.Name == ProcessorCountPerNode.P).NewValue); var nodeWrappers = wrappers.Where(w => w.ResourceName == estimation.Resource.Name && w.Node.CoresTotal >= coresNumber && estimation.Resource.Nodes.Any(n => n.DNSName == w.NodeName)); var optionsNumber = (int)Math.Pow(nodeWrappers.Count(), nodesNumber); var dests = new LaunchDestination[optionsNumber]; var indices = Enumerable.Repeat(0, nodesNumber).ToArray(); var baseValues = Enumerable.Repeat(nodeWrappers.Count(), nodesNumber).ToArray(); var usedNodes = new NodeAvailabilityTime[nodesNumber]; var resName = estimation.Resource.Name; for (var k = 0; k < optionsNumber; k++) { for (var l = 0; l < usedNodes.Length; l++) { usedNodes[l] = nodeWrappers.ElementAt(indices[l]); } var dest = new LaunchDestination() { ResourceName = resName, NodeNames = usedNodes.Select(un => un.NodeName).ToArray() }; dests[k] = dest; AdvanceIndices(indices, baseValues); } dests = dests.Where(d => d.NodeNames.Distinct().Count() == nodesNumber).ToArray(); foreach (var dest in dests) { var taskOnResource = new ActiveEstimatedTask(task); taskOnResource.Estimation.Result = estimation.Result; taskOnResource.Estimation.Destination = dest; taskOnResource.Estimation.NodesTimings = nodeWrappers.Where(w => w.ResourceName == dest.ResourceName && dest.NodeNames.Contains(w.NodeName)).ToArray(); ((List <ActiveEstimatedTask>)estimatedTasks[i]).Add(taskOnResource); } } } return(estimatedTasks); }