コード例 #1
0
            public override ServiceDescription Build()
            {
                var statelessDescription = new StatelessServiceDescription
                {
                    InstanceCount = this.InstanceCount
                };

                statelessDescription.ApplicationName            = this.ApplicationName;
                statelessDescription.PartitionSchemeDescription = this.PartitionSchemeDescriptionBuilder.Build();
                statelessDescription.ServiceName          = this.ServiceName;
                statelessDescription.ServiceTypeName      = this.ServiceTypeName;
                statelessDescription.PlacementConstraints = this.PlacementConstraints;
                statelessDescription.ServiceDnsName       = this.ServiceDnsName;

                if (this.Correlations != null)
                {
                    foreach (var str in this.Correlations)
                    {
                        statelessDescription.Correlations.Add(ServiceCmdletBase.ParseCorrelation(str));
                    }
                }

                if (this.PlacementPolicies != null)
                {
                    foreach (var str in this.PlacementPolicies)
                    {
                        statelessDescription.PlacementPolicies.Add(ServiceCmdletBase.ParsePlacementPolicy(str));
                    }
                }

                if (this.DefaultMoveCost != null)
                {
                    statelessDescription.DefaultMoveCost = ServiceCmdletBase.ParseMoveCost(this.DefaultMoveCost);
                }

                statelessDescription.ServicePackageActivationMode = this.ServicePackageActivationMode;

                if (this.Metrics != null)
                {
                    foreach (var str in this.Metrics)
                    {
                        statelessDescription.Metrics.Add(ServiceCmdletBase.ParseStatelessMetric(str));
                    }
                }

                if (this.ScalingPolicies != null)
                {
                    foreach (var scale in this.ScalingPolicies)
                    {
                        statelessDescription.ScalingPolicies.Add(scale);
                    }
                }

                return(statelessDescription);
            }
コード例 #2
0
            public virtual ServiceDescription Build()
            {
                this.ServiceDescription.ApplicationName            = this.ApplicationName;
                this.ServiceDescription.PartitionSchemeDescription = this.PartitionSchemeDescriptionBuilder.Build();
                this.ServiceDescription.ServiceName          = this.ServiceName;
                this.ServiceDescription.ServiceTypeName      = this.ServiceTypeName;
                this.ServiceDescription.PlacementConstraints = this.PlacementConstraints;
                this.ServiceDescription.ServiceDnsName       = this.ServiceDnsName;

                if (this.Correlations != null)
                {
                    foreach (var str in this.Correlations)
                    {
                        this.ServiceDescription.Correlations.Add(ServiceCmdletBase.ParseCorrelation(str));
                    }
                }

                if (this.PlacementPolicies != null)
                {
                    foreach (var str in this.PlacementPolicies)
                    {
                        this.ServiceDescription.PlacementPolicies.Add(ServiceCmdletBase.ParsePlacementPolicy(str));
                    }
                }

                if (this.DefaultMoveCost != null)
                {
                    this.ServiceDescription.DefaultMoveCost = ServiceCmdletBase.ParseMoveCost(this.DefaultMoveCost);
                }

                if (this.Metrics != null)
                {
                    foreach (var str in this.Metrics)
                    {
                        this.ServiceDescription.Metrics.Add(ServiceCmdletBase.ParseStatefulMetric(str));
                    }
                }

                this.ServiceDescription.ServicePackageActivationMode = this.ServicePackageActivationMode;

                return(this.ServiceDescription);
            }
コード例 #3
0
            /*
             * This method is only used to create ServiceGroupDescription, and is not related to the
             * ServiceDescriptionBuilder:Build().
             */
            public new virtual ServiceGroupDescription Build()
            {
                this.ServiceGroupDescription.ServiceDescription.ApplicationName            = this.ApplicationName;
                this.ServiceGroupDescription.ServiceDescription.PartitionSchemeDescription = this.PartitionSchemeDescriptionBuilder.Build();
                this.ServiceGroupDescription.ServiceDescription.ServiceName          = this.ServiceName;
                this.ServiceGroupDescription.ServiceDescription.ServiceTypeName      = this.ServiceTypeName;
                this.ServiceGroupDescription.ServiceDescription.PlacementConstraints = this.PlacementConstraints;

                if (this.Correlations != null)
                {
                    foreach (var str in this.Correlations)
                    {
                        this.ServiceGroupDescription.ServiceDescription.Correlations.Add(ServiceCmdletBase.ParseCorrelation(str));
                    }
                }

                if (this.PlacementPolicies != null)
                {
                    foreach (var str in this.PlacementPolicies)
                    {
                        this.ServiceGroupDescription.ServiceDescription.PlacementPolicies.Add(ServiceCmdletBase.ParsePlacementPolicy(str));
                    }
                }

                if (this.MemberDescriptions != null)
                {
                    foreach (var memberDescription in this.MemberDescriptions)
                    {
                        this.ServiceGroupDescription.MemberDescriptions.Add(this.ParseMemberDescription(memberDescription));
                    }
                }

                this.ServiceGroupDescription.ServiceDescription.ServicePackageActivationMode = this.ServicePackageActivationMode;

                return(this.ServiceGroupDescription);
            }
