Esempio n. 1
0
        public static List <Machine> MachineGroup(ComputingPower computingPower, bool excludeLocalhost = true)
        {
            var machines = List.Where(machine => machine.ComputingPower == computingPower);

            if (excludeLocalhost)
            {
                machines = machines.Where(machine => machine.Name != "localhost");
            }

            return(machines.ToList());
        }
Esempio n. 2
0
        public List <string> Generate(Distribution servicesDistribution)
        {
            InitializeAvailableServicesList();
            // the below list is utilized only in case of non-random distribution
            var correlationList = new List <int>();

            if (servicesDistribution != Distribution.Random)
            {
                correlationList = Services.GetServicesListByCorrelation(servicesDistribution);
            }
            var outputList = new List <string>();

            for (int nodeId = 0; nodeId < NodesCount; nodeId++)
            {
                var nodeProperties = new List <string>();
                // node id
                nodeProperties.Add(nodeId.ToString());
                // computing power
                nodeProperties.Add(ComputingPower.ToString());
                // parallel computing potential
                nodeProperties.Add(ParallelComputingPotential.ToString());
                // liczba obsługiwanych węzłów
                nodeProperties.Add(ServicesPerNodeCount.ToString());
                var assignedServices = new List <int>();
                while (assignedServices.Count != ServicesPerNodeCount)
                {
                    int serviceId;
                    if (servicesDistribution == Distribution.Random)
                    {
                        serviceId = random.Next(Services.Count);
                    }
                    else
                    {
                        serviceId = correlationList[serviceRank];
                        serviceRank++;
                    }

                    if (!assignedServices.Contains(serviceId) && IsServiceAvailable(serviceId))
                    {
                        assignedServices.Add(serviceId);
                        SetServiceUnavailability(serviceId);
                    }
                }
                foreach (var serviceId in assignedServices)
                {
                    nodeProperties.Add(serviceId.ToString());
                }
                outputList.Add(String.Join(" ", nodeProperties));
            }
            return(outputList);
        }
Esempio n. 3
0
        /// <summary>
        /// 根据用户id查账户实体
        /// sj
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <returns></returns>
        public ComputingPower GetComputingPowerByLogName(string logName)
        {
            ComputingPower data = new ComputingPower();

            try
            {
                using (var db = BaseDal.ReadOnlySanNongDunConn())
                {
                    data = db.Query <ComputingPower>(SqlQuery <ComputingPower> .Builder(db).AndWhere(x => x.LoginName, OperationMethod.Equal, logName)).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(typeof(ComputingPowerDal), ex);
                data = null;
            }
            return(data);
        }
Esempio n. 4
0
        /// <summary>
        /// 修改账户
        /// sj
        /// </summary>
        /// <param name="customerAccount">修改账户实体</param>
        /// <returns></returns>
        public bool UpdateComputingPower(ComputingPower computingPower)
        {
            bool result = false;

            try
            {
                if (computingPower != null)
                {
                    using (var db = BaseDal.WriteSanNongDunDbBase())
                    {
                        result = db.Update(computingPower);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(ComputingPowerDal), "UpdateComputingPower", Engineer.ccc, computingPower, ex);
            }
            return(result);
        }