节点恢复时Ping

1026 更新于: 2021-03-25 读完约需 1 分钟

当一个节点被标记为dead时,它会被放在一个专门的空间里(原文为dog house)一段时间。一旦它被重新激活,在实际的API调用之前就会安排一次ping,以确保这个节点启动并运行。如果还处于停止运行的状态,就把它再次放回那个空间里。

以下是请求超时的示例,了解其中每个超时各自是什么:

var audit = new Auditor(() => VirtualClusterWith
    .Nodes(3)
    .ClientCalls(r => r.SucceedAlways())
    .ClientCalls(r => r.OnPort(9202).Fails(Once))
    .Ping(p => p.SucceedAlways())
    .StaticConnectionPool()
    .AllDefaults()
);

audit = await audit.TraceCalls(
    new ClientCall { { PingSuccess, 9200 }, { HealthyResponse, 9200 } },
    new ClientCall { { PingSuccess, 9201 }, { HealthyResponse, 9201 } },
    new ClientCall {
        { PingSuccess, 9202},
        { BadResponse, 9202},
        { HealthyResponse, 9200},
        { pool =>  pool.Nodes.Where(n=>!n.IsAlive).Should().HaveCount(1) }
    },
    new ClientCall { { HealthyResponse, 9201 } },
    new ClientCall { { HealthyResponse, 9200 } },
    new ClientCall { { HealthyResponse, 9201 } },
    new ClientCall {
        { HealthyResponse, 9200 },
        { pool => pool.Nodes.First(n=>!n.IsAlive).DeadUntil.Should().BeAfter(DateTime.UtcNow) }
    }
);

audit = await audit.TraceCalls(
    new ClientCall { { HealthyResponse, 9201 } },
    new ClientCall { { HealthyResponse, 9200 } },
    new ClientCall { { HealthyResponse, 9201 } }
);

audit.ChangeTime(d => d.AddMinutes(20));

audit = await audit.TraceCalls(
    new ClientCall { { HealthyResponse, 9201 } },
    new ClientCall {
        { Resurrection, 9202 },
        { PingSuccess, 9202 },
        { HealthyResponse, 9202 }
    }
);

版权声明:本作品系原创,版权归码友网所有,如未经许可,禁止任何形式转载,违者必究。

发表评论

登录用户才能发表评论, 请 登 录 或者 注册