public void Bug1771070_1771072_JobAndPoolLifetimeStats()
        {
            Action test = () =>
            {
                using (BatchClient batchCli = TestUtilities.OpenBatchClientAsync(TestUtilities.GetCredentialsFromEnvironment()).Result)
                {
                    JobStatistics  jobStatistics  = batchCli.JobOperations.GetAllJobsLifetimeStatistics();
                    PoolStatistics poolStatistics = batchCli.PoolOperations.GetAllPoolsLifetimeStatistics();

                    Assert.NotNull(jobStatistics);
                    Assert.NotNull(poolStatistics);

                    //Since we cannot really validate that the stats returned by the service are correct, the best we can do is make sure we get some

                    //Dump a few properties from each stats bag to make sure they are populated
                    this.testOutputHelper.WriteLine("JobScheduleStatistics.StartTime: {0}", jobStatistics.StartTime);
                    this.testOutputHelper.WriteLine("JobScheduleStatistics.LastUpdateTime: {0}", jobStatistics.LastUpdateTime);
                    this.testOutputHelper.WriteLine("JobScheduleStatistics.NumSucceededTasks: {0}", jobStatistics.SucceededTaskCount);
                    this.testOutputHelper.WriteLine("JobScheduleStatistics.UserCpuTime: {0}", jobStatistics.UserCpuTime);

                    this.testOutputHelper.WriteLine("PoolStatistics.StartTime: {0}", poolStatistics.StartTime);
                    this.testOutputHelper.WriteLine("PoolStatistics.LastUpdateTime: {0}", poolStatistics.LastUpdateTime);
                    this.testOutputHelper.WriteLine("PoolStatistics.ResourceStatistics.AvgMemory: {0}", poolStatistics.ResourceStatistics.AverageMemoryGiB);
                    this.testOutputHelper.WriteLine("PoolStatistics.UsageStatistics.DedicatedCoreTime: {0}", poolStatistics.UsageStatistics.DedicatedCoreTime);
                }
            };

            SynchronizationContextHelper.RunTest(test, TestTimeout);
        }
        public PSPoolStatistics ListAllPoolsLifetimeStatistics(BatchAccountContext context, IEnumerable <BatchClientBehavior> additionBehaviors = null)
        {
            PoolOperations   poolOperations   = context.BatchOMClient.PoolOperations;
            PoolStatistics   poolStatistics   = poolOperations.GetAllPoolsLifetimeStatistics(additionBehaviors);
            PSPoolStatistics psPoolStatistics = new PSPoolStatistics(poolStatistics);

            return(psPoolStatistics);
        }
示例#3
0
        /// <summary>
        /// Gets all pools lifetime summary statistics
        /// </summary>
        /// <param name="context">The account to use.</param>
        /// <param name="additionBehaviors">Additional client behaviors to perform.</param>
        public PSPoolStatistics GetAllPoolsLifetimeStatistics(BatchAccountContext context, IEnumerable <BatchClientBehavior> additionBehaviors = null)
        {
            PoolOperations poolOperations = context.BatchOMClient.PoolOperations;

            WriteVerbose(string.Format(Resources.GetAllPoolsLifetimeStatistics));

            PoolStatistics   poolStatistics   = poolOperations.GetAllLifetimeStatistics(additionBehaviors);
            PSPoolStatistics psPoolStatistics = new PSPoolStatistics(poolStatistics);

            return(psPoolStatistics);
        }
        public async Task <List <PoolStatistics> > GetPoolsAndStatisticOfCategory(int categoryId)
        {
            List <Pool> categoryPools = await _DaoPool.GetPoolsByCategory(categoryId);

            List <PoolStatistics> response = new List <PoolStatistics>();

            foreach (var p in categoryPools)
            {
                PoolStatistics             ps = new PoolStatistics();
                List <PoolTeamStatisctics> poolsStatistics = new List <PoolTeamStatisctics>();
                poolsStatistics = await _DaoPool.GetPoolTeamsAndStatistics(p.Id);

                ps.poolId   = p.Id;
                ps.poolName = p.Name;
                List <int> teamsWithStatistics = new List <int>();
                if (poolsStatistics != null && poolsStatistics.Count > 0)
                {
                    //ps.teamsStatistics = poolsStatistics;
                    foreach (var x in poolsStatistics)
                    {
                        teamsWithStatistics.Add(x.teamId);
                    }
                }
                ps.teamsStatistics = poolsStatistics;

                //Filling the list with all the pool teams statisctis (Those teams that doesn´t have statistics already)
                List <Team> poolTeams = await _DaoTeam.GetTeamsPool(p.Id);

                if (poolTeams != null && poolTeams.Count > 0 && poolTeams.Count != teamsWithStatistics.Count)
                {
                    foreach (var t in poolTeams)
                    {
                        if (!teamsWithStatistics.Contains(t.TeamId))
                        {
                            var tmp = new PoolTeamStatisctics()
                            {
                                teamId         = t.TeamId,
                                teamName       = t.Name,
                                played         = 0,
                                won            = 0,
                                lost           = 0,
                                scored         = 0,
                                against        = 0,
                                goalDifference = 0
                            };
                            poolsStatistics.Add(tmp);
                        }
                    }
                }
                response.Add(ps);
            }
            return(response);
        }