我的一位同事对SDK 1.7进行了以下工作:
foreach (RoleInstance ri in RoleEnvironment.CurrentRoleInstance.Role.Instances)
{
config.discovery.zen.ping.unicast.hosts.Add(ri.InstanceEndpoints["Endpoint1"].IPEndpoint.Address.ToString());
}
当我对SDK 1.8(osFamily = 3)执行相同操作时,我注意到远程实例的名称不能使用InstanceEndpoints。但是,以下变体仍可用于确定其他实例的IP:
foreach (RoleInstance instance in RoleEnvironment.CurrentRoleInstance.Role.Instances)
{
if (!instance.InstanceEndpoints.ContainsKey("Endpoint1"))
log.Error(string.Format("Instance {0} does not have Endpoint1 defined, has {1} endpoints in total.", instance.Id, instance.InstanceEndpoints.Count));
if (instance.InstanceEndpoints.Count > 0)
config.discovery.zen.ping.unicast.hosts.Add(instance.InstanceEndpoints[instance.InstanceEndpoints.Keys.First()].IPEndpoint.Address.ToString());
}
我找不到任何与此行为有关的文档,希望有人可以解释一下吗?