Example #1
0
        private static RecentInvocationEntry Convert(IRecentFunctionEntry entity)
        {
            var snapshot = entity.ConvertToSnapshot();
            var metadata = RecentInvocationEntry.CreateMetadata(snapshot);

            return(RecentInvocationEntry.Create(metadata));
        }
        public void CreateOrUpdate(FunctionInstanceSnapshot snapshot, DateTimeOffset timestamp)
        {
            if (snapshot == null)
            {
                throw new ArgumentNullException("snapshot");
            }

            string innerId = CreateInnerId(timestamp, snapshot.Id);

            _store.CreateOrUpdate(innerId, RecentInvocationEntry.CreateMetadata(snapshot), String.Empty);
        }
        public IResultSegment <RecentInvocationEntry> Read(string relativePrefix, int maximumResults, string continuationToken)
        {
            BlobContinuationToken blobContinuationToken = BlobContinuationTokenSerializer.Deserialize(continuationToken);

            BlobResultSegment blobSegment;
            string            prefix = _directoryPrefix + relativePrefix;

            try
            {
                blobSegment = _container.ListBlobsSegmented(
                    prefix: prefix,
                    useFlatBlobListing: true,
                    blobListingDetails: BlobListingDetails.Metadata,
                    maxResults: maximumResults,
                    currentToken: blobContinuationToken,
                    options: null,
                    operationContext: null);
            }
            catch (StorageException exception)
            {
                if (exception.IsNotFound())
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }

            if (blobSegment == null)
            {
                return(null);
            }

            List <RecentInvocationEntry> results = new List <RecentInvocationEntry>();

            // Cast from IListBlobItem to ICloudBlob is safe due to useFlatBlobListing: true above.
            foreach (ICloudBlob blob in blobSegment.Results)
            {
                RecentInvocationEntry result = RecentInvocationEntry.Create(blob.Metadata);
                results.Add(result);
            }

            string nextContinuationToken = BlobContinuationTokenSerializer.Serialize(blobSegment.ContinuationToken);

            return(new ResultSegment <RecentInvocationEntry>(results, nextContinuationToken));
        }
Example #4
0
        public static RecentInvocationEntry Create(IDictionary <string, string> metadata)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            Guid?id = GetMetadataNullableGuid(metadata, IdKey);

            if (!id.HasValue)
            {
                throw new InvalidOperationException("Invalid recent function instance ID");
            }

            string         displayTitle = GetMetadataString(metadata, DisplayTitleKey);
            DateTimeOffset?startTime    = GetMetadataNullableDateTimeOffset(metadata, StartTimeKey);
            DateTimeOffset?endTime      = GetMetadataNullableDateTimeOffset(metadata, EndTimeKey);
            bool?          succeeded    = GetMetadataNullableBoolean(metadata, SucceededKey);

            string heartbeatSharedContainerName = GetMetadataString(metadata, HeartbeatSharedContainerNameKey);
            string heartbeatSharedDirectoryName = GetMetadataString(metadata, HeartbeatSharedDirectoryNameKey);
            string heartbeatInstanceBlobName    = GetMetadataString(metadata, HeartbeatInstanceBlobNameKey);
            int?   heartbeatExpirationInSeconds = GetMetadataNullableInt32(metadata, HeartbeatExpirationInSecondsKey);

            HeartbeatDescriptor heartbeat;

            if (heartbeatSharedContainerName != null && heartbeatSharedDirectoryName != null &&
                heartbeatInstanceBlobName != null && heartbeatExpirationInSeconds.HasValue)
            {
                heartbeat = new HeartbeatDescriptor
                {
                    SharedContainerName = heartbeatSharedContainerName,
                    SharedDirectoryName = heartbeatSharedDirectoryName,
                    InstanceBlobName    = heartbeatInstanceBlobName,
                    ExpirationInSeconds = heartbeatExpirationInSeconds.Value
                };
            }
            else
            {
                heartbeat = null;
            }

            var entry = new RecentInvocationEntry(id.Value, displayTitle, startTime, endTime, succeeded, heartbeat);

            entry.FunctionInstanceHeartbeatExpiry = GetMetadataNullableDateTime(metadata, FunctionInstanceHeartbeatExpiredTimeKey);
            return(entry);
        }
