Example #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);
        }
        internal static Type ResolveDerivedClass(ServicePartitionKind kind)
        {
            switch (kind)
            {
            case ServicePartitionKind.Singleton:
                return(typeof(SingletonPartitionInformation));

            case ServicePartitionKind.Int64Range:
                return(typeof(Int64RangePartitionInformation));

            case ServicePartitionKind.Named:
                return(typeof(NamedPartitionInformation));

            default:
                return(null);
            }
        }
        private EndpointType(string serviceAbsolutePath, Guid partitionId, string endpointName,
                             bool defaultEndpoint, ServiceEndpointRole role, ServicePartitionKind partitionKind, long?partitionLow,
                             long?partitionHigh, string partitionKey)
        {
            ServiceAbsolutePath = serviceAbsolutePath;
            PartitionId         = partitionId;
            EndpointName        = endpointName;
            DefaultEndpoint     = defaultEndpoint;
            Role          = role;
            PartitionKind = partitionKind;
            PartitionLow  = partitionLow;
            PartitionHigh = partitionHigh;
            PartitionKey  = partitionKey;
            _key          = $"{serviceAbsolutePath}|{partitionId}|{endpointName}|{role}";

            IngressId = $"I|{_key}";
            EgressId  = $"E|{_key}";
        }
Example #4
0
 public async Task MapPartitions(Uri applicationName, Uri serviceName, ClusterDetails primaryCluster, ServicePartitionList partitionsInPrimary, ClusterDetails secondaryCluster, ServicePartitionList partitionsInSecondary, string reliableDictionary)
 {
     if (partitionsInPrimary != null)
     {
         ServicePartitionKind partitionKind = partitionsInPrimary[0].PartitionInformation.Kind;
         if (partitionKind.Equals(ServicePartitionKind.Int64Range))
         {
             await MapInt64Partitions(applicationName, serviceName, primaryCluster, partitionsInPrimary, secondaryCluster, partitionsInSecondary, reliableDictionary);
         }
         else if (partitionKind.Equals(ServicePartitionKind.Named))
         {
             await MapNamedPartitions(applicationName, serviceName, primaryCluster, partitionsInPrimary, secondaryCluster, partitionsInSecondary, reliableDictionary);
         }
         else if (partitionKind.Equals(ServicePartitionKind.Singleton))
         {
             await MapSingletonPartition(applicationName, serviceName, primaryCluster, partitionsInPrimary, secondaryCluster, partitionsInSecondary, reliableDictionary);
         }
     }
 }
        public ServiceDescription(Uri serviceName, ServicePartitionKind partitionKind, string listenerName = "")
        {
            if (serviceName == null)
            {
                throw new ArgumentNullException(nameof(serviceName));
            }

            if (partitionKind != ServicePartitionKind.Singleton &&
                partitionKind != ServicePartitionKind.Int64Range &&
                partitionKind != ServicePartitionKind.Named)
            {
                throw new ArgumentException(null, nameof(partitionKind));
            }

            if (listenerName == null)
            {
                throw new ArgumentNullException(nameof(listenerName));
            }

            ServiceName = serviceName;
            PartitionKind = partitionKind;
            ListenerName = listenerName;
        }
Example #6
0
        public ServiceDescription(Uri serviceName, ServicePartitionKind partitionKind, string listenerName = "")
        {
            if (serviceName == null)
            {
                throw new ArgumentNullException(nameof(serviceName));
            }

            if (partitionKind != ServicePartitionKind.Singleton &&
                partitionKind != ServicePartitionKind.Int64Range &&
                partitionKind != ServicePartitionKind.Named)
            {
                throw new ArgumentException(null, nameof(partitionKind));
            }

            if (listenerName == null)
            {
                throw new ArgumentNullException(nameof(listenerName));
            }

            ServiceName   = serviceName;
            PartitionKind = partitionKind;
            ListenerName  = listenerName;
        }
 /// <summary>
 /// Instantiates a ServicePartitionKey for named partitioned services.
 /// </summary>
 /// <param name="partitionKey">Value of the named partition key</param>
 public ServicePartitionKey(string partitionKey)
 {
     this.value = partitionKey;
     this.servicePartitionKind = ServicePartitionKind.Named;
 }
 /// <summary>
 /// Instantiates a ServicePartitionKey for uniform int64 partitioned service.
 /// </summary>
 /// <param name="partitionKey">Value of the int64 partition key</param>
 public ServicePartitionKey(long partitionKey)
 {
     this.servicePartitionKind = ServicePartitionKind.Int64Range;
     this.value = partitionKey;
 }
 /// <summary>
 /// Instantiates a ServicePartitionKey for singleton partitioned service.
 /// </summary>
 public ServicePartitionKey()
 {
     this.value = null;
     this.servicePartitionKind = ServicePartitionKind.Singleton;
 }
Example #10
0
 private Uri GetEventStoreUri(string api, ServicePartitionKind servicePartitionKind, long partitionKey)
 {
     return(new Uri($"http://localhost:{this.configSettings.ReverseProxyPort}/{serviceUri.Replace("fabric:/", "")}{api}?PartitionKind={servicePartitionKind}&PartitionKey={partitionKey}"));
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="servicePartitionKind">Service Partition Kind</param>
 protected PartitionInformation(ServicePartitionKind servicePartitionKind)
 {
     this.ServicePartitionKind = servicePartitionKind;
 }
 internal ServicePartitionInformation(ServicePartitionKind kind)
 {
     this.Kind = kind;
 }