Пример #1
0
        internal static unsafe ServicePartitionList CreateFromNativeList(
            NativeTypes.FABRIC_SERVICE_PARTITION_QUERY_RESULT_LIST *nativeList,
            NativeTypes.FABRIC_PAGING_STATUS *nativePagingStatus)
        {
            var retval = new ServicePartitionList();

            var nativeItemArray = (NativeTypes.FABRIC_SERVICE_PARTITION_QUERY_RESULT_ITEM *)nativeList->Items;

            for (int i = 0; i < nativeList->Count; ++i)
            {
                var nativeItem = *(nativeItemArray + i);
                var item       = Partition.CreateFromNative(nativeItem);
                if (item != null)
                {
                    retval.Add(item);
                }
            }

            if (nativePagingStatus != null)
            {
                retval.ContinuationToken = NativeTypes.FromNativeString(nativePagingStatus->ContinuationToken);
            }

            return(retval);
        }
Пример #2
0
        /// <summary>
        /// This method tells whether the partition map should be stored in this partition or not. This is basically partitioning the data
        /// </summary>
        /// <param name="hashCode">Hashed value of partitionId</param>
        /// <returns></returns>
        public async Task <bool> BelongsToPartition(long hashCode)
        {
            FabricClient fabricClient = new FabricClient();

            System.Fabric.Query.ServicePartitionList partitions = await fabricClient.QueryManager.GetPartitionAsync(this.Context.PartitionId);

            foreach (var partition in partitions)
            {
                var  int64PartitionInfo = partition.PartitionInformation as Int64RangePartitionInformation;
                long?lowKey             = int64PartitionInfo?.LowKey;
                long?highKey            = int64PartitionInfo?.HighKey;
                if (hashCode >= lowKey && hashCode <= highKey)
                {
                    return(true);
                }
            }
            return(false);
        }