Exemplo n.º 1
0
        protected override void ProcessMessage(PipeMessageEnvelope envelope)
        {
            if (null == envelope)
            {
                throw new ArgumentNullException("envelope");
            }

            try
            {
                if (!ThreadsLinkingRequested && !IsOverlay)
                {
                    Tracer.Error("Threads linking was not requested, but threads linker still got a message!\r\n"
                                 + "    Label = {0}, Body is {1}", envelope.Label,
                                 (envelope.Body == null) ? "null" : envelope.Body.GetType().FullName);
                    return;
                }

                if (envelope.Label == "EndOfDataMarker")
                {
                    FinalizeRelationships();

                    if (FamiliesLinkingRequested || IsOverlay)
                    {
                        // When both linkings are requested it is responsibility of threads linker
                        // to tell to family linker when it can finalize the data
                        SendEndOfDataMarkerToFamiliesLinker();
                    }
                    return;
                }

                var threadsInfo = envelope.Body as ThreadsInfo;
                if (threadsInfo != null)
                {
                    //Tracer.Warning("Starting intermediate threads calculations");
                    var threadsCalculationResults = _threadsProcessor.ProcessThreadsInfo(threadsInfo);
                    resultsAccumulator.Append(threadsCalculationResults);

                    // Plan B: we don't do intermediate production now.
                    //Tracer.Warning("Starting intermediate threads production");
                    //ProduceThreadsRecords(threadsCalculationResults);
                    //Tracer.Warning("Finished intermediate threads production");
                }
            }
            catch (Exception ex)
            {
                ReportToDirector(ex);
                ex.Trace().Swallow();
            }
        }