Example #5
0
        private async Task <IResultSegment <RecentInvocationEntry> > Read3Async(
            FunctionId functionId, int maximumResults, string continuationToken)
        {
            var queryParams = new RecentFunctionQuery
            {
                FunctionId     = functionId,
                MaximumResults = maximumResults,
                Start          = DateTime.MinValue,
                End            = DateTime.MaxValue
            };

            var segment = await _reader.GetRecentFunctionInstancesAsync(queryParams, continuationToken);

            var results = Array.ConvertAll(segment.Results, item =>
                                           RecentInvocationEntry.Create(RecentInvocationEntry.CreateMetadata(item.ConvertToSnapshot())));

            return(new ResultSegment <RecentInvocationEntry>(results, segment.ContinuationToken));
        }
 private static string CreateInnerId(Guid parentId, DateTimeOffset timestamp, Guid id)
 {
     return(DashboardBlobPrefixes.CreateByParentRelativePrefix(parentId) +
            RecentInvocationEntry.CreateBlobName(timestamp, id));
 }
        public void CreateOrUpdate(FunctionInstanceSnapshot snapshot, DateTimeOffset timestamp)
        {
            string innerId = CreateInnerId(snapshot.ParentId.Value, timestamp, snapshot.Id);

            _store.CreateOrUpdate(innerId, RecentInvocationEntry.CreateMetadata(snapshot), String.Empty);
        }
Example #8
0
 private static string CreateInnerId(WebJobRunIdentifier webJobRunId, DateTimeOffset timestamp, Guid id)
 {
     return(DashboardBlobPrefixes.CreateByJobRunRelativePrefix(webJobRunId) +
            RecentInvocationEntry.CreateBlobName(timestamp, id));
 }
Example #9
0
        public void CreateOrUpdate(FunctionInstanceSnapshot snapshot, WebJobRunIdentifier webJobRunId, DateTimeOffset timestamp)
        {
            string innerId = CreateInnerId(webJobRunId, timestamp, snapshot.Id);

            _store.CreateOrUpdate(innerId, RecentInvocationEntry.CreateMetadata(snapshot), String.Empty);
        }
 private static string CreateInnerId(DateTimeOffset timestamp, Guid id)
 {
     return(RecentInvocationEntry.CreateBlobName(timestamp, id));
 }
 IResultSegment<RecentInvocationEntry> IRecentInvocationIndexByJobRunReader.Read(WebJobRunIdentifier webJobRunId, int maximumResults, string continuationToken)
 {
     var x = new RecentInvocationEntry[0];
     return new ResultSegment<RecentInvocationEntry>(x, null);
 }
 IResultSegment<RecentInvocationEntry> IRecentInvocationIndexByParentReader.Read(Guid parentId, int maximumResults, string continuationToken)
 {
     var x = new RecentInvocationEntry[0];
     return new ResultSegment<RecentInvocationEntry>(x, null);
 }
        private InvocationLogViewModel CreateInvocationEntry(RecentInvocationEntry entry)
        {
            Debug.Assert(entry != null);

            var metadataSnapshot = new FunctionInstanceSnapshot();
            metadataSnapshot.Id = entry.Id;
            metadataSnapshot.DisplayTitle = entry.DisplayTitle;
            metadataSnapshot.StartTime = entry.StartTime;
            metadataSnapshot.EndTime = entry.EndTime;
            metadataSnapshot.Succeeded = entry.Succeeded;
            metadataSnapshot.Heartbeat = entry.Heartbeat;
            return new InvocationLogViewModel(metadataSnapshot, HostInstanceHasHeartbeat(metadataSnapshot));
        }
Example #14
0
        IResultSegment <RecentInvocationEntry> IRecentInvocationIndexByJobRunReader.Read(WebJobRunIdentifier webJobRunId, int maximumResults, string continuationToken)
        {
            var x = new RecentInvocationEntry[0];

            return(new ResultSegment <RecentInvocationEntry>(x, null));
        }
Example #15
0
        IResultSegment <RecentInvocationEntry> IRecentInvocationIndexByParentReader.Read(Guid parentId, int maximumResults, string continuationToken)
        {
            var x = new RecentInvocationEntry[0];

            return(new ResultSegment <RecentInvocationEntry>(x, null));
        }