Exemplo n.º 1
0
        /// <summary>
        /// get the job metrics, not like JobState, this might contain huge number of metrics data.
        /// </summary>
        /// <param name="metricName">the name of metric</param>
        /// <param name="startIndex">start index of the page</param>
        /// <param name="pageSize">the size of page</param>
        /// <returns>job metrics, by page</returns>
        public override Task <GetJobMetricsReply> GetJobMetrics(GetJobMetricsRequest request, ServerCallContext context)
        {
            double[] result = null;

            if (this.jobMetrics != null && this.jobMetrics.ContainsKey(request.MetricName) && this.jobMetrics[request.MetricName].Length > request.StartIndex)
            {
                result = this.jobMetrics[request.MetricName].Skip(request.StartIndex).Take(Math.Min(request.PageSize, this.jobMetrics[request.MetricName].Length - request.StartIndex)).ToArray();
            }

            var reply = new GetJobMetricsReply();

            reply.JobMetrics.AddRange(result);
            return(Task.FromResult(reply));
        }
Exemplo n.º 2
0
        /// <summary>
        /// get the job metrics, not like JobState, this might contain huge number of metrics data.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="context">The context.</param>
        /// <returns>job metrics, by page</returns>
        public override async Task <GetJobMetricsReply> GetJobMetrics(GetJobMetricsRequest request, ServerCallContext context)
        {
            var temp = await this.RunOnAllClients(
                async (c) => await c.GetJobMetricsAsync(new JobRunnerProto.GetJobMetricsRequest()
            {
                MetricName = request.MetricName,
                StartIndex = request.StartIndex,
                PageSize   = request.PageSize
            }))
                       .ConfigureAwait(false);

            var reply = new GetJobMetricsReply();

            reply.JobMetrics.AddRange(temp.Where(t => t != null).SelectMany(t => t.JobMetrics));

            return(reply);
        }