Пример #1
0
 private static void SetPartitionDescription(ServiceModel.ServiceType description, PartitionSchemeDescription partitionDescription)
 {
     if (partitionDescription is SingletonPartitionSchemeDescription)
     {
         description.SingletonPartition = new ServiceModel.ServiceTypeSingletonPartition();
     }
     else if (partitionDescription is UniformInt64RangePartitionSchemeDescription)
     {
         var uniform = (UniformInt64RangePartitionSchemeDescription)partitionDescription;
         description.UniformInt64Partition = new ServiceModel.ServiceTypeUniformInt64Partition
         {
             HighKey        = uniform.HighKey.ToString(System.Globalization.CultureInfo.InvariantCulture),
             LowKey         = uniform.LowKey.ToString(System.Globalization.CultureInfo.InvariantCulture),
             PartitionCount = uniform.PartitionCount.ToString(System.Globalization.CultureInfo.InvariantCulture)
         };
     }
     else if (partitionDescription is NamedPartitionSchemeDescription)
     {
         var named = (NamedPartitionSchemeDescription)partitionDescription;
         description.NamedPartition = new ServiceModel.ServiceTypeNamedPartition
         {
             Partition = named.PartitionNames.Select(n => new ServiceModel.ServiceTypeNamedPartitionPartition {
                 Name = n
             }).ToArray()
         };
     }
 }
Пример #2
0
        public ServiceModel.ServiceType GenerateServiceDescription()
        {
            ServiceModel.ServiceType description = null;
            if (this.IsStateless)
            {
                description = new ServiceModel.StatelessServiceType
                {
                    ServiceTypeName          = this.ServiceTypeName,
                    InstanceCount            = this.InstanceCount.ToString(System.Globalization.CultureInfo.InvariantCulture),
                    LoadMetrics              = GenerateStatelessLoadMetrics(),
                    PlacementConstraints     = this.PlacementConstraints,
                    ServiceCorrelations      = GenerateServiceCorrelations(),
                    ServicePlacementPolicies = GenerateServicePlacementPolicies(),
                    ServiceScalingPolicies   = GenerateScalingPolicy()
                };
                if (DefaultMoveCost.HasValue)
                {
                    description.DefaultMoveCostSpecified = true;
                    description.DefaultMoveCost          = (ServiceTypeDefaultMoveCost)DefaultMoveCost.Value;
                }
            }
            else
            {
                description = new ServiceModel.StatefulServiceType
                {
                    ServiceTypeName          = this.ServiceTypeName,
                    MinReplicaSetSize        = this.MinReplicaSetSize.ToString(System.Globalization.CultureInfo.InvariantCulture),
                    TargetReplicaSetSize     = this.TargetReplicaSetSize.ToString(System.Globalization.CultureInfo.InvariantCulture),
                    LoadMetrics              = GenerateStatefulLoadMetrics(),
                    PlacementConstraints     = this.PlacementConstraints,
                    ServiceCorrelations      = GenerateServiceCorrelations(),
                    ServicePlacementPolicies = GenerateServicePlacementPolicies()
                };
                if (DefaultMoveCost.HasValue)
                {
                    description.DefaultMoveCostSpecified = true;
                    description.DefaultMoveCost          = (ServiceTypeDefaultMoveCost)DefaultMoveCost.Value;
                }
            }

            SetPartitionDescription(description, this.Partition);

            return(description);
        }