コード例 #4
0
        protected StatelessServiceUpdateDescription GetStatelessServiceUpdateDescription(
            int?instanceCount,
            string[] metrics,
            string[] correlations,
            string[] placementPolicies,
            string placementConstraints,
            string defaultMoveCost,
            string[] partitionNamesToAdd,
            string[] partitionNamesToRemove,
            List <ScalingPolicyDescription> scalingPolicies)
        {
            var statelessServiceUpdateDescription = new StatelessServiceUpdateDescription();

            if (instanceCount.HasValue)
            {
                statelessServiceUpdateDescription.InstanceCount = instanceCount.Value;
            }

            if (placementConstraints != null)
            {
                statelessServiceUpdateDescription.PlacementConstraints = placementConstraints;
            }

            if (metrics != null)
            {
                statelessServiceUpdateDescription.Metrics = new KeyedItemCollection <string, ServiceLoadMetricDescription>(d => d.Name);

                foreach (var str in metrics)
                {
                    statelessServiceUpdateDescription.Metrics.Add(ServiceCmdletBase.ParseStatelessMetric(str));
                }
            }

            if (defaultMoveCost != null)
            {
                statelessServiceUpdateDescription.DefaultMoveCost = ServiceCmdletBase.ParseMoveCost(defaultMoveCost);
            }

            if (correlations != null)
            {
                statelessServiceUpdateDescription.Correlations = new List <ServiceCorrelationDescription>();

                foreach (var str in correlations)
                {
                    statelessServiceUpdateDescription.Correlations.Add(ServiceCmdletBase.ParseCorrelation(str));
                }
            }

            if (placementPolicies != null)
            {
                statelessServiceUpdateDescription.PlacementPolicies = new List <ServicePlacementPolicyDescription>();

                foreach (var str in placementPolicies)
                {
                    statelessServiceUpdateDescription.PlacementPolicies.Add(ServiceCmdletBase.ParsePlacementPolicy(str));
                }
            }

            if ((partitionNamesToAdd != null && partitionNamesToAdd.Length > 0) || (partitionNamesToRemove != null && partitionNamesToRemove.Length > 0))
            {
                statelessServiceUpdateDescription.RepartitionDescription = new NamedRepartitionDescription(
                    partitionNamesToAdd,
                    partitionNamesToRemove);
            }

            if (scalingPolicies != null)
            {
                statelessServiceUpdateDescription.ScalingPolicies = new List <ScalingPolicyDescription>();
                foreach (var scale in scalingPolicies)
                {
                    statelessServiceUpdateDescription.ScalingPolicies.Add(scale);
                }
            }

            return(statelessServiceUpdateDescription);
        }
