2016-11-09 25 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屬性。感謝您的解釋! –

相關問題