Created
June 7, 2017 21:03
-
-
Save FredrikGoransson/846935fcfef0c1d19980402875c1b511 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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