示例#1
0
 public override NodeState GetNodeState(ResourceNode node)
 {
     lock (_hadoopLock)
     {
         return new NodeState()
         {
             CoresAvailable = _nodeUsed ? 0 : node.CoresCount
         };
     }
 }
示例#2
0
        public override NodeState GetNodeState(ResourceNode node)
        {
            lock (_pcLock)
            {
                //CheckNodeNamePresence(node.NodeName);
                if (!_nodeUsed.ContainsKey(node.NodeName))
                    _nodeUsed[node.NodeName] = false;

                return new NodeState()
                {
                    CoresAvailable = (_nodeUsed[node.NodeName])? 0: node.CoresCount
                };
            }
        }
示例#3
0
        private JObject BuildNodeDescription(ResourceNode node)
        {
            //todo make proper fillness later
            var json = new JObject();
            json.Add("NodeName", node.NodeName);
            json.Add("NodeAddress", node.NodeAddress);

            //Services section
            var jsonServices = new JObject();
            json.Add("Services", jsonServices);
            jsonServices.Add("ExecutionUrl", node.Services.ExecutionUrl);

            //Packages section
            if (node.Packages != null && node.Packages.Count > 0)
            {
                var array = node.Packages.Select(x => BuildPackageDescription(x)).ToArray<object>();
                var jsonPackages = new JArray(array);
                json.Add("Packages", jsonPackages);
            }
            //CoresCount Section
            if (node.CoresCount != 0)
            {
                json.Add("CoresCount", node.CoresCount);
            }
            //Credentials section
            if (node.Credentials != null)
            {
                var jsonCredentials = new JObject();

                if (node.Credentials.Username != null)
                {
                    jsonCredentials.Add("Username",node.Credentials.Username);
                }
                if (node.Credentials.Password != null)
                {
                    jsonCredentials.Add("Password", node.Credentials.Password);
                }
                if (node.Credentials.CertFile != null)
                {
                    jsonCredentials.Add("CertFile", node.Credentials.CertFile);
                }

                if (jsonCredentials.Count > 0)
                {
                    json.Add("Credentials", jsonCredentials);
                }
            }
            //SupportedArchitectures section
            if (node.SupportedArchitectures != null && node.SupportedArchitectures.Count() > 0)
            {
                var array = node.SupportedArchitectures.ToArray<object>();
                var jsonSupportedArchitectures = new JArray(array);
                json.Add("SupportedArchitectures", jsonSupportedArchitectures);
            }
            //TasksSubmissionLimit section
            if (node.TasksSubmissionLimit != 0)
            {
                json.Add("TasksSubmissionLimit", node.TasksSubmissionLimit);
            }
            //DataFolders section
            if (node.DataFolders != null)
            {
                var jsonDataFolders = new JObject();
                if (node.DataFolders.ExchangeUrlFromSystem != null)
                {
                    jsonDataFolders.Add("ExchangeUrlFromSystem", node.DataFolders.ExchangeUrlFromSystem);
                }
                if (node.DataFolders.ExchangeUrlFromResource != null)
                {
                    jsonDataFolders.Add("ExchangeUrlFromResource", node.DataFolders.ExchangeUrlFromResource);
                }
                if (node.DataFolders.LocalFolder != null)
                {
                    jsonDataFolders.Add("LocalFolder", node.DataFolders.LocalFolder);
                }
                jsonDataFolders.Add("CopyLocal", node.DataFolders.CopyLocal);

                json.Add("DataFolders", jsonDataFolders);
            }
            //OtherSoftware section
            if (node.OtherSoftware != null && node.OtherSoftware.Count > 0)
            {
                var arr = node.OtherSoftware.ToArray<object>();
                var jsonOtherSoftware = new JArray(arr);
                json.Add("OtherSoftware", jsonOtherSoftware);
            }
            //HardwareParams section
            if (node.StaticHardwareParams != null && node.StaticHardwareParams.Count > 0)
            {
                var arr = node.StaticHardwareParams.Select(x =>
                    {
                        var obj = new JObject();
                        obj.Add("Key", x.Key);
                        obj.Add("Value", x.Value);
                        return obj;
                    }).ToArray<object>();

                var jsonHardwareParams = new JArray(arr);
                json.Add("HardwareParams", jsonHardwareParams);
            }

            return json;
        }
