private void UpdateJobStatistic(JobStatistic oldStat, JobStatistic newStat) { oldStat.State = newStat.State; oldStat.StartTime = newStat.StartTime; oldStat.EndTime = newStat.EndTime; oldStat.SubmitTime = newStat.SubmitTime; oldStat.TotalRunningTimeInSecond = newStat.TotalRunningTimeInSecond; oldStat.PNSeconds = newStat.PNSeconds; }
private JobStatistic GetJobStatistic(JobInfo job) { double?pnSeconds = null; try { // for job that had been run less than 30 seconds, we don't count it now. if (job.TotalRunningTime.TotalSeconds < 1.0 || (job.TotalRunningTime.TotalSeconds < 30.0 && !IsJobStateFinal(job.State))) { return(null); } var jobStatistics = VC.GetJobStatistics(job.ID.ToString()); pnSeconds = jobStatistics.VertexStats.Take(1).Sum(v => v.TotalTimeCompleted.TotalSeconds); JobStatistic stat = new JobStatistic() { Id = job.ID, Name = job.Name, HyperLink = string.Format("{0}/_Jobs/{1}", _httpUrlOfVirtualCluster, job.ID), UserName = job.UserName, TrueUserName = GetTrueUserName(job), State = (int)job.State, SubmitTime = job.SubmitTime, StartTime = job.StartTime, EndTime = job.EndTime, TotalRunningTimeInSecond = (long?)job.TotalRunningTime.TotalSeconds, PNSeconds = (long?)pnSeconds, }; return(stat); } catch (Exception ex) { Console.WriteLine("Failed to get statistics for job. ID: {0}. Exception: {1}", job.ID, ex); Console.WriteLine("JobInfo: {0} {1} {2} {3} {4} {5} {6}", job.Name, job.UserName, job.State, job.SubmitTime, job.StartTime, job.TotalRunningTime, pnSeconds); } return(null); }
public static IList <JobStatistic> GetJobStatistic() { IList <JobStatistic> totailwork = new List <JobStatistic>(); string sql = "SELECT COUNT(id), worker FROM jobs WHERE jobStatus = 1 group by worker"; DataTable dt = SqliteHelper.ExecuteTable(sql); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { JobStatistic js = new JobStatistic(); string workerId = dt.Rows[i][1].ToString(); if (workerId != null && workerId.Length > 0) { js.Worker = Sys_roleService.GetUserByiId(int.Parse(workerId)); } js.ClosedJob = Convert.ToInt32(dt.Rows[i][0]); totailwork.Add(js); } } return(totailwork); }