Exemplo n.º 1
0
        public override AgentsDesired GetAgentsDesired()
        {
            int agentCount  = 0;
            int jobCount    = 0;
            int serverCount = 0;

            string SQL = @"
                SELECT Count(CAI.[CaseArtifactID]) 
                FROM   [ContentAnalystIndexJob] CAI WITH(NOLOCK)
                       INNER JOIN [Case] C WITH(NOLOCK)
                               ON CAI.[CaseArtifactID] = C.[ArtifactID] 
                WHERE  C.[ResourceGroupArtifactID] = @ResourceGroupArtifactID 
                       AND [Status] IN ( 0, 1 )";

            SqlParameter poolIdParam = new SqlParameter("@ResourceGroupArtifactID", System.Data.SqlDbType.Int)
            {
                Value = AgentAgentResourcePool
            };

            jobCount    = _eddsDbContext.ExecuteSqlStatementAsScalar <int>(SQL, new SqlParameter[] { poolIdParam });
            serverCount = _environment.GetAnalyticsServerCountByResourcePool(AgentAgentResourcePool);

            if (jobCount < serverCount)
            {
                agentCount = jobCount;
            }
            else
            {
                agentCount = serverCount;
            }

            return(new AgentsDesired()
            {
                Guid = Guid,
                RespectsResourcePool = RespectsResourcePool,
                Count = agentCount
            });
        }