示例#1
0
        public static TestServicePartitionInfo Convert(ResolvedServicePartition resolvedPartition, ResolvedServiceEndpoint resolvedEndpoint, int partitionIdentifierNumber)
        {
            ThrowIf.Null(resolvedPartition, "resolvedPartition");
            ThrowIf.Null(resolvedEndpoint, "resolvedEndpoint");
            ServicePartitionKind keyType = ServicePartitionKind.Invalid;

            object rangeHighKey = null;
            object rangeLowKey  = null;

            switch (resolvedPartition.Info.Kind)
            {
            case ServicePartitionKind.Singleton:
                keyType = ServicePartitionKind.Singleton;
                break;

            case ServicePartitionKind.Int64Range:
                keyType      = ServicePartitionKind.Int64Range;
                rangeHighKey = ((System.Fabric.Int64RangePartitionInformation)resolvedPartition.Info).HighKey;
                rangeLowKey  = ((System.Fabric.Int64RangePartitionInformation)resolvedPartition.Info).LowKey;
                break;

            case ServicePartitionKind.Named:
                keyType = ServicePartitionKind.Named;
                break;

            default:
                throw new InvalidOperationException("Unknown ServicePartitionKind " + resolvedPartition.Info.Kind.ToString() + ".");
            }

            TestServicePartitionInfo testServicePartitionInfo = new TestServicePartitionInfo()
            {
                Location            = resolvedEndpoint.Address,
                Name                = resolvedPartition.ServiceName,
                Id                  = resolvedPartition.Info.Id,
                KeyType             = keyType,
                RangeHighKey        = rangeHighKey,
                RangeLowKey         = rangeLowKey,
                Role                = resolvedEndpoint.Role,
                PartitionIdentifier = partitionIdentifierNumber,
            };

            if (resolvedPartition.Endpoints.Any(e => e.Role == ServiceEndpointRole.StatefulPrimary))
            {
                testServicePartitionInfo.IsPrimaryEndpoint = resolvedPartition.GetEndpoint().Address == resolvedEndpoint.Address;
            }
            else
            {
                testServicePartitionInfo.IsPrimaryEndpoint = false;
            }

            return(testServicePartitionInfo);
        }
示例#2
0
        public ResolveServiceRequest(IFabricClient fabricClient, Uri name, object partitionKey, TestServicePartitionInfo previousResult, TimeSpan timeout)
            : base(fabricClient, timeout)
        {
            ThrowIf.Null(name, "name");

            this.Name           = name;
            this.PartitionKey   = partitionKey;
            this.PreviousResult = previousResult;

            this.ConfigureErrorCodes();
        }