示例#4
0
        public void AddNewNodeToResource(string resourceName, ResourceNode node, string userId)
        {
            //throw new NotImplementedException();
            lock (_updateLock)
            {
                var oldRes = GetResourceByName(resourceName, userId);

                if (oldRes == null)
                {
                    throw new InvalidDataException("There is no resources which can be modified. Check resource name, node name or access rights");
                }

                var oldNode = oldRes.Nodes.FirstOrDefault(x => x.NodeName == node.NodeName);
                if (oldNode != null)
                {
                    throw new InvalidDataException("There alredy exists node with NodeName:" + node.NodeName);
                }

                var json = oldRes.Json;
                var resource = JObject.Parse(json);
                var nodes = resource["Nodes"].ToObject<JArray>();

                var newNode = BuildNodeDescription(node);
                nodes.Add(newNode);

                resource["Nodes"] = nodes;

                var newJson = resource.ToString();

                Resource.SaveResource(newJson, oldRes.ResourceName);
            }
        }
示例#5
0
        private static Dictionary <string, object> GetModelCoefs(PackageEngine engine, ResourceNode node)
        {
            var fixedCoefs      = new Dictionary <string, object>(engine.CompiledMode.Models.DefaultCoeffs);
            var adjustableCoefs = new Dictionary <string, double>();

            string packageName = engine.CompiledMode.ModeQName.PackageName; // engineState._taskDescription.Package
            var    packParams  = node.PackageByName(packageName).Params;

            foreach (string paramKey in packParams.Keys)
            {
                string paramValue = packParams[paramKey];
                double paramValueAsDouble;
                bool   isDouble = double.TryParse(paramValue,
                                                  System.Globalization.NumberStyles.Float,
                                                  System.Globalization.CultureInfo.InvariantCulture.NumberFormat,
                                                  out paramValueAsDouble);

                if (paramKey.ToLowerInvariant().StartsWith(FIXED_COEF_PREFIX))
                {
                    string coefName = paramKey.Remove(0, FIXED_COEF_PREFIX.Length);
                    if (isDouble)
                    {
                        fixedCoefs[coefName] = paramValueAsDouble;
                    }
                    else
                    {
                        fixedCoefs[coefName] = paramValue;
                    }
                }
                else
                if (paramKey.ToLowerInvariant().StartsWith(ADJUSTABLE_COEF_PREFIX))
                {
                    string coefName = paramKey.Remove(0, ADJUSTABLE_COEF_PREFIX.Length);
                    if (isDouble)
                    {
                        adjustableCoefs[coefName] = paramValueAsDouble;
                    }
                    else
                    {
                        fixedCoefs[coefName] = paramValue;
                        Log.Warn(String.Format(
                                     "Cannot adjust param '{0}' for pack '{1}' on resource node '{2}.{3}' because it's value is not number",
                                     paramKey, packageName,
                                     node.ResourceName, node.NodeName
                                     ));
                    }
                }
            }

            var adjustedCoefs = AutoAdjustCoefsByHistory(engine, node, fixedCoefs, adjustableCoefs) ?? new Dictionary <string, double>();

            if (adjustableCoefs.Any())
            {
                Log.Info("Model coefs were adjusted");
            }

            var newCoefNames = adjustedCoefs.Keys.Except(adjustableCoefs.Keys);

            if (newCoefNames.Any())
            {
                Log.Warn("Autoadjust created new coefs (ignoring them): " + String.Join(", ", newCoefNames));
            }

            var modelCoefs = new Dictionary <string, object>(fixedCoefs);

            foreach (var coefName in adjustableCoefs.Keys)
            {
                if (adjustedCoefs.ContainsKey(coefName))
                {
                    modelCoefs[coefName] = adjustedCoefs[coefName];
                }
                else
                {
                    modelCoefs[coefName] = adjustableCoefs[coefName];
                    Log.Warn("Coef " + coefName + " was not returned as adjusted. Using non-adjusted value.");
                }
            }
            return(modelCoefs);
        }
