我正在测试持久功能如何扇入/扇出以及如何扩展我的代码。对于这个例子,我模拟了许多短期运行的、CPU 密集型的操作。
并非所有活动似乎都已完成,我不确定为什么或在哪里查找失败日志。
请看下面的代码:
public static class ParallelLoadDurable
{
[FunctionName("ParallelLoadDurable")]
public static async Task<string> RunOrchestrator(
[OrchestrationTrigger] DurableOrchestrationContext context, ILogger log)
{
DateTime StartTimer = DateTime.Now;
int counter = 0;
var parallelTasks = new List<Task<string>>();
var retryOptions = new RetryOptions(
firstRetryInterval: TimeSpan.FromSeconds(5),
maxNumberOfAttempts: 5);
for (int i = 0; i < 1000; i++)
{
counter += 1;
DurablePassModel DPM = new DurablePassModel()
{
LoopNum = counter,
StartedOn = StartTimer
};
Task<string> task = context.CallActivityWithRetryAsync<string>("ParallelLoadDurable_Hello", retryOptions, DPM);
parallelTasks.Add(task);
}
await Task.WhenAll(parallelTasks);
DateTime CompleteTime = DateTime.Now;
TimeSpan TS = CompleteTime.Subtract(StartTimer);
string ret = $"PROCESS COMPLETED: {counter} times for: {TS.TotalMilliseconds} ms.";
log.LogInformation(ret);
return ret;
}
[FunctionName("ParallelLoadDurable_Hello")]
public static string SayHello([ActivityTrigger] DurablePassModel val, ILogger log)
{
log.LogInformation($"Starting child function num {val.LoopNum.ToString()}.");
DateTime StartTimer = DateTime.Now;
var endTime = DateTime.Now.AddSeconds(10);
while (true)
{
if (DateTime.Now >= endTime)
break;
}
DateTime CompleteTime = DateTime.Now;
TimeSpan TS = CompleteTime.Subtract(val.StartedOn);
TimeSpan TSThis = CompleteTime.Subtract(StartTimer);
string ret = $"Ran this for: {TSThis.TotalSeconds}s - LoopNum: {val.LoopNum} - total time: {TS.TotalSeconds}s.";
log.LogInformation(ret);
return ret;
}
[FunctionName("ParallelLoadDurable_HttpStart")]
public static async Task<HttpResponseMessage> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")]HttpRequestMessage req,
[OrchestrationClient]DurableOrchestrationClient starter,
ILogger log)
{
// Function input comes from the request content.
string instanceId = await starter.StartNewAsync("ParallelLoadDurable", null);
log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
return starter.CreateCheckStatusResponse(req, instanceId);
}
}
我几乎在每一个案例中都得到了大约 96% 的预期活动完成。这是来自历史表中的结果,其中 EventType = TaskCompleted
同样在“实例”表中,RuntimeStatus 只是保持在“正在运行”
我在哪里可以找到失败列表?
谢谢你的帮助
缺口