首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >服务健康状态不更新在蔚蓝服务织物浏览器从健康管理?

服务健康状态不更新在蔚蓝服务织物浏览器从健康管理?
EN

Stack Overflow用户
提问于 2016-11-09 12:14:13
回答 1查看 415关注 0票数 0

如果这个问题听起来含糊不清,我很抱歉。下面是我观察到的情况。

我已经用两个无状态服务创建了一个天蓝色服务结构应用程序(POC)。

  1. Service-1最初将其健康状况报告为OK,在第一次迭代中存活时间为5分钟,等待2分钟(随机配置等待2分钟)。
  2. 10秒后,Service-2将其健康状况报告为Error,在其第一次迭代中以10 的时间存活。就连这个也要等两分钟。

此时,Service资源管理器正确地显示Service-1's状态为OK,Service-2's状态为Error。如预期的

  1. 同时,Service-1的第二次迭代开始并报告其状态为ERROR
  2. 服务-2的第二次迭代也将启动并报告其状态为OK

预期的:Service将显示Service-1's状态为ERROR,Service-2's状态显示为OK。

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

Service fabric explorer不是每次刷新时都会从health那里获得健康状态吗?如果是这样的话,为什么我被显示为这两个服务的错误状态?

以下代码供参考: Service-1:

代码语言:javascript
复制
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:

代码语言:javascript
复制
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);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-09 19:09:37

由于第二个健康属性不同于第一个健康属性(因为您是根据迭代来命名它们),第一个健康属性将一直保留到其TTL,然后具有由RemoveWhenExpired属性定义的行为(默认情况下为false,因此它将保持不变)。第一个属性不会被“OK”健康报告覆盖,因为这是一个“不同的属性”。在SFX中,我打赌你会看到这两个属性。他们需要有相同的名字才能像你所期望的那样工作。更多信息是这里

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40506787

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档