Exemple #1
0
        static void Main(string[] args)
        {
            //TraceStoreConnectionInformation info = new LocalTraceStoreConnectionInformation(
            //    @"D:\Repos\WindowsFabric\out\debug-amd64\bin\WinFabricTest\test\FabActFiveNodelCluster.test\TC",
            //    @"E:\crm_duplicate",
            //    @"D:\Repos\WindowsFabric\out\debug-amd64\bin\WinFabricTest\test\FabActFiveNodelCluster.test\TC");

            TraceStoreConnectionInformation info = new AzureTraceStoreConnectionInformation(
                "winfablrc",
                HandyUtil.SecureStringFromCharArray("<Insert key Here>"),
                "vipinrtobitlogsqt",
                "blobContainerRandmom",
                "e98a88aa63aa42b4",
                LocalDiskLogger.LogProvider);

            TraceStoreConnection connection = new TraceStoreConnection(info, LocalDiskLogger.LogProvider);
            ReadFilter           filter     = ReadFilter.CreateReadFilter(typeof(NodeOpeningTraceRecord));

            // SET your Duration.
            var duration = new Duration(
                DateTime.SpecifyKind(DateTime.Parse("2018-04-10 01:01:19.155"), DateTimeKind.Utc),
                DateTime.SpecifyKind(DateTime.UtcNow, DateTimeKind.Utc));

            var results = connection.EventStoreReader.WithinBound(duration).ReadBackwardAsync(filter, 500, CancellationToken.None).GetAwaiter().GetResult();

            Console.WriteLine("Count {0}", results.Count());
            foreach (var one in results)
            {
                Console.WriteLine(one.TimeStamp.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture) + " " + one);
                Console.WriteLine();
            }

            Console.Read();
        }
        public static ReadFilter CreateTypeAndIdFilter(ITraceStoreReader traceStoreReader, Type type, Guid eventInstanceId)
        {
            var filter = ReadFilter.CreateReadFilter(type);

            if (eventInstanceId != Guid.Empty && traceStoreReader.IsPropertyLevelFilteringSupported())
            {
                filter.AddFilter(type, EventInstanceFilterName, eventInstanceId);
            }

            return(filter);
        }
Exemple #3
0
        /// <inheritdoc />
        protected override async Task <IDictionary <Scenario, IList <TraceRecord> > > GetSignalsForScenarioAsync(
            IList <Scenario> scenarios,
            Duration duration,
            CancellationToken token)
        {
            var        allTypes = this.GetTypesFromScenarios(scenarios);
            ReadFilter filter   = ReadFilter.CreateReadFilter(allTypes);

            var allTraceRecords = await this.traceStoreReader.ReadTraceRecordsAsync(duration, filter, token).ConfigureAwait(false);

            return(this.GroupTraceRecordsByScenario(allTraceRecords));
        }
        public static ReadFilter CreatePartitionFilter(ITraceStoreReader traceStoreReader, IList <Type> types, Guid partitionId)
        {
            var filter = ReadFilter.CreateReadFilter(types);

            if (partitionId != Guid.Empty && traceStoreReader.IsPropertyLevelFilteringSupported())
            {
                foreach (var oneType in types)
                {
                    filter.AddFilter(oneType, PartitionFilterName, partitionId);
                }
            }

            return(filter);
        }
        public static ReadFilter CreateNodeFilter(ITraceStoreReader traceStoreReader, IList <Type> types, string nodeName)
        {
            var filter = ReadFilter.CreateReadFilter(types);

            if (!string.IsNullOrEmpty(nodeName) && traceStoreReader.IsPropertyLevelFilteringSupported())
            {
                foreach (var oneType in types)
                {
                    filter.AddFilter(oneType, NodeFilterName, nodeName);
                }
            }

            return(filter);
        }
        private async Task <FabricEvent> GetPartitionEventsAsync(Duration duration, Guid instanceId, CancellationToken token)
        {
            var records = await this.traceStoreReader.ReadTraceRecordsAsync(
                duration,
                ReadFilter.CreateReadFilter(Mapping.EntityToEventsMap[EntityType.Partition].Select(item => item.UnderlyingType).ToList()),
                token).ConfigureAwait(false);

            var recordOfInterest = records.SingleOrDefault(item => item.ObjectInstanceId?.Id == instanceId);

            if (recordOfInterest != null)
            {
                return(PartitionEventAdapter.Convert(recordOfInterest));
            }

            return(null);
        }
        public async Task <IEnumerable <ReportFaultTraceRecord> > GetReportFaultTraceRecordsAsync(PrimaryMoveAnalysisEvent analysisEvent)
        {
            var records = await this.queryStoreReader.ReadTraceRecordsAsync(
                analysisEvent.GetDuration(),
                ReadFilter.CreateReadFilter(
                    new[]
            {
                typeof(ReportFaultTraceRecord)
            }
                    ),
                this.cancellationToken).ConfigureAwait(false);

            var interstingRecords = records.Select(item => item as ReportFaultTraceRecord).Where(item => item.ReasonActivityId == analysisEvent.ReasonActivityId);

            return(interstingRecords);
        }
        public async Task <IEnumerable <ReplicaStateChangeTraceRecord> > GetReplicaStateChangeTraceRecordsAsync(PrimaryMoveAnalysisEvent analysisEvent)
        {
            var records = await this.queryStoreReader.ReadTraceRecordsAsync(
                analysisEvent.GetDuration(),
                ReadFilter.CreateReadFilter(
                    new[]
            {
                typeof(ReplicaStateChangeTraceRecord)
            }
                    ),
                this.cancellationToken).ConfigureAwait(false);

            var interstingRecords = records.Select(item => item as ReplicaStateChangeTraceRecord).Where(item => item.PartitionId == analysisEvent.TriggerReconfigurationCompletedTraceRecord.PartitionId && item.Role == global::ReplicaRole.P && item.Status == ReplicaLifeCycleState.Closing && item.NodeInstanceId.StartsWith(analysisEvent.PreviousPrimaryContext.NodeId) && item.ReasonActivityId != Guid.Empty);

            return(interstingRecords);
        }
        public async Task <IEnumerable <NodeUpTraceRecord> > GetNodeUpTraceRecordsAsync(PrimaryMoveAnalysisEvent analysisEvent)
        {
            var records = await this.queryStoreReader.ReadTraceRecordsAsync(
                analysisEvent.GetDuration(),
                ReadFilter.CreateReadFilter(
                    new[]
            {
                typeof(NodeUpTraceRecord)
            }
                    ),
                this.cancellationToken).ConfigureAwait(false);

            var interstingRecords = records.Select(item => item as NodeUpTraceRecord).Where(item => item.NodeName.Equals(analysisEvent.PreviousPrimaryContext.NodeName, StringComparison.OrdinalIgnoreCase));

            return(interstingRecords);
        }
