2016-06-12 1 views

답변

9

당신은 FabricClient를 사용하여 파티션을 열거 할 수

var serviceName = new Uri("fabric:/MyApp/MyService"); 
using (var client = new FabricClient()) 
{ 
    var partitions = await client.QueryManager.GetPartitionListAsync(serviceName); 

    foreach (var partition in partitions) 
    { 
     Debug.Assert(partition.PartitionInformation.Kind == ServicePartitionKind.Int64Range); 
     var partitionInformation = (Int64RangePartitionInformation)partition.PartitionInformation; 
     var proxy = ServiceProxy.Create<IMyService>(serviceName, new ServicePartitionKey(partitionInformation.LowKey)); 
     // TODO: call service 
    } 
} 

주 당신은 아마 GetPartitionListAsync의 결과를 캐시해야하는 서비스 파티션이 서비스를 다시없이 변경 될 수 없기 때문에 (당신은 단지 LowKey 값 목록을 유지할 수 있습니다).

또한 FabricClient도 가능한 한 많이 공유해야합니다 (documentation 참조).

+0

'LowKey'값의 목록을 유지하는 것이 좋습니다. 고마워. –

+0

"FabricClient"를 "공유하는"의미는 무엇입니까? – jugg1es

+0

@ jugg1es 매번 새로운 것을 생성하는 대신에, 'FabricClient'의 인스턴스를 재사용한다는 의미입니다. –

관련 문제