public async Task <ChaosReport> GetChaosReportAsync(
            GetChaosReportDescription getChaosReportDescription,
            TimeSpan timeout,
            CancellationToken cancellationToken)
        {
            Guid activityId = Guid.NewGuid();

            this.ThrowIfNotReady(() => this.ChaosMessageProcessor != null);

            TestabilityTrace.TraceSource.WriteNoise(TraceType, "{0}:Enter GetChaosReportAsync, description={1}", activityId, getChaosReportDescription.ToString());

            ChaosReport report = null;

            try
            {
                ChaosReportFilter reportFilter = null;
                var continuationToken          = getChaosReportDescription.ContinuationToken;

                if (!string.IsNullOrEmpty(continuationToken))
                {
                    reportFilter = await this.ChaosMessageProcessor.GetReportFilterAsync(activityId, continuationToken).ConfigureAwait(false);
                }
                else
                {
                    var continuationTokenGuid = Guid.NewGuid().ToString();
                    var fileTimeUtcTicks      = DateTime.UtcNow.ToFileTimeUtc();

                    continuationToken = string.Format(FASConstants.ChaosReportContinuationTokenFormat, fileTimeUtcTicks, continuationTokenGuid);
                }

                reportFilter = reportFilter ?? getChaosReportDescription.Filter;

                if (!string.IsNullOrEmpty(getChaosReportDescription.ClientType) &&
                    (getChaosReportDescription.ClientType.Equals(ChaosConstants.RestClientTypeName, StringComparison.OrdinalIgnoreCase) ||
                     getChaosReportDescription.ClientType.Equals(ChaosConstants.NativeClientTypeName, StringComparison.OrdinalIgnoreCase)))
                {
                    ChaosUtility.DisableOptimizationForValidationFailedEvent = true;
                }
                else
                {
                    ChaosUtility.DisableOptimizationForValidationFailedEvent = false;
                }

                report = await this.ChaosMessageProcessor.ProcessGetChaosReportAsync(
                    activityId,
                    reportFilter,
                    continuationToken).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                TestabilityTrace.TraceSource.WriteWarning(TraceType, "{0}:GetChaosReportAsync - Exception occurred: {1}", activityId, e.Message);
                FaultAnalysisServiceUtility.ThrowTransientExceptionIfRetryable(e);

                throw;
            }

            TestabilityTrace.TraceSource.WriteNoise(TraceType, "{0}:GetChaosReportAsync - returning report.", activityId);

            return(report);
        }
Beispiel #2
0
            internal static unsafe ChaosReport CreateFromNative(NativeClient.IFabricChaosReportResult nativeResult)
            {
                if (nativeResult == null)
                {
                    return(null);
                }

                var chaosReport = ChaosReport.FromNative(nativeResult.get_ChaosReportResult());

                GC.KeepAlive(nativeResult);
                return(chaosReport);
            }
Beispiel #3
0
        protected override void ProcessRecord()
        {
            var clusterConnection = this.GetClusterConnection();

            try
            {
                ChaosReport report = null;

                if (string.IsNullOrEmpty(this.ContinuationToken))
                {
                    report = clusterConnection.GetChaosReportAsync(
                        this.CreateChaosReportFilter(),
                        this.GetTimeout(),
                        this.GetCancellationToken()).Result;
                }
                else
                {
                    report = clusterConnection.GetChaosReportAsync(
                        this.ContinuationToken,
                        this.GetTimeout(),
                        this.GetCancellationToken()).Result;
                }

                this.WriteObject(this.FormatOutput(report));
            }
            catch (AggregateException aggregateException)
            {
                aggregateException.Handle((ae) =>
                {
                    this.ThrowTerminatingError(
                        ae,
                        Constants.GetChaosReportCommandErrorId,
                        clusterConnection);
                    return(true);
                });
            }
        }
 public ChaosReportResult(ChaosReport report)
 {
     this.pinCollection = new PinCollection();
     this.nativeResult  = report.ToNative(pinCollection);
 }