Ejemplo n.º 1
0
        public async Task <List <IPerformance> > GetPerformances(PerformanceFilterIOption option)
        {
            string where = " where  CreateTime >= @Start AND CreateTime < @End ";

            if (!option.Service.IsEmpty())
            {
                where = where + " AND Service = @Service ";
            }

            if (!option.Instance.IsEmpty())
            {
                where = where + " AND Instance = @Instance ";
            }


            string sql = $@" Select * From ""{Prefix}Performance"" " + where;

            TraceLogSql(sql);

            var result = await LoggingSqlOperation(async connection => (

                                                       await connection.QueryAsync <Performance>(sql, option)

                                                       ));

            return(result.Select(x => x as IPerformance).ToList());
        }
Ejemplo n.º 2
0
        public async Task <string> GetPerformanceChart(PerformanceFilterIOption option)
        {
            if (option.Service.IsEmpty() || option.Service == "ALL")
            {
                option.Service = "";
            }

            if (option.Instance.IsEmpty() || option.Instance == "ALL")
            {
                option.Instance = "";
            }


            List <Performance> performances = new List <Performance>();

            if (option.Start > option.End)
            {
                return(Json(new HttpResultEntity(-1, _lang.TimeRangeFormatError, null)));
            }

            int Times = ((option.End - option.Start).TotalSeconds.ToInt() / option.TimeFormat);

            if (Times >= 60)
            {
                Times = 60;
            }

            var list = await _storage.GetPerformances(option);

            for (int i = 0; i < Times; i++)
            {
                var items = list.Where(x => x.CreateTime >= option.End.AddSeconds(-(i + 1) * option.TimeFormat) && x.CreateTime < option.End.AddSeconds(-i * option.TimeFormat));

                if (!items.Any())
                {
                    continue;
                }

                performances.Insert(0, new Performance {
                    Id                 = option.End.AddSeconds(-i * option.TimeFormat).ToString("mm:ss"),
                    GCGen0             = items.Average(x => x.GCGen0).ToInt(),
                    GCGen1             = items.Average(x => x.GCGen1).ToInt(),
                    GCGen2             = items.Average(x => x.GCGen2).ToInt(),
                    HeapMemory         = items.Average(x => x.HeapMemory).ToString().ToDouble(2),
                    ProcessCPU         = items.Average(x => x.ProcessCPU).ToString().ToDouble(2),
                    ProcessMemory      = items.Average(x => x.ProcessMemory).ToString().ToDouble(2),
                    ThreadCount        = items.Average(x => x.ThreadCount).ToInt(),
                    PendingThreadCount = items.Average(x => x.PendingThreadCount).ToInt()
                });
            }

            return(Json(new HttpResultEntity(1, "ok", performances)));
        }
Ejemplo n.º 3
0
        public async Task <List <IPerformance> > GetPerformances(PerformanceFilterIOption option)
        {
            List <IPerformance> performances = new List <IPerformance>();

            var response = await Client.SearchAsync <Performance>(a => a.Index(GetIndexName <Performance>())
                                                                  .Query(b => b.HasDateWhere(option.Start, option.End) && b.Term(c => c.Instance, option.Instance) && b.Term(c => c.Service, option.Service)));

            if (response != null && response.IsValid)
            {
                performances = response.Documents.Select(x => x as IPerformance).ToList();
            }

            return(performances);
        }
Ejemplo n.º 4
0
        public async Task <string> GetPerformanceChart(PerformanceFilterIOption option)
        {
            if (option.Start > option.End)
            {
                return(Json(new HttpResultEntity(-1, _lang.TimeRangeFormatError, null)));
            }

            if (option.TimeFormat == 10)
            {
                if (option.Start <= option.End.AddSeconds(-10 * 60))
                {
                    option.Start = option.End.AddSeconds(-10 * 60);
                }
            }

            var list = await _storage.GetPerformances(option);

            return(Json(new HttpResultEntity(1, "ok", list)));
        }
Ejemplo n.º 5
0
        public async Task <List <IPerformance> > GetPerformances(PerformanceFilterIOption option)
        {
            string where = $" where  CreateTime >= to_date('{option.Start:yyyy-MM-dd HH:mm:ss}','YYYY-MM-DD hh24:mi:ss') AND CreateTime < to_date('{option.End:yyyy-MM-dd HH:mm:ss}','YYYY-MM-DD hh24:mi:ss')  ";

            if (!option.Service.IsEmpty())
            {
                where = where + " AND Service = :Service ";
            }

            if (!option.Instance.IsEmpty())
            {
                where = where + " AND Instance = :Instance ";
            }


            string sql = " Select * From Performance " + where;

            TraceLogSql(sql);

            var result = await LoggingSqlOperation(async _ => await _.QueryAsync <Performance>(sql, option));

            return(result.Select(x => x as IPerformance).ToList());
        }
 public Task <List <IPerformance> > GetPerformances(PerformanceFilterIOption option)
 {
     throw new NotImplementedException();
 }