示例#6
0
        private static Dictionary <string, double> AutoAdjustCoefsByHistory(PackageEngine engine, ResourceNode node, Dictionary <string, object> fixedCoefs, Dictionary <string, double> adjustableCoefs)
        {
            lock (_historyLock)
            {
                //Log.Info("Adjusting coefs");
                string packageName = engine.CompiledMode.ModeQName.PackageName.ToLowerInvariant();
                var    history     = GetHistorySamples(packageName, node.ResourceName, node.NodeName);

                if (history.Length < 1)
                {
                    //Log.Debug("Not enough history samples to adjust coefs");
                    return(null);
                }

                if (packageName == "bsm")
                {
                    double[] fTime = history.Select(hs => double.Parse(hs.PackParams["ForecastSize"])).ToArray();
                    double[] cTime = history.Select(hs => hs.CalcTime.TotalSeconds).ToArray();

                    double perf = BSMSimpleEstimator.BsmEstimatePerf(fTime, cTime);
                    double dev  = BSMSimpleEstimator.BsmRelativeStDev(perf, fTime, cTime);

                    return(new Dictionary <string, double>()
                    {
                        { "Perf", perf },
                        { "D", dev }
                    });
                }
                else
                {
                    Log.Warn("Unsupported package to adjust coefs: " + packageName);
                    return(null);
                }
            }
        }
示例#7
0
 public abstract NodeState GetNodeState(ResourceNode node);
示例#8
0
        public void OverrideNulls(ResourceNode defaultValues)
        {
            Init();

            if (defaultValues == null)
            {
                CheckConsistency();
                return;
            }

            //ResourceName { get;  set; }   //  private set
            //public string ProviderName;

            if (!SupportedArchitectures.Any() && defaultValues.SupportedArchitectures.Any())
                SupportedArchitectures = defaultValues.SupportedArchitectures; // it's ok, because field is read-only

            if (Services == null)
                Services = new NodeServices(defaultValues.Services);

            if (DataFolders == null)
                DataFolders = new NodeDataFolders(defaultValues.DataFolders);

            Credentials = new NodeCredentials
            (
                userName: (Credentials.Username ?? defaultValues.Credentials.Username),
                password: (Credentials.Password ?? defaultValues.Credentials.Password),
                certFile: (Credentials.CertFile ?? defaultValues.Credentials.CertFile)
            );

            if (CoresCount == 0 && defaultValues.CoresCount > 0)
                CoresCount = defaultValues.CoresCount;

            //if (CoresAvailable == 0 && defaultValues.CoresAvailable > 0) // todo : unnecessary?
                //CoresAvailable = defaultValues.CoresAvailable;

            if (TasksSubmissionLimit <= 1 && defaultValues.TasksSubmissionLimit > 1) // do not override if defaultValue == (0 or 1) or non-default value for node is set
                TasksSubmissionLimit = defaultValues.TasksSubmissionLimit;

            //if (SubmissionsAvailable == 0 && defaultValues.SubmissionsAvailable > 0) // todo : unnecessary?
                //SubmissionsAvailable = defaultValues.SubmissionsAvailable;

            if (defaultValues.StaticHardwareParams != null)
                foreach (var key in defaultValues.StaticHardwareParams.Keys)
                {
                    if (!StaticHardwareParams.ContainsKey(key))
                        StaticHardwareParams[key] = defaultValues.StaticHardwareParams[key];
                }

            if (!_packages.Any())
            {
                foreach (var pack in defaultValues._packages)
                    _packages.Add(new PackageOnNode(pack));
            }

            if (!_otherSoftware.Any())
            {
                foreach (var soft in defaultValues._otherSoftware)
                    _otherSoftware.Add(soft);
            }

            CheckConsistency();
        }
示例#9
0
 public override string ExecuteRun(ResourceNode node, string scriptPath)
 {
     return(SshExec(node, GetRunCommand(), scriptPath + " " + UnixPbsCommands.SeparateThread));
 }
