Ejemplo n.º 1
0
        protected override void ProcessRecord()
        {
            IClusterConnection clusterConnection = this.GetClusterConnection();

            try
            {
                string fileAbsolutePath = this.GetAbsolutePath(this.StateFilePath);
                string state            = File.ReadAllText(fileAbsolutePath);

                FabricUpgradeOrchestrationServiceState result = clusterConnection.SetUpgradeOrchestrationServiceStateAsync(
                    state,
                    this.GetTimeout(),
                    this.GetCancellationToken()).Result;
                this.WriteObject(result);
            }
            catch (AggregateException aggregateException)
            {
                aggregateException.Handle((ae) =>
                {
                    this.ThrowTerminatingError(
                        ae,
                        "SetUpgradeOrchestrationServiceStateErrorId",
                        clusterConnection);
                    return(true);
                });
            }
        }
        public async Task <string> ProcessSetUpgradeOrchestrationServiceStateAsync(string inputBlob, TimeSpan timeout, CancellationToken cancellationToken)
        {
            UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Entering ProcessSetUpgradeOrchestrationServiceStateAsync.");
            try
            {
                // data validation
                StandAloneCluster cluster = null;
                if (!string.IsNullOrWhiteSpace(inputBlob))
                {
                    JsonSerializerSettings settings = StandaloneUtility.GetStandAloneClusterDeserializerSettings();

                    cluster = JsonConvert.DeserializeObject <StandAloneCluster>(
                        inputBlob,
                        settings);
                }

                await this.storeManager.SetStorageObjectAsync(Constants.ClusterReliableDictionaryKey, inputBlob, this.cancellationToken).ConfigureAwait(false);

                FabricUpgradeOrchestrationServiceState result = UpgradeOrchestrationMessageProcessor.ConstructServiceStateFromCluster(cluster);

                return(JsonConvert.SerializeObject(
                           result,
                           new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
                    NullValueHandling = NullValueHandling.Ignore,
                }));
            }
            catch (Exception e)
            {
                UpgradeOrchestrationTrace.TraceSource.WriteWarning(TraceType, "ProcessSetUpgradeOrchestrationServiceStateAsync exception: {0}", e);
                throw UpgradeOrchestrationMessageProcessor.ConvertToComException(e);
            }
        }
        internal static FabricUpgradeOrchestrationServiceState ConstructServiceStateFromCluster(StandAloneCluster cluster)
        {
            FabricUpgradeOrchestrationServiceState result = new FabricUpgradeOrchestrationServiceState();

            if (cluster != null)
            {
                if (cluster.Current != null && cluster.Current.ExternalState != null)
                {
                    result.CurrentCodeVersion = cluster.Current.ExternalState.MsiVersion;

                    if (cluster.Current.ExternalState.ClusterManifest != null)
                    {
                        result.CurrentManifestVersion = cluster.Current.ExternalState.ClusterManifest.Version;
                    }
                }

                if (cluster.Pending != null)
                {
                    result.PendingUpgradeType = cluster.Pending.GetType().Name;

                    if (cluster.Pending.ExternalState != null)
                    {
                        result.TargetCodeVersion = cluster.Pending.ExternalState.MsiVersion;

                        if (cluster.Pending.ExternalState.ClusterManifest != null)
                        {
                            result.TargetManifestVersion = cluster.Pending.ExternalState.ClusterManifest.Version;
                        }
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 4
0
            internal static FabricUpgradeOrchestrationServiceState CreateFromNative(NativeClient.IFabricUpgradeOrchestrationServiceStateResult nativeResult)
            {
                if (nativeResult == null)
                {
                    return(null);
                }

                var state = FabricUpgradeOrchestrationServiceState.FromNative(nativeResult.get_State());

                GC.KeepAlive(nativeResult);
                return(state);
            }