private IHttpActionResult GetIndexerLogs(PagingInfo pagingInfo)
        {
            IResultSegment <IndexerLogEntry> logs = _indexerLogReader.ReadWithoutDetails(
                pagingInfo.Limit,
                pagingInfo.ContinuationToken);

            IndexerLogEntriesViewModel viewModel = new IndexerLogEntriesViewModel();

            if (logs != null)
            {
                viewModel.Entries           = logs.Results;
                viewModel.ContinuationToken = logs.ContinuationToken;
            }

            return(Ok(viewModel));
        }
Beispiel #2
0
        public IHttpActionResult GetInvocationChildren(Guid functionInvocationId, [FromUri] PagingInfo pagingInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (pagingInfo == null)
            {
                return(BadRequest());
            }

            IResultSegment <RecentInvocationEntry> indexSegment = _recentInvocationsByParentReader.Read(
                functionInvocationId, pagingInfo.Limit, pagingInfo.ContinuationToken);

            return(Invocations(indexSegment));
        }
Beispiel #3
0
        private IHttpActionResult Invocations(IResultSegment <RecentInvocationEntry> indexSegment)
        {
            if (indexSegment == null)
            {
                return(Ok(new InvocationLogSegment {
                    Entries = new InvocationLogViewModel[0]
                }));
            }

            InvocationLogSegment results = new InvocationLogSegment
            {
                Entries           = CreateInvocationEntries(indexSegment.Results),
                ContinuationToken = indexSegment.ContinuationToken
            };

            return(Ok(results));
        }
Beispiel #4
0
        private IHttpActionResult GetFunctionsInJob(WebJobTypes webJobType, string jobName, string runId, [FromUri] PagingInfo pagingInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (pagingInfo == null)
            {
                return(BadRequest());
            }

            var runIdentifier = new WebJobRunIdentifier(Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME"),
                                                        (InternalWebJobTypes)webJobType, jobName, runId);

            IResultSegment <RecentInvocationEntry> indexSegment = _recentInvocationsByJobRunReader.Read(runIdentifier,
                                                                                                        pagingInfo.Limit, pagingInfo.ContinuationToken);
            InvocationLogSegment results;

            if (indexSegment != null)
            {
                results = new InvocationLogSegment
                {
                    Entries           = CreateInvocationEntries(indexSegment.Results),
                    ContinuationToken = indexSegment.ContinuationToken
                };
            }
            else
            {
                results = new InvocationLogSegment
                {
                    IsOldHost = OnlyBeta1HostExists(alreadyFoundNoNewerEntries: false)
                };
            }

            return(Ok(results));
        }
Beispiel #5
0
        public IHttpActionResult GetInvocationsForFunction(string functionId, [FromUri] PagingInfo pagingInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (pagingInfo == null)
            {
                return(BadRequest());
            }

            var func = _functionLookup.Read(functionId);

            if (func == null)
            {
                return(NotFound());
            }

            IResultSegment <RecentInvocationEntry> indexSegment = _recentInvocationsByFunctionReader.Read(func.Id,
                                                                                                          pagingInfo.Limit, pagingInfo.ContinuationToken);

            return(Invocations(indexSegment));
        }
Beispiel #6
0
        public IHttpActionResult GetFunctionDefinitions([FromUri] PagingInfo pagingInfo)
        {
            if (pagingInfo == null)
            {
                throw new ArgumentNullException("pagingInfo");
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            IResultSegment <FunctionIndexEntry> indexSegment = _functionIndexReader.Read(pagingInfo.Limit,
                                                                                         pagingInfo.ContinuationToken);

            var  model = new FunctionStatisticsSegment();
            bool foundItem;

            if (indexSegment != null && indexSegment.Results != null)
            {
                IEnumerable <FunctionStatisticsViewModel> query = indexSegment.Results
                                                                  .Select(entry => new FunctionStatisticsViewModel
                {
                    FunctionId       = entry.Id,
                    FunctionFullName = entry.FullName,
                    FunctionName     = entry.ShortName,
                    IsRunning        = HostHasHeartbeat(entry).GetValueOrDefault(true),
                    FailedCount      = 0,
                    SuccessCount     = 0
                });

                model.Entries           = query.ToArray();
                foundItem               = query.Any();
                model.ContinuationToken = indexSegment.ContinuationToken;
            }
            else
            {
                foundItem = false;
            }

            if (pagingInfo.ContinuationToken == null)
            {
                // For requests for the first page only, also provide a version to enable polling for updates.
                model.VersionUtc = _functionIndexReader.GetCurrentVersion().UtcDateTime;
            }

            model.StorageAccountName = _account.Credentials.AccountName;

            if (!foundItem)
            {
                model.IsOldHost = OnlyBeta1HostExists(alreadyFoundNoNewerEntries: true);
            }

            if (model.Entries != null)
            {
                foreach (FunctionStatisticsViewModel statisticsModel in model.Entries)
                {
                    if (statisticsModel == null)
                    {
                        continue;
                    }

                    Tuple <int, int> counts = GetStatistics(statisticsModel.FunctionId);
                    statisticsModel.SuccessCount = counts.Item1;
                    statisticsModel.FailedCount  = counts.Item2;
                }
            }

            return(Ok(model));
        }
        private IHttpActionResult Invocations(IResultSegment<RecentInvocationEntry> indexSegment)
        {
            if (indexSegment == null)
            {
                return Ok(new InvocationLogSegment { Entries = new InvocationLogViewModel[0] });
            }

            InvocationLogSegment results = new InvocationLogSegment
            {
                Entries = CreateInvocationEntries(indexSegment.Results),
                ContinuationToken = indexSegment.ContinuationToken
            };

            return Ok(results);
        }