Ejemplo n.º 1
0
 public ClusterException(ClustersService.Code errorCode)
     : this(String.Format(
                CONST.Dirty <string>("Ошибка интегратора управления кластерами: {0}"), errorCode.ToString()
                ))
 {
 }
Ejemplo n.º 2
0
        public override string Run(ulong taskId, IncarnationParams incarnation, Resource resource, IEnumerable <NodeConfig> nodesConfig)
        {
            string providedTaskId = taskId.ToString();

            var node = GetDefaultNodeSettings(resource, nodesConfig);
            var pack = node.PackageByName(incarnation.PackageName);

            var service = EntryPointProxy.GetClustersService();

            ClustersService.Code     errCode;
            ClustersService.TaskInfo taskInfo;

            lock (_clustersServiceLock)
            {
                taskInfo = service.GetTaskState(providedTaskId, out errCode);
            }

            if (errCode != ServiceProxies.ClustersService.Code.OperationSuccess)
            {
                throw new ClusterException(errCode);
            }

            taskInfo.ClusterName = resource.ResourceName;
            taskInfo.CommandLine = String.Format(incarnation.CommandLine, pack.AppPath);
            taskInfo.PackageName = incarnation.PackageName.ToUpperInvariant();

            /*
             * if (!String.IsNullOrEmpty(incarnation.StdInFile))
             *  taskInfo.StdinFileName = incarnation.StdInFile;
             * else
             *  taskInfo.StdinFileName = "";
             *
             * if (!String.IsNullOrEmpty(incarnation.StdOutFile))
             *  taskInfo.StdoutFileName = incarnation.StdOutFile;
             * else
             *  taskInfo.StdoutFileName = "";
             */

            // cores on nodes: {n, 0, 0} -> {n}
            taskInfo.NumberOfCores = new ClustersService.ArrayOfInt();
            taskInfo.NumberOfCores.AddRange(nodesConfig.Where(conf => conf.Cores > 0).Select(conf => conf.Cores));

            taskInfo.NumberOfNodes = taskInfo.NumberOfCores.Count;

            var logStream = new StringWriter();

            logStream.WriteLine("Задача {0} ({1}) запускается на кластере {2}",
                                taskInfo.TaskID, taskInfo.PackageName, taskInfo.ClusterName);
            logStream.WriteLine("     Папка с файлами расчета: {0}", taskInfo.FTPPath);
            logStream.WriteLine("     Строка запуска: {0}", taskInfo.CommandLine);
            logStream.WriteLine("     Перенаправление вывода: {0}", taskInfo.StdoutFileName);
            logStream.Write("     Количество ядер (по каждому узлу): ");
            foreach (int coresCount in taskInfo.NumberOfCores)
            {
                logStream.Write("{0} ", coresCount);
            }

            Log.Info(logStream.ToString());

            lock (_clustersServiceLock)
            {
                errCode = service.ExecuteTask(taskInfo);
            }

            if (errCode != ServiceProxies.ClustersService.Code.OperationSuccess)
            {
                throw new ClusterException(String.Format(
                                               CONST.Dirty <string>("Ошибка интегратора управления кластерами при запуске задачи: {0}"), errCode.ToString()
                                               ));
            }

            return(providedTaskId);
        }