示例#10
0
        private JObject BuildNodeDescription(ResourceNode node)
        {
            //todo make proper fillness later
            var json = new JObject();

            json.Add("NodeName", node.NodeName);
            json.Add("NodeAddress", node.NodeAddress);

            //Services section
            var jsonServices = new JObject();

            json.Add("Services", jsonServices);
            jsonServices.Add("ExecutionUrl", node.Services.ExecutionUrl);

            //Packages section
            if (node.Packages != null && node.Packages.Count > 0)
            {
                var array        = node.Packages.Select(x => BuildPackageDescription(x)).ToArray <object>();
                var jsonPackages = new JArray(array);
                json.Add("Packages", jsonPackages);
            }
            //CoresCount Section
            if (node.CoresCount != 0)
            {
                json.Add("CoresCount", node.CoresCount);
            }
            //Credentials section
            if (node.Credentials != null)
            {
                var jsonCredentials = new JObject();

                if (node.Credentials.Username != null)
                {
                    jsonCredentials.Add("Username", node.Credentials.Username);
                }
                if (node.Credentials.Password != null)
                {
                    jsonCredentials.Add("Password", node.Credentials.Password);
                }
                if (node.Credentials.CertFile != null)
                {
                    jsonCredentials.Add("CertFile", node.Credentials.CertFile);
                }

                if (jsonCredentials.Count > 0)
                {
                    json.Add("Credentials", jsonCredentials);
                }
            }
            //SupportedArchitectures section
            if (node.SupportedArchitectures != null && node.SupportedArchitectures.Count() > 0)
            {
                var array = node.SupportedArchitectures.ToArray <object>();
                var jsonSupportedArchitectures = new JArray(array);
                json.Add("SupportedArchitectures", jsonSupportedArchitectures);
            }
            //TasksSubmissionLimit section
            if (node.TasksSubmissionLimit != 0)
            {
                json.Add("TasksSubmissionLimit", node.TasksSubmissionLimit);
            }
            //DataFolders section
            if (node.DataFolders != null)
            {
                var jsonDataFolders = new JObject();
                if (node.DataFolders.ExchangeUrlFromSystem != null)
                {
                    jsonDataFolders.Add("ExchangeUrlFromSystem", node.DataFolders.ExchangeUrlFromSystem);
                }
                if (node.DataFolders.ExchangeUrlFromResource != null)
                {
                    jsonDataFolders.Add("ExchangeUrlFromResource", node.DataFolders.ExchangeUrlFromResource);
                }
                if (node.DataFolders.LocalFolder != null)
                {
                    jsonDataFolders.Add("LocalFolder", node.DataFolders.LocalFolder);
                }
                jsonDataFolders.Add("CopyLocal", node.DataFolders.CopyLocal);

                json.Add("DataFolders", jsonDataFolders);
            }
            //OtherSoftware section
            if (node.OtherSoftware != null && node.OtherSoftware.Count > 0)
            {
                var arr = node.OtherSoftware.ToArray <object>();
                var jsonOtherSoftware = new JArray(arr);
                json.Add("OtherSoftware", jsonOtherSoftware);
            }
            //HardwareParams section
            if (node.StaticHardwareParams != null && node.StaticHardwareParams.Count > 0)
            {
                var arr = node.StaticHardwareParams.Select(x =>
                {
                    var obj = new JObject();
                    obj.Add("Key", x.Key);
                    obj.Add("Value", x.Value);
                    return(obj);
                }).ToArray <object>();

                var jsonHardwareParams = new JArray(arr);
                json.Add("HardwareParams", jsonHardwareParams);
            }

            return(json);
        }
