2016-11-09 86 views
0

如果问题听起来含糊不清,我很抱歉。这是我观察的场景。健康管理中心的Azure服务结构浏览器中的服务运行状况不会更新?

我创建了一个具有2个无状态服务的azure服务结构应用程序(POC)。

  1. Service-1最初的报告是健康OK与生存时间的第一次迭代5分钟和2分钟等待(任意配置的等待2分钟)。
  2. 10秒后,Service-2报告它的健康错误与存活时间为10秒在其第一次迭代。即使这样也等待2分钟。

此时,Service fabric explorer正确显示Service-1's状态为OK,Service-2's状态为Error。 AS EXPECTED

  1. 同时,Service-1开始和报告第二次迭代它现在的地位错误
  2. 服务-2的第二次迭代也启动并现在报告其状态为好吧

预期:服务织物探险家将显示Service-1's状态错误和Service-2's地位确定。

实际:两种服务都显示为错误。

不服务fabric explorer每次刷新时都会从Health Manager中获取运行状况状态?如果是这样,为什么我将两个服务的状态显示为错误?下面

代码以供参考: 服务-1:

long iterations = 0; 
if (iterations++%2 == 0) 
{ 
    var healthInformation = new HealthInformation("Service-1", $"{this.Context.ServiceName}-OK-{iterations}-Property", 
     HealthState.Ok); 
    healthInformation.TimeToLive = TimeSpan.FromSeconds(300); 
    var healthReport = new StatelessServiceInstanceHealthReport(this.Context.PartitionId, 
     this.Context.InstanceId, healthInformation); 
    fabricClient.HealthManager.ReportHealth(healthReport); 
    ServiceEventSource.Current.ServiceMessage(this, "Logged OK health from {0}", this.Context.ServiceName); 
    await Task.Delay(TimeSpan.FromSeconds(120), cancellationToken); 
} 
else 
{ 
    var healthInformation = new HealthInformation("Service-1", $"{this.Context.ServiceName}-Error-{iterations}-Property", 
     HealthState.Error); 
    healthInformation.TimeToLive = TimeSpan.FromSeconds(10); 
    var healthReport = new StatelessServiceInstanceHealthReport(this.Context.PartitionId, 
     this.Context.InstanceId, healthInformation); 
    fabricClient.HealthManager.ReportHealth(healthReport); 
    ServiceEventSource.Current.ServiceMessage(this, "Logged Error health from {0}", this.Context.ServiceName); 
    await Task.Delay(TimeSpan.FromSeconds(120), cancellationToken); 
} 

服务-2:

long iterations = 0; 
if (iterations++ % 2 == 0) 
{ 
    var healthInformation = new HealthInformation("StatelessService2", $"{this.Context.ServiceName}-Error-{iterations}-Property", 
     HealthState.Error); 
    healthInformation.TimeToLive = TimeSpan.FromSeconds(10); 
    var healthReport = new StatelessServiceInstanceHealthReport(this.Context.PartitionId, 
     this.Context.InstanceId, healthInformation); 
    fabricClient.HealthManager.ReportHealth(healthReport); 
    ServiceEventSource.Current.ServiceMessage(this, "Logged Error from {0}" , this.Context.ServiceName); 
    await Task.Delay(TimeSpan.FromSeconds(120), cancellationToken); 
} 
else 
{ 
    var healthInformation = new HealthInformation("StatelessService2", $"{this.Context.ServiceName}-OK-{iterations}-Property", 
     HealthState.Ok); 
    healthInformation.TimeToLive = TimeSpan.FromSeconds(300); 
    var healthReport = new StatelessServiceInstanceHealthReport(this.Context.PartitionId, 
     this.Context.InstanceId, healthInformation); 
    fabricClient.HealthManager.ReportHealth(healthReport); 
    ServiceEventSource.Current.ServiceMessage(this, "Logged OK from {0}" ,this.Context.ServiceName); 
    await Task.Delay(TimeSpan.FromSeconds(120), cancellationToken); 
} 

回答

0

由于第二健康属性是从所述第一健康属性不同(因为你基于迭代命名它们),第一个健康属性将保留到TTL和n具有由RemoveWhenExpired属性定义的行为(默认为false,因此它将保持不变)。第一个属性不会被“OK”健康报告覆盖,因为这是“不同的属性”。在SFX中,我敢打赌你实际上会看到这两个属性。他们需要使用相同的名称才能以您期望的方式工作。更多的信息是here

+0

明白了。我没有设置RemoveWhenExpired属性。感谢您的解释! –