Rag*_*ghu 8 azure-service-fabric
我该怎么办呢?
小智 22
这是一种发现群集中运行的服务和端点的方法.(请记住,您还需要监控更改.)
private static void ListEndpoints()
{
var resolver = ServicePartitionResolver.GetDefault();
var fabricClient = new FabricClient();
var apps = fabricClient.QueryManager.GetApplicationListAsync().Result;
foreach (var app in apps)
{
Console.WriteLine($"Discovered application:'{app.ApplicationName}");
var services = fabricClient.QueryManager.GetServiceListAsync(app.ApplicationName).Result;
foreach (var service in services)
{
Console.WriteLine($"Discovered Service:'{service.ServiceName}");
var partitions = fabricClient.QueryManager.GetPartitionListAsync(service.ServiceName).Result;
foreach (var partition in partitions)
{
Console.WriteLine($"Discovered Service Partition:'{partition.PartitionInformation.Kind} {partition.PartitionInformation.Id}");
ServicePartitionKey key;
switch (partition.PartitionInformation.Kind)
{
case ServicePartitionKind.Singleton:
key = ServicePartitionKey.Singleton;
break;
case ServicePartitionKind.Int64Range:
var longKey = (Int64RangePartitionInformation)partition.PartitionInformation;
key = new ServicePartitionKey(longKey.LowKey);
break;
case ServicePartitionKind.Named:
var namedKey = (NamedPartitionInformation)partition.PartitionInformation;
key = new ServicePartitionKey(namedKey.Name);
break;
default:
throw new ArgumentOutOfRangeException("partition.PartitionInformation.Kind");
}
var resolved = resolver.ResolveAsync(service.ServiceName, key, CancellationToken.None).Result;
foreach (var endpoint in resolved.Endpoints)
{
Console.WriteLine($"Discovered Service Endpoint:'{endpoint.Address}");
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
您可以使用PowerShell与负载均衡器通信:
Get-AzureRmLoadBalancer
Run Code Online (Sandbox Code Playgroud)
最后,您需要提出一种方法来将负载均衡器后端端口与服务端点进行匹配.
| 归档时间: |
|
| 查看次数: |
4528 次 |
| 最近记录: |