/// <summary>
        /// Serializes the object to JSON.
        /// </summary>
        /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param>
        /// <param name="obj">The object to serialize to JSON.</param>
        internal static void Serialize(JsonWriter writer, PartitionQuorumLossProgress obj)
        {
            // Required properties are always serialized, optional properties are serialized when not null.
            writer.WriteStartObject();
            writer.WriteProperty(obj.State, "State", OperationStateConverter.Serialize);
            if (obj.InvokeQuorumLossResult != null)
            {
                writer.WriteProperty(obj.InvokeQuorumLossResult, "InvokeQuorumLossResult", InvokeQuorumLossResultConverter.Serialize);
            }

            writer.WriteEndObject();
        }
Exemplo n.º 2
0
            internal static PartitionQuorumLossProgress CreateFromNative(NativeClient.IFabricPartitionQuorumLossProgressResult nativeResult)
            {
                if (nativeResult == null)
                {
                    return(null);
                }

                var progress = PartitionQuorumLossProgress.FromNative(nativeResult.get_Progress());

                GC.KeepAlive(nativeResult);
                return(progress);
            }
        public async Task <PartitionQuorumLossProgress> GetInvokeQuorumLossProgressAsync(
            Guid operationId,
            TimeSpan timeout,
            CancellationToken cancellationToken)
        {
            this.ThrowIfNotReady();
            PartitionQuorumLossProgress progress = null;

            try
            {
                ActionStateBase actionState = await this.MessageProcessor.ProcessGetProgressAsync(operationId, timeout, cancellationToken);

                StepStateNames stateName = actionState.StateProgress.Peek();

                TestCommandProgressState state = FaultAnalysisServiceUtility.ConvertState(actionState, TraceType);
                InvokeQuorumLossState    invokeQuorumLossState = actionState as InvokeQuorumLossState;

                var selectedPartition = new SelectedPartition
                {
                    ServiceName = invokeQuorumLossState.Info.PartitionSelector.ServiceName,
                    PartitionId = invokeQuorumLossState.Info.PartitionId
                };

                PartitionQuorumLossResult result = new PartitionQuorumLossResult(selectedPartition, actionState.ErrorCausingRollback);

                progress = new PartitionQuorumLossProgress(state, result);

                TestabilityTrace.TraceSource.WriteInfo(
                    TraceType,
                    "{0} - {1} progress - {2}, Exception - {3}",
                    operationId,
                    ActionType.InvokeQuorumLoss,
                    progress.Result != null ? progress.Result.SelectedPartition.ToString() : FASConstants.UnavailableMessage,
                    (progress.Result != null && progress.Result.Exception != null) ? progress.Result.Exception.ToString() : FASConstants.UnavailableMessage);
            }
            catch (Exception e)
            {
                TestabilityTrace.TraceSource.WriteWarning(TraceType, "{0} - Exception: {1}", operationId, e.ToString());
                FaultAnalysisServiceUtility.ThrowTransientExceptionIfRetryable(e);

                throw;
            }

            return(progress);
        }