Example #1
0
        public string GetValue(Resource resource, LaunchDestination destination)
        {
            var nodes = resource.Nodes.Join(destination.NodeNames, n => n.DNSName, n => n, (n, name) => n).Distinct();
            var cores = nodes.Select(n => Int32.Parse(ClusterParameterReader.GetValue(TotalNodeCores.TCORES, n), CultureInfo.InvariantCulture)).Sum();
            var perf  = nodes.Select(n => Double.Parse(ClusterParameterReader.GetValue(PERF, n), CultureInfo.InvariantCulture.NumberFormat)).Sum();

            return((perf / cores).ToString(CultureInfo.InvariantCulture.NumberFormat));
        }
Example #2
0
        public static string GetValue(string parameterId, Resource resource, LaunchDestination destination)
        {
            if (resource == null || !ResourceParameterTypes.ContainsKey(parameterId))
            {
                throw new HardwareParameterException(parameterId, resource == null ? null : resource.Name);
            }

            return(((IResourceHardwareParameter)ResourceParameterTypes[parameterId].GetConstructor(Type.EmptyTypes).Invoke(null)).GetValue(resource, destination));
        }
Example #3
0
 public string GetValue(Resource resource, LaunchDestination destination)
 {
     if (resource.Parameters.ContainsKey(Key))
     {
         return(resource.Parameters[Key]);
     }
     else
     {
         throw new HardwareParameterException(Id, resource.Name);
     }
 }
Example #4
0
        public EstimationResult Estimate(Task task, string resourceName, LaunchDestination destination, bool optimize)
        {
            var key = new KeyValuePair <string, ulong>(resourceName, task.Id);

            if (_estimations.ContainsKey(key))
            {
                return(_estimations[key]);
            }
            else
            {
                var result = TaskTimeMeter.MeasureAppTime(task.ApplicationName, task.Parameters, resourceName, destination, optimize);
                _estimations[key] = result;
                return(result);
            }
        }
Example #5
0
 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;
     }
                                             ));
 }
Example #6
0
        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);
        }
Example #7
0
        /*private void LaunchVMs(Workflow workflow, LaunchPlan plan)
         * {
         *  var startedMachines = new List<string>();
         *  bool virtualsUsed = false;
         *
         *  foreach (var t in plan.Plan)
         *  {
         *      if (virtualsUsed && workflow.IsSequence)
         *      {
         *          t.State = TaskState.SCHEDULED;
         *          t.EstimatedLaunchTime = 0;
         *          continue;
         *      }
         *
         *      var plannedNodes = workflow.Resources.Single(r => r.Name == t.Destination.ResourceName).Nodes.Where(n => t.Destination.NodeNames.Any(s => s == n.DNSName));
         *      foreach (var node in plannedNodes)
         *      {
         *          var isVirtual = Boolean.Parse(ClusterParameterReader.GetValue(IsNodeVirtual.IS_VIRTUAL, node));
         *          if (isVirtual)
         *          {
         *              var parameters = Newtonsoft.Json.JsonConvert.DeserializeObject<HostConnectionParams>(ClusterParameterReader.GetValue(VirtualConnectionParams.VCP, node));
         *              try
         *              {
         *                  var host = vManager.AddHost(parameters);
         *                  if (vManager.ConnectToHost(host.Name))
         *                  {
         *                      var state = vManager.GetMachineState(host.Name, node.DNSName);
         *                      if (state.State != MachineState.RUNNING || !vManager.IsGuestOSRunning(host.Name, node.DNSName))
         *                      {
         *                          virtualsUsed = true;
         *                          if (!startedMachines.Any(m => m == node.DNSName))
         *                          {
         *                              switch (state.State)
         *                              {
         *                                  case MachineState.STOPPED:
         *                                      vManager.StartMachine(host.Name, node.DNSName, new Dictionary<string, string>());
         *                                      break;
         *                                  case MachineState.SUSPENDED:
         *                                      vManager.WakeMachine(host.Name, node.DNSName);
         *                                      break;
         *                              }
         *                              startedMachines.Add(node.DNSName);
         *                          }
         *                          t.State = TaskState.SCHEDULED;
         *                          t.EstimatedLaunchTime = 0;
         *                      }
         *                      else
         *                      {
         *                          startedMachines.Add(node.DNSName);
         *                      }
         *                  }
         *              }
         *              catch (FaultException<ErrorMessage> e)
         *              {
         *
         *              }
         *          }
         *      }
         *  }
         * }*/

        public static NodeAvailabilityTime[] GenerateWrappers(EstimatedWorkflow workflow)
        {
            var wrs = workflow.Tasks.SelectMany(t => t.Estimations.SelectMany(e => e.Resource.Nodes.Select(n => new NodeAvailabilityTime(n)))).Distinct(new RWComparer()).ToList();

            foreach (var wrapper in wrs)
            {
                var d = new LaunchDestination()
                {
                    ResourceName = wrapper.ResourceName, NodeNames = new[] { wrapper.NodeName }
                };
                foreach (var t in workflow.ActiveTasks.Where(t => t.Estimation.Destination.IsLike(d)))
                {
                    wrapper.AssignTask(t);
                }
            }
            return(wrs.ToArray());
        }
 public string GetValue(Resource resource, LaunchDestination destination)
 {
     var nodes = resource.Nodes.Join(destination.NodeNames, n => n.DNSName, n => n, (n, name) => n).Distinct();
     return Math.Floor((double)nodes.Sum(node => node.CoresTotal) / nodes.Count()).ToString();
 }