示例#11
0
        public void OverrideNulls(ResourceNode defaultValues)
        {
            Init();

            if (defaultValues == null)
            {
                CheckConsistency();
                return;
            }

            //ResourceName { get;  set; }   //  private set
            //public string ProviderName;

            if (!SupportedArchitectures.Any() && defaultValues.SupportedArchitectures.Any())
            {
                SupportedArchitectures = defaultValues.SupportedArchitectures; // it's ok, because field is read-only
            }
            if (Services == null)
            {
                Services = new NodeServices(defaultValues.Services);
            }

            if (DataFolders == null)
            {
                DataFolders = new NodeDataFolders(defaultValues.DataFolders);
            }

            Credentials = new NodeCredentials
                          (
                userName: (Credentials.Username ?? defaultValues.Credentials.Username),
                password: (Credentials.Password ?? defaultValues.Credentials.Password),
                certFile: (Credentials.CertFile ?? defaultValues.Credentials.CertFile)
                          );

            if (CoresCount == 0 && defaultValues.CoresCount > 0)
            {
                CoresCount = defaultValues.CoresCount;
            }

            //if (CoresAvailable == 0 && defaultValues.CoresAvailable > 0) // todo : unnecessary?
            //CoresAvailable = defaultValues.CoresAvailable;

            if (TasksSubmissionLimit <= 1 && defaultValues.TasksSubmissionLimit > 1) // do not override if defaultValue == (0 or 1) or non-default value for node is set
            {
                TasksSubmissionLimit = defaultValues.TasksSubmissionLimit;
            }

            //if (SubmissionsAvailable == 0 && defaultValues.SubmissionsAvailable > 0) // todo : unnecessary?
            //SubmissionsAvailable = defaultValues.SubmissionsAvailable;

            if (defaultValues.StaticHardwareParams != null)
            {
                foreach (var key in defaultValues.StaticHardwareParams.Keys)
                {
                    if (!StaticHardwareParams.ContainsKey(key))
                    {
                        StaticHardwareParams[key] = defaultValues.StaticHardwareParams[key];
                    }
                }
            }

            if (!_packages.Any())
            {
                foreach (var pack in defaultValues._packages)
                {
                    _packages.Add(new PackageOnNode(pack));
                }
            }

            if (!_otherSoftware.Any())
            {
                foreach (var soft in defaultValues._otherSoftware)
                {
                    _otherSoftware.Add(soft);
                }
            }

            CheckConsistency();
        }
示例#12
0
 private string GetPartition(ResourceNode node)
 {
     return(node.StaticHardwareParams[PARTITION_NAME_PARAM]);
 }
        //private ConcurrentStack<>

        protected PackageOnNode PackageByName(ResourceNode node, string packageName)
        {
            return(node.Packages.First(p => String.Equals(p.Name, packageName, StringComparison.InvariantCultureIgnoreCase)));
        }
示例#14
0
 public virtual string ExecuteRun(ResourceNode node, string scriptPath)
 {
     return(SshExec(node, GetRunCommand(), scriptPath));
 }
示例#15
0
 public void InstallByTicket(InstallationTicket ticket, ResourceNode node, string localAddress)
 {
     //var installer = new WindowsInstallerImpl();
 }
 public void AddNewNodeToResource(string resourceName, ResourceNode node)
 {
     _resourceBase.AddNewNodeToResource(resourceName, node, GetUserIdFromHeader());
 }
示例#17
0
        public override NodeState GetNodeState(ResourceNode node)
        {
            var nodeState = new NodeState();

            var service = EntryPointProxy.GetClustersService();
            ClustersService.Code errCode;
            ClustersService.ClusterStateInfo clusterStateInfo;

            lock (_clustersServiceLock)
            {
                clusterStateInfo = service.GetClusterStateInfo(node.ResourceName, out errCode);
                // GetClusterStateInfoFast is probably buggy! (doesn't update immediatly after task launch)
            }

            if (errCode != ServiceProxies.ClustersService.Code.OperationSuccess || clusterStateInfo == null)
                throw new ClusterException(errCode);

            try
            {
                var nodeStateInfo = clusterStateInfo.Node.First(stateInfo =>
                    stateInfo != null &&
					!String.IsNullOrEmpty(stateInfo.DNSName) &&
					!String.IsNullOrEmpty(node.NodeName) &&
					stateInfo.DNSName == node.NodeName
                );

                if (nodeStateInfo == null || (nodeStateInfo.TaskID != null && nodeStateInfo.TaskID.Count > 0))
                    nodeState.CoresAvailable = 0;
                else
                    nodeState.CoresAvailable = node.CoresCount;
            }
            catch
            {
                nodeState.CoresAvailable = 0;
            }

            return nodeState;
        }
 public void AddNewNodeToResource(string resourceName, ResourceNode node)
 {
     _resourceBase.AddNewNodeToResource(resourceName, node, GetUserIdFromHeader());
 }
 public abstract NodeState GetNodeState(ResourceNode node);