/// <summary>
        /// read the config and initialize. Can throw exceptions which will be cleanly caught by
        /// the parent
        /// </summary>
        /// <param name="p">parent to use for callbacks</param>
        /// <param name="name">name of this group in the service</param>
        /// <param name="config">element describing configuration parameters</param>
        public void Initialize(IServiceManager p, string name, XElement config)
        {
            parent       = p;
            logger       = parent.Logger;
            groupName    = name;
            shuttingDown = false;

            // read the target number of processes out of the config. This defaults to 1
            // if not otherwise specified
            int numberOfProcesses = 1;
            var nProcAttr         = config.Attribute("numberOfProcesses");

            if (nProcAttr != null)
            {
                // don't worry about throwing exceptions if this is malformed
                numberOfProcesses = int.Parse(nProcAttr.Value);
            }

            // read the target number of restarts for each process out of the config. This defaults to 5
            // if not otherwise specified
            numberOfVersions = 5;
            var nRestartAttr = config.Attribute("numberOfVersions");

            if (nRestartAttr != null)
            {
                // don't worry about throwing exceptions if this is malformed
                numberOfVersions = int.Parse(nRestartAttr.Value);
            }

            // make a logical process object for each process we are managing
            processes = new LocalProcess[numberOfProcesses];
            for (int i = 0; i < processes.Length; ++i)
            {
                processes[i] = new LocalProcess(this, i);
            }

            // read the descriptor that we will use to create physical processes.
            // don't worry about throwing exceptions if this isn't present or is
            // malformed
            var processElement = config.Descendants("Process").Single();

            processDetails = new ExeDetails();
            processDetails.ReadFromConfig(processElement, logger);
        }
Exemple #2
0
        /// <summary>
        /// read the config and initialize. Can throw exceptions which will be cleanly caught by
        /// the parent
        /// </summary>
        /// <param name="p">parent to use for callbacks</param>
        /// <param name="name">name of this group in the service</param>
        /// <param name="config">element describing configuration parameters</param>
        public void Initialize(IServiceManager p, string name, XElement config)
        {
            parent    = p;
            logger    = parent.Logger;
            groupName = name;

            // read the target number of processes out of the config. This defaults to -1
            // if not otherwise specified, which means use all the machines in the cluster
            maxProcesses = -1;
            var nProcAttr = config.Attribute("maxProcesses");

            if (nProcAttr != null)
            {
                // don't worry about throwing exceptions if this is malformed
                maxProcesses = int.Parse(nProcAttr.Value);
            }

            // read the target number of failures out of the config. These default to -1
            // if not otherwise specified, which means tolerate arbitrary failures
            maxFailuresPerNode = -1;
            var nFPNAttr = config.Attribute("maxFailuresPerNode");

            if (nFPNAttr != null)
            {
                // don't worry about throwing exceptions if this is malformed
                maxFailuresPerNode = int.Parse(nFPNAttr.Value);
            }
            maxTotalFailures = -1;
            var nTFAttr = config.Attribute("maxTotalFailures");

            if (nTFAttr != null)
            {
                // don't worry about throwing exceptions if this is malformed
                maxTotalFailures = int.Parse(nTFAttr.Value);
            }
            // read the amount of memory to request per container from the config
            // it defaults to -1
            workerMemoryInMB = -1;
            var workerMemAttr = config.Attribute("workerMemoryInMB");

            if (workerMemAttr != null)
            {
                workerMemoryInMB = int.Parse(workerMemAttr.Value);
            }

            // read the descriptor that we will use to create physical processes.
            // don't worry about throwing exceptions if this isn't present or is
            // malformed
            var processElement = config.Descendants("Process").Single();

            processDetails = new ExeDetails();
            processDetails.ReadFromConfig(processElement, logger);

            foreach (var rg in processDetails.resources)
            {
                if (!(rg is HdfsResources))
                {
                    throw new ApplicationException("All YARN process resources must reside in HDFS: " + rg.ToString());
                }
            }
        }