Beispiel #1
0
        private InvocationLogViewModel CreateInvocationEntry(Guid id)
        {
            InvocationLogViewModel invocationModel = null;
            string cacheKey = "INVOCATION_MODEL_" + id;

            if (HttpRuntime.Cache != null)
            {
                invocationModel = HttpRuntime.Cache.Get(cacheKey) as InvocationLogViewModel;
                if (invocationModel == null)
                {
                    var invocation = _functionInstanceLookup.Lookup(id);
                    if (invocation != null)
                    {
                        invocationModel = new InvocationLogViewModel(invocation, HostInstanceHasHeartbeat(invocation));
                        if (invocationModel.IsFinal())
                        {
                            HttpRuntime.Cache.Insert(cacheKey, invocationModel, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(30));
                        }
                    }
                }
            }
            else
            {
                var invocation = _functionInstanceLookup.Lookup(id);
                if (invocation != null)
                {
                    invocationModel = new InvocationLogViewModel(invocation, HostInstanceHasHeartbeat(invocation));
                }
            }

            return(invocationModel);
        }
Beispiel #2
0
        public IHttpActionResult Output(string id, int start = 0)
        {
            // Parse the ID
            Guid funcId;

            if (!Guid.TryParse(id, out funcId))
            {
                return(BadRequest());
            }

            // Get the invocation log
            var instance = _functionInstanceLookup.Lookup(funcId);

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

            if (instance.InlineOutputText != null)
            {
                return(new TextResult(instance.InlineOutputText, Request));
            }

            LocalBlobDescriptor outputBlobDescriptor = instance.OutputBlob;

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

            CloudBlockBlob blob = outputBlobDescriptor.GetBlockBlob(_account);

            var sb     = new StringBuilder();
            var stream = blob.OpenRead();

            try
            {
                using (var sr = new StreamReader(stream))
                {
                    stream = null;
                    string line = sr.ReadLine();
                    for (int i = 0; line != null; i++, line = sr.ReadLine())
                    {
                        if (i >= start)
                        {
                            sb.AppendLine(line);
                        }
                    }
                }
            }
            finally
            {
                if (stream != null)
                {
                    stream.Dispose();
                }
            }

            return(new TextResult(sb.ToString(), Request));
        }
        private FunctionSnapshot GetFunctionFromInstance(string id, out Guid parsed, out FunctionInstanceSnapshot snapshot)
        {
            if (!Guid.TryParse(id, out parsed))
            {
                snapshot = null;
                return(null);
            }

            snapshot = _functionInstanceLookup.Lookup(parsed);

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

            return(GetFunction(snapshot.FunctionId));
        }
        private DateTimeOffset?GetFunctionCompletedTime(Guid functionInstanceId)
        {
            FunctionInstanceSnapshot primaryLog = _functionInstanceLookup.Lookup(functionInstanceId);

            return(primaryLog != null ? primaryLog.EndTime : null);
        }