コード例 #5
0
        protected StatefulServiceUpdateDescription GetStatefulServiceUpdateDescription(
            int?targetReplicaSetSize,
            int?minReplicaSetSize,
            TimeSpan?replicaRestartWaitDuration,
            TimeSpan?quorumLossWaitDuration,
            TimeSpan?standByReplicaKeepDuration,
            string[] metrics,
            string[] correlations,
            string[] placementPolicies,
            string placementConstraints,
            string defaultMoveCost,
            string[] partitionNamesToAdd,
            string[] partitionNamesToRemove,
            List <ScalingPolicyDescription> scalingPolicies)
        {
            var statefulServiceUpdateDescription = new StatefulServiceUpdateDescription();

            if (targetReplicaSetSize.HasValue)
            {
                statefulServiceUpdateDescription.TargetReplicaSetSize = targetReplicaSetSize.Value;
            }

            if (minReplicaSetSize.HasValue)
            {
                statefulServiceUpdateDescription.MinReplicaSetSize = minReplicaSetSize.Value;
            }

            if (replicaRestartWaitDuration.HasValue)
            {
                statefulServiceUpdateDescription.ReplicaRestartWaitDuration = replicaRestartWaitDuration.Value;
            }

            if (quorumLossWaitDuration.HasValue)
            {
                statefulServiceUpdateDescription.QuorumLossWaitDuration = quorumLossWaitDuration.Value;
            }

            if (standByReplicaKeepDuration.HasValue)
            {
                statefulServiceUpdateDescription.StandByReplicaKeepDuration = standByReplicaKeepDuration.Value;
            }

            if (placementConstraints != null)
            {
                statefulServiceUpdateDescription.PlacementConstraints = placementConstraints;
            }

            if (metrics != null)
            {
                statefulServiceUpdateDescription.Metrics = new KeyedItemCollection <string, ServiceLoadMetricDescription>(d => d.Name);

                foreach (var str in metrics)
                {
                    statefulServiceUpdateDescription.Metrics.Add(ServiceCmdletBase.ParseStatefulMetric(str));
                }
            }

            if (defaultMoveCost != null)
            {
                statefulServiceUpdateDescription.DefaultMoveCost = ServiceCmdletBase.ParseMoveCost(defaultMoveCost);
            }

            if (correlations != null)
            {
                statefulServiceUpdateDescription.Correlations = new List <ServiceCorrelationDescription>();

                foreach (var str in correlations)
                {
                    statefulServiceUpdateDescription.Correlations.Add(ServiceCmdletBase.ParseCorrelation(str));
                }
            }

            if (placementPolicies != null)
            {
                statefulServiceUpdateDescription.PlacementPolicies = new List <ServicePlacementPolicyDescription>();

                foreach (var str in placementPolicies)
                {
                    statefulServiceUpdateDescription.PlacementPolicies.Add(ServiceCmdletBase.ParsePlacementPolicy(str));
                }
            }

            if ((partitionNamesToAdd != null && partitionNamesToAdd.Length > 0) || (partitionNamesToRemove != null && partitionNamesToRemove.Length > 0))
            {
                statefulServiceUpdateDescription.RepartitionDescription = new NamedRepartitionDescription(
                    partitionNamesToAdd,
                    partitionNamesToRemove);
            }

            if (scalingPolicies != null)
            {
                statefulServiceUpdateDescription.ScalingPolicies = new List <ScalingPolicyDescription>();
                foreach (var scale in scalingPolicies)
                {
                    statefulServiceUpdateDescription.ScalingPolicies.Add(scale);
                }
            }

            return(statefulServiceUpdateDescription);
        }
コード例 #6
0
            public override ServiceDescription Build()
            {
                var statefulDescription = new StatefulServiceDescription
                {
                    HasPersistedState    = this.HasPersistentState,
                    TargetReplicaSetSize = this.TargetReplicaSetSize,
                    MinReplicaSetSize    = this.MinReplicaSetSize
                };

                statefulDescription.ApplicationName            = this.ApplicationName;
                statefulDescription.PartitionSchemeDescription = this.PartitionSchemeDescriptionBuilder.Build();
                statefulDescription.ServiceName          = this.ServiceName;
                statefulDescription.ServiceTypeName      = this.ServiceTypeName;
                statefulDescription.PlacementConstraints = this.PlacementConstraints;
                statefulDescription.ServiceDnsName       = this.ServiceDnsName;

                if (this.ReplicaRestartWaitDuration.HasValue)
                {
                    statefulDescription.ReplicaRestartWaitDuration = this.ReplicaRestartWaitDuration.Value;
                }

                if (this.QuorumLossWaitDuration.HasValue)
                {
                    statefulDescription.QuorumLossWaitDuration = this.QuorumLossWaitDuration.Value;
                }

                if (this.StandByReplicaKeepDuration.HasValue)
                {
                    statefulDescription.StandByReplicaKeepDuration = this.StandByReplicaKeepDuration.Value;
                }

                if (this.Correlations != null)
                {
                    foreach (var str in this.Correlations)
                    {
                        statefulDescription.Correlations.Add(ServiceCmdletBase.ParseCorrelation(str));
                    }
                }

                if (this.PlacementPolicies != null)
                {
                    foreach (var str in this.PlacementPolicies)
                    {
                        statefulDescription.PlacementPolicies.Add(ServiceCmdletBase.ParsePlacementPolicy(str));
                    }
                }

                if (this.DefaultMoveCost != null)
                {
                    statefulDescription.DefaultMoveCost = ServiceCmdletBase.ParseMoveCost(this.DefaultMoveCost);
                }

                statefulDescription.ServicePackageActivationMode = this.ServicePackageActivationMode;

                if (this.Metrics != null)
                {
                    foreach (var str in this.Metrics)
                    {
                        statefulDescription.Metrics.Add(ServiceCmdletBase.ParseStatefulMetric(str));
                    }
                }

                if (this.ScalingPolicies != null)
                {
                    foreach (var scale in this.ScalingPolicies)
                    {
                        statefulDescription.ScalingPolicies.Add(scale);
                    }
                }

                return(statefulDescription);
            }