Exemple #10
0
        public static ReadFilter CreateCorrelationEventFilter(ITraceStoreReader reader, IList <Guid> eventInstances)
        {
            var type   = typeof(CorrelationTraceRecord);
            var filter = ReadFilter.CreateReadFilter(type);

            if (!reader.IsPropertyLevelFilteringSupported())
            {
                return(filter);
            }

            foreach (var oneInstance in eventInstances)
            {
                filter.AddFilter(type, CorrelationTraceRecord.RelatedFromIdPropertyName, oneInstance);
                filter.AddFilter(type, CorrelationTraceRecord.RelatedToIdPropertyName, oneInstance);
            }

            return(filter);
        }
        public async Task <IEnumerable <OperationTraceRecord> > GetEffectiveOperationTraceRecordsAsync(PrimaryMoveAnalysisEvent analysisEvent)
        {
            var records = await this.queryStoreReader.ReadTraceRecordsAsync(
                analysisEvent.GetDuration(),
                ReadFilter.CreateReadFilter(
                    new[]
            {
                typeof(OperationTraceRecord),
                typeof(OperationIgnoredTraceRecord)
            }
                    ),
                this.cancellationToken).ConfigureAwait(false);

            HashSet <Guid> ignoredDecisions = new HashSet <Guid>();
            Dictionary <Guid, OperationTraceRecord> decisionOperationMap      = new Dictionary <Guid, OperationTraceRecord>();
            List <OperationTraceRecord>             effectiveOperationRecords = new List <OperationTraceRecord>();

            foreach (var r in records)
            {
                OperationTraceRecord operation = r as OperationTraceRecord;
                if (operation == null)
                {
                    OperationIgnoredTraceRecord ignored = r as OperationIgnoredTraceRecord;

                    if (ignored != null && ignored.FailoverUnitId == analysisEvent.TriggerReconfigurationCompletedTraceRecord.PartitionId)
                    {
                        ignoredDecisions.Add(ignored.DecisionId);
                        if (decisionOperationMap.ContainsKey(ignored.DecisionId))
                        {
                            effectiveOperationRecords.Remove(decisionOperationMap[ignored.DecisionId]);
                        }
                    }
                }
                else if (this.MatchPartitionSourceAndDestination(operation, analysisEvent) && !ignoredDecisions.Contains(operation.DecisionId))
                {
                    effectiveOperationRecords.Add(operation);
                    decisionOperationMap[operation.DecisionId] = operation;
                }
            }

            var effectiveOperationRecordsMatchingSourceTarget = effectiveOperationRecords.Where(r => r.SourceNode.StartsWith(analysisEvent.PreviousNode) && r.TargetNode.StartsWith(analysisEvent.CurrentNode));

            return(effectiveOperationRecords);
        }
        private async Task DecorateCorrelationAttributeAsync(Duration duration, IList <FabricEvent> partitionEvents, CancellationToken token)
        {
            var newTimeDuration = new Duration(
                duration.StartTime,
                DateTime.UtcNow - duration.EndTime > MaxDurationForCorrelatingEvent ? duration.EndTime + MaxDurationForCorrelatingEvent : DateTime.UtcNow);

            var filter = ReadFilter.CreateReadFilter(typeof(CorrelationTraceRecord));
            var allCorrelationTraces = (await this.traceStoreReader.ReadTraceRecordsAsync(newTimeDuration, filter, token).ConfigureAwait(false));

            foreach (var oneCorrelationTrace in allCorrelationTraces)
            {
                var castedRecord   = (CorrelationTraceRecord)oneCorrelationTrace;
                var matchingEvents = partitionEvents.Where(item => item.EventInstanceId == castedRecord.RelatedFromId || item.EventInstanceId == castedRecord.RelatedToId);
                if (matchingEvents.Any())
                {
                    foreach (var oneEvent in matchingEvents)
                    {
                        oneEvent.HasCorrelatedEvents = true;
                    }
                }
            }
        }
Exemple #13
0
 public static ReadFilter CreateClusterFilter(IList <Type> types)
 {
     return(ReadFilter.CreateReadFilter(types));
 }