protected void UpdateServiceGroup(
            Uri serviceName,
            ServiceGroupUpdateDescription updateDescription)
        {
            var clusterConnection = this.GetClusterConnection();

            try
            {
                clusterConnection.UpdateServiceGroupAsync(
                    serviceName,
                    updateDescription,
                    this.GetTimeout(),
                    this.GetCancellationToken()).Wait();
                this.WriteObject(StringResources.Info_UpdateServiceGroupSucceeded);
            }
            catch (AggregateException aggregateException)
            {
                aggregateException.Handle((ae) =>
                {
                    this.ThrowTerminatingError(
                        ae,
                        Constants.UpdateServiceGroupErrorId,
                        clusterConnection);
                    return(true);
                });
            }
        }
Пример #2
0
 private Task UpdateServiceGroupAsyncHelper(Uri name, ServiceGroupUpdateDescription updateDescription, TimeSpan timeout, CancellationToken cancellationToken)
 {
     return(Utility.WrapNativeAsyncInvokeInMTA(
                (callback) => this.UpdateServiceGroupBeginWrapper(name, updateDescription, timeout, callback),
                this.UpdateServiceGroupEndWrapper,
                cancellationToken,
                "ServiceManager.UpdateServiceGroup"));
 }
Пример #3
0
            /// <summary>
            /// Asynchronously updates a service group with specified description.
            /// </summary>
            /// <param name="name">The URI name of the service being updated.</param>
            /// <param name="updateDescription">The <see cref="System.Fabric.Description.ServiceGroupUpdateDescription" /> that specifies the updated configuration for the service.</param>
            /// <param name="timeout">The maximum amount of time the system will allow this API to take before returning <see cref="System.TimeoutException" />.</param>
            /// <param name="cancellationToken">The <see cref="System.Threading.CancellationToken" /> that the operation is observing. It can be used to propagate notification that the operation should be canceled.</param>
            /// <returns>The task representing the asynchronous service group update operation.</returns>
            public Task UpdateServiceGroupAsync(Uri name, ServiceGroupUpdateDescription updateDescription, TimeSpan timeout, CancellationToken cancellationToken)
            {
                this.fabricClient.ThrowIfDisposed();
                Requires.Argument <Uri>("name", name).NotNull();
                Requires.Argument <ServiceGroupUpdateDescription>("updateDescription", updateDescription).NotNull();

                return(this.UpdateServiceGroupAsyncHelper(name, updateDescription, timeout, cancellationToken));
            }
Пример #4
0
            internal static IntPtr ToNative(PinCollection pin, ServiceGroupUpdateDescription updateDescription)
            {
                if (updateDescription == null)
                {
                    return(IntPtr.Zero);
                }

                var nativeDescription = new NativeTypes.FABRIC_SERVICE_GROUP_UPDATE_DESCRIPTION[1];

                nativeDescription[0].UpdateDescription = updateDescription.ServiceUpdateDescription.ToNative(pin);

                return(pin.AddBlittable(nativeDescription[0]));
            }
Пример #5
0
        protected override void ProcessRecord()
        {
            ServiceGroupUpdateDescription serviceGroupUpdateDescription = new ServiceGroupUpdateDescription();

            if (this.Stateful)
            {
                var statefulServiceUpdateDescription = new StatefulServiceUpdateDescription();
                if (this.TargetReplicaSetSize.HasValue)
                {
                    statefulServiceUpdateDescription.TargetReplicaSetSize = this.TargetReplicaSetSize.Value;
                }

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

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

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

                serviceGroupUpdateDescription.ServiceUpdateDescription = statefulServiceUpdateDescription;
            }
            else
            {
                var statelessServiceUpdateDescription = new StatelessServiceUpdateDescription();
                if (this.InstanceCount.HasValue)
                {
                    statelessServiceUpdateDescription.InstanceCount = this.InstanceCount.Value;
                }

                serviceGroupUpdateDescription.ServiceUpdateDescription = statelessServiceUpdateDescription;
            }

            if (this.ShouldProcess(this.ServiceName.OriginalString))
            {
                if (this.Force || this.ShouldContinue(string.Empty, string.Empty))
                {
                    this.UpdateServiceGroup(this.ServiceName, serviceGroupUpdateDescription);
                }
            }
        }
Пример #6
0
 private NativeCommon.IFabricAsyncOperationContext UpdateServiceGroupBeginWrapper(Uri name, ServiceGroupUpdateDescription updateDescription, TimeSpan timeout, NativeCommon.IFabricAsyncOperationCallback callback)
 {
     using (var pin = new PinCollection())
     {
         return(this.nativeServiceGroupClient.BeginUpdateServiceGroup(
                    pin.AddObject(name),
                    InteropHelpers.ServiceGroupUpdateDescriptionHelper.ToNative(pin, updateDescription),
                    Utility.ToMilliseconds(timeout, "timeout"),
                    callback));
     }
 }
Пример #7
0
 /// <summary>
 /// Asynchronously updates a service group with the specified description.
 /// </summary>
 /// <param name="name">The URI name of the service group being updated.</param>
 /// <param name="updateDescription">The <see cref="System.Fabric.Description.ServiceGroupUpdateDescription" /> that specifies the updated configuration for the service group.</param>
 /// <returns>The task representing the asynchronous service group update operation.</returns>
 public Task UpdateServiceGroupAsync(Uri name, ServiceGroupUpdateDescription updateDescription)
 {
     return(this.UpdateServiceGroupAsync(name, updateDescription, FabricClient.DefaultTimeout, CancellationToken.None));
 }