Пример #1
0
 public NodeInfo(ILogSource logSource, NodeId nodeId,
                 ILogPartToken logPart, IEnumerable <M.Event> messages,
                 ISameNodeDetectionToken sameNodeDetectionToken)
 {
     LogSources             = new [] { logSource };
     NodeId                 = nodeId;
     LogPart                = logPart;
     Messages               = messages;
     SameNodeDetectionToken = sameNodeDetectionToken;
 }
Пример #2
0
        SameNodeDetectionResult ISameNodeDetectionToken.DetectSameNode(ISameNodeDetectionToken otherNodeToken)
        {
            var otherChromiumNode = otherNodeToken as NodeDetectionToken;

            if (otherChromiumNode == null)
            {
                return(null);
            }
            if (!this.processIds.Overlaps(otherChromiumNode.processIds))
            {
                return(null);
            }
            foreach (var candidate in this.iceCandidates)
            {
                ICECandidateInfo otherCandidate;
                if (otherChromiumNode.iceCandidates.TryGetValue(candidate.Key, out otherCandidate))
                {
                    var diff = Math.Round((candidate.Value.CreationTime - otherCandidate.CreationTime).TotalMinutes);
                    return(new SameNodeDetectionResult()
                    {
                        TimeDiff = TimeSpan.FromMinutes(diff)
                    });
                }
            }

            // console logging matching is used to match chromedebug and chromedriver logs
            // that both record console logging
            var loggingDiffs = new Dictionary <int, int>();

            foreach (var log in this.logEntries)
            {
                ConsoleLogEntry otherLog;
                if (otherChromiumNode.logEntries.TryGetValue(log.Key, out otherLog))
                {
                    var diff  = (int)Math.Round((log.Value.Timestamp - otherLog.Timestamp).TotalMinutes);
                    int count = 0;
                    loggingDiffs.TryGetValue(diff, out count);
                    loggingDiffs[diff] = count + 1;
                }
            }
            var topLogDiffs = loggingDiffs.OrderByDescending(x => x.Value).Take(2).ToArray();
            var minLogCount = 5;

            if ((topLogDiffs.Length == 1 && topLogDiffs[0].Value > minLogCount) ||
                (topLogDiffs.Length == 2 && (topLogDiffs[0].Value - topLogDiffs[1].Value) > minLogCount))
            {
                return(new SameNodeDetectionResult()
                {
                    TimeDiff = TimeSpan.FromMinutes(topLogDiffs[0].Key)
                });
            }

            return(null);
        }
Пример #3
0
        void ISameNodeDetectionTokenFactories.SafeWriteTo(ISameNodeDetectionToken token, XmlWriter writer)
        {
            if (token == null)
            {
                return;
            }
            var tokenElt = new XElement(sameNodeDetectionTokenEltName);

            token.Serialize(tokenElt);
            tokenElt.SetAttributeValue(factoryAttributeName, token.Factory.Id);
            tokenElt.WriteTo(writer);
        }
Пример #4
0
 bool ISameNodeDetectionTokenFactories.TryReadLogPartToken(XElement element, out ISameNodeDetectionToken token)
 {
     token = null;
     if (element != null && element.Name.LocalName == sameNodeDetectionTokenEltName)
     {
         var factoryId = element.AttributeValue(factoryAttributeName);
         if (factories.TryGetValue(factoryId, out var tokenFactory))
         {
             token = tokenFactory.Deserialize(element);
         }
     }
     return(token != null);
 }
Пример #5
0
        public PostprocessorOutput(
            LogSourcePostprocessorDeserializationParams p,
            ILogPartTokenFactories rotatedLogPartFactories,
            ISameNodeDetectionTokenFactories nodeDetectionTokenFactories)
        {
            this.logSource = p.LogSource;
            var reader = p.Reader;

            events = new List <M.Event>();
            rotatedLogPartToken    = new NullLogPartToken();
            sameNodeDetectionToken = new NullSameNodeDetectionToken();

            if (!reader.ReadToFollowing("root"))
            {
                throw new FormatException();
            }
            etag.Read(reader);

            foreach (var elt in p.Reader.ReadChildrenElements())
            {
                if (rotatedLogPartFactories.TryReadLogPartToken(elt, out var tmp))
                {
                    this.rotatedLogPartToken = tmp;
                }
                else if (nodeDetectionTokenFactories.TryReadLogPartToken(elt, out var tmp2))
                {
                    sameNodeDetectionToken = tmp2;
                }
                else if (elt.Name == messagingEventsElementName)
                {
                    var eventsDeserializer = new M.EventsDeserializer(TextLogEventTrigger.DeserializerFunction);
                    foreach (var me in elt.Elements())
                    {
                        if (eventsDeserializer.TryDeserialize(me, out var evt))
                        {
                            events.Add(evt);
                        }
                    }
                }
                p.Cancellation.ThrowIfCancellationRequested();
            }
        }
Пример #6
0
 SameNodeDetectionResult ISameNodeDetectionToken.DetectSameNode(ISameNodeDetectionToken otherNodeToken)
 {
     return(null);
 }
Пример #7
0
 SameNodeDetectionResult ISameNodeDetectionToken.DetectSameNode(ISameNodeDetectionToken otherNodeToken) => null;