Skip to content

Instantly share code, notes, and snippets.

@FredrikGoransson
Created June 7, 2017 21:03
Show Gist options
  • Select an option

  • Save FredrikGoransson/846935fcfef0c1d19980402875c1b511 to your computer and use it in GitHub Desktop.

Select an option

Save FredrikGoransson/846935fcfef0c1d19980402875c1b511 to your computer and use it in GitHub Desktop.
// serviceUri - the fabric address of the service you want to query for partitions
// this gist assumes your service has an Int64 partitioning scheme.
var fabricClient = new FabricClient();
var servicePartitionList = await fabricClient.QueryManager.GetPartitionListAsync(serviceUri);
IList<Int64RangePartitionInformation> partitionKeys = new List<Int64RangePartitionInformation>(servicePartitionList.Count);
foreach (var partition in servicePartitionList)
{
var int64PartitionInfo = partition.PartitionInformation as Int64RangePartitionInformation;
if (int64PartitionInfo != null)
{
System.Diagnostics.Debug.WriteLine($"Id: {partition.PartitionInformation.Id}, Low: {int64PartitionInfo.LowKey} - {int64PartitionInfo.HighKey}");
}
var namedPartitionInfo = partition.PartitionInformation as NamedPartitionInformation;
if (namedPartitionInfo != null)
{
System.Diagnostics.Debug.WriteLine($"Id: {partition.PartitionInformation.Id}, Name: {namedPartitionInfo.Name}");
}
var singletonPartitionInfo = partition.PartitionInformation as SingletonPartitionInformation;
if (singletonPartitionInfo != null)
{
System.Diagnostics.Debug.WriteLine($"Id: {partition.PartitionInformation.Id}, Singleton");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment