Пример #1
0
        /// <summary>
        ///     saves the output from the resource usage object to an output file
        /// </summary>
        private void SaveResourceUsage(DrmaaResourceUsage rUsage, UnitOfWork unitOfWork)
        {
            // derive the resource usage filename
            string resourcesPath = string.Format("{0}.cluster", Path.Combine(unitOfWork.LoggingFolder, unitOfWork.LoggingStub));

            // save the resource usage to the output file
            try
            {
                using (StreamWriter writer = new StreamWriter(resourcesPath))
                {
                    writer.WriteLine(rUsage);
                }
            }
            catch (Exception)
            {
                // this is a non-fatal error
                Console.WriteLine("ERROR: Unable to write the resource usage file ({0}).", resourcesPath);
            }
        }
Пример #2
0
        /// <summary>
        ///     populates a resource usage data structure with the resource usage statistics from this job
        /// </summary>
        private DrmaaResourceUsage GetResourceUsage(IntPtr resourceUsage)
        {
            // initialize
            byte[] attributeBuffer                  = new byte[DrmaaAttrBuffer + 1];
            Dictionary<string, string> resourceData = new Dictionary<string, string>();

            // put all of the attributes in a dictionary
            while (SafeNativeMethods.drmaa_get_next_attr_value(resourceUsage, attributeBuffer, DrmaaAttrBuffer) !=
                   DrmaaErrnoNoMoreElements)
            {
                string[] cols = ConvertByteArrayToString(attributeBuffer).Split('=');
                resourceData[cols[0]] = (cols.Length == 2 ? cols[1] : string.Empty);
            }

            // populate the resource usage data structure
            DrmaaResourceUsage rusage = new DrmaaResourceUsage
                {
                    CpuTime              = GetRusageTimeSpan(resourceData, "cpu"),
                    UserTime             = GetRusageTimeSpan(resourceData, "ru_utime"),
                    IoWaitTime           = GetRusageTimeSpan(resourceData, "iow"),
                    WallTime             = GetRusageTimeSpan(resourceData, "ru_wallclock"),
                    SubmissionTime       = GetRusageDateTime(resourceData, "submission_time"),
                    StartTime            = GetRusageDateTime(resourceData, "start_time"),
                    EndTime              = GetRusageDateTime(resourceData, "end_time"),
                    IoDataTransferredGB  = GetRusageDouble(resourceData, "io"),
                    NumPageFaults        = GetRusageInt(resourceData, "ru_majflt"),
                    NumPageReclaims      = GetRusageInt(resourceData, "ru_minflt"),
                    VirtualMemory        = GetRusageDouble(resourceData, "vmem"),
                    MaximumVirtualMemory = GetRusageDouble(resourceData, "maxvmem"),
                    Priority             = GetRusageDouble(resourceData, "priority"),
                    ExitStatus           = GetRusageInt(resourceData, "exit_status"),
                    Signal               = GetRusageInt(resourceData, "signal")
                };

            return rusage;
        }