Example #9
0
 internal static string GetValue(string parameterId, ClusterInfo cluster, LaunchDestination destination)
 {
     return(GetValue(parameterId, new IntegratorResource(cluster), destination));
 }
Example #10
0
        public string GetValue(Resource resource, LaunchDestination destination)
        {
            var nodes = resource.Nodes.Join(destination.NodeNames, n => n.DNSName, n => n, (n, name) => n).Distinct();

            return(Math.Floor((double)nodes.Sum(node => node.CoresTotal) / nodes.Count()).ToString());
        }
Example #11
0
 public string GetValue(Resource resource, LaunchDestination destination)
 {
     return(resource.Nodes.Join(destination.NodeNames, n => n.DNSName, n => n, (n, name) => n).Distinct().Count().ToString());
 }
 public string GetValue(Resource resource, LaunchDestination destination)
 {
     var nodes = resource.Nodes.Join(destination.NodeNames, n => n.DNSName, n => n, (n, name) => n).Distinct();
     var cores = nodes.Select(n => Int32.Parse(ClusterParameterReader.GetValue(TotalNodeCores.TCORES, n), CultureInfo.InvariantCulture)).Sum();
     var perf = nodes.Select(n => Double.Parse(ClusterParameterReader.GetValue(PERF, n), CultureInfo.InvariantCulture.NumberFormat)).Sum();
     return (perf / cores).ToString(CultureInfo.InvariantCulture.NumberFormat);
 }
Example #13
0
 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;
         }
     );
 }
 public string GetValue(Resource resource, LaunchDestination destination)
 {
     return resource.Nodes.Join(destination.NodeNames, n => n.DNSName, n => n, (n, name) => n).Distinct().Count().ToString();
 }
 internal static string GetValue(string parameterId, ClusterInfo cluster, LaunchDestination destination)
 {
     return GetValue(parameterId, new IntegratorResource(cluster), destination);
 }
        public static string GetValue(string parameterId, Resource resource, LaunchDestination destination)
        {
            if (resource == null || !ResourceParameterTypes.ContainsKey(parameterId))
            {
                throw new HardwareParameterException(parameterId, resource == null ? null : resource.Name);
            }

            return ((IResourceHardwareParameter)ResourceParameterTypes[parameterId].GetConstructor(Type.EmptyTypes).Invoke(null)).GetValue(resource, destination);
        }
 public string GetValue(Resource resource, LaunchDestination destination)
 {
     if (resource.Parameters.ContainsKey(Key))
     {
         return resource.Parameters[Key];
     }
     else
     {
         throw new HardwareParameterException(Id, resource.Name);
     }
 }