コード例 #1
0
        private DtsLogEvent ProcessEvent(string sFullEventRow)
        {
            //Columns: event,computer,operator,source,sourceid,executionid,starttime,endtime,datacode,databytes,message
            string[] sColumns = sFullEventRow.Split(new char[] { ',' }, 11);
            if (sColumns[0].StartsWith("User:"******"User:"******"User:"******"could not parse start time");
                return(null);
            }
            if (!DateTime.TryParse(sColumns[7], out e.EndTime))
            {
                System.Diagnostics.Debug.WriteLine("could not parse end time");
                return(null);
            }

            e.Message = sColumns[10];
            return(e);
        }
コード例 #2
0
 public void Log(string eventName, string computerName, string operatorName, string sourceName, string sourceGuid, string executionGuid, string messageText, DateTime startTime, DateTime endTime, int dataCode, ref byte[] dataBytes)
 {
     if (listMonitoredEventNames.Contains(eventName))
     {
         DtsLogEvent e = new DtsLogEvent();
         e.Event = (BidsHelperCapturedDtsLogEvent)System.Enum.Parse(typeof(BidsHelperCapturedDtsLogEvent), eventName);
         e.SourceName = sourceName;
         e.SourceId = sourceGuid;
         e.StartTime = startTime;
         e.EndTime = endTime;
         e.Message = messageText;
         this.LoadEvent(e);
     }
 }
コード例 #3
0
        public void LoadEvent(DtsLogEvent e)
        {
            if (!listComponentsPerformanceLookup.ContainsKey(e.SourceId)) return;
            DtsObjectPerformance perf = listComponentsPerformanceLookup[e.SourceId];
            if (e.Event == BidsHelperCapturedDtsLogEvent.OnPipelineRowsSent)
            {
                //<ignore> : <ignore> : PathID : PathName : TransformID : TransformName : InputID : InputName : RowsSent
                //Denali includes the following at the end... DestinationTransformName : Paths[SourceName.SourceOutputName] : DestinationTransformName.Inputs[InputName]
                DtsPipelinePerformance pipePerf = (DtsPipelinePerformance)perf;
                string[] parts = e.Message.Split(new string[] { " : " }, StringSplitOptions.None);
                int iPathID = int.Parse(parts[2]);
                int iInputID = int.Parse(parts[6]);
                if (pipePerf.InputOutputLookup.ContainsKey(iInputID))
                {
                    PipelinePath path = pipePerf.InputOutputLookup[iInputID];
                    path.DateRanges.Add(new DateRange(e.StartTime, e.EndTime));
                    path.RowCount += int.Parse(parts[8]);
                    path.BufferCount++;
                    
                }
            }
            else if (e.Event == BidsHelperCapturedDtsLogEvent.OnPipelinePrePrimeOutput)
            {
                //PrimeOutput will be called on a component. : 28490 : Flat File Source 1
                //<ignore> : TransformID : TransformName
                DtsPipelinePerformance pipePerf = (DtsPipelinePerformance)perf;
                string[] parts = e.Message.Split(new string[] { " : " }, StringSplitOptions.None);
                int iTransformID = int.Parse(parts[1]);
                foreach (ExecutionTree tree in pipePerf.ExecutionTrees)
                {
                    if (tree.Paths.Count > 0)
                    {
                        PipelinePath path = tree.Paths[0]; //only look for the component on the output of the first path
                        if (path.OutputTransformID == iTransformID)
                        {
                            tree.DateRanges.Add(new DateRange(e.StartTime));
                            //break; //there could be multiple execution trees started by the same component?
                        }
                    }
                }
            }
            else if (e.Event == BidsHelperCapturedDtsLogEvent.OnPipelinePostEndOfRowset)
            {
                //A component has finished processing all of its rows. : 30341 : Multicast : 30342 : Multicast Input 1
                //<ignore> : TransformID : TransformName : InputID : InputName
                DtsPipelinePerformance pipePerf = (DtsPipelinePerformance)perf;
                string[] parts = e.Message.Split(new string[] { " : " }, StringSplitOptions.None);
                int iInputID = int.Parse(parts[3]);

                foreach (ExecutionTree tree in pipePerf.ExecutionTrees)
                {
                    foreach (PipelinePath path in tree.Paths)
                    {
                        if (path.InputID == iInputID)
                        {
                            if (tree.DateRanges.Count > 0) //this is to avoid an error on issue 31275 where OnPipelinePrePrimeOutput wasn't ever called so we didn't start a date range
                            {
                                DateRange lastDateRange = tree.DateRanges[tree.DateRanges.Count - 1];
                                if (lastDateRange.EndDate == DateTime.MinValue)
                                {
                                    lastDateRange.EndDate = e.EndTime;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            else if (e.Event == BidsHelperCapturedDtsLogEvent.OnPreExecute)
            {
                perf.DateRanges.Add(new DateRange(e.StartTime));
            }
            else if (e.Event == BidsHelperCapturedDtsLogEvent.OnPostExecute)
            {
                if (perf.DateRanges.Count > 0)
                {
                    DateRange lastDateRange = perf.DateRanges[perf.DateRanges.Count - 1];
                    if (lastDateRange.EndDate == DateTime.MinValue)
                    {
                        lastDateRange.EndDate = e.EndTime;
                    }
                }
            }
            else if (e.Event == BidsHelperCapturedDtsLogEvent.PipelineExecutionTrees)
            {
                DtsPipelinePerformance pipePerf = (DtsPipelinePerformance)perf;
                ExecutionTree tree = null;
                foreach (string line in e.Message.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                {
                    if (line.StartsWith(EXECUTION_TREE_START_PHRASE))
                    {
                        int iTreeID = int.Parse(line.Substring(EXECUTION_TREE_START_PHRASE.Length));
                        tree = new ExecutionTree();
                        tree.ID = iTreeID;
                        tree.UniqueId = pipePerf.ID + "ExecutionTree" + iTreeID;
                        tree.Name = "Execution Tree " + iTreeID;

                        bool bFoundTree = false;
                        foreach (ExecutionTree t in pipePerf.ExecutionTrees)
                        {
                            if (t.ID == tree.ID)
                            {
                                bFoundTree = true;
                                break;
                            }
                        }
                        if (!bFoundTree)
                            pipePerf.ExecutionTrees.Add(tree);
                    }
                    else if (line.StartsWith(EXECUTION_TREE_END_PHRASE))
                    {
                        //skip line
                    }
                    else
                    {
                        Match match = regexExecutionTreeOutput.Match(line);

#if DENALI || SQL2014
                        if (match.Groups.Count == 3)
                        {
                            string sComponent = match.Groups[1].Value;
                            string sOutput = match.Groups[2].Value;
                            foreach (PipelinePath path in pipePerf.InputOutputLookup.Values)
                            {
                                if (path.OutputName == sOutput && path.OutputTransformName == sComponent && !tree.Paths.Contains(path))
                                {
                                    tree.Paths.Add(path);
                                }
                            }
                        }
#else
                        if (match.Groups.Count == 2)
                        {
                            int iOutputID = int.Parse(match.Groups[1].Value);
                            if (pipePerf.InputOutputLookup.ContainsKey(iOutputID) && !tree.Paths.Contains(pipePerf.InputOutputLookup[iOutputID]))
                                tree.Paths.Add(pipePerf.InputOutputLookup[iOutputID]);
                        }
#endif
                    }
                }
            }
            else if (e.Event == BidsHelperCapturedDtsLogEvent.PipelineExecutionPlan)
            {
                DtsPipelinePerformance pipePerf = (DtsPipelinePerformance)perf;
                foreach (string line in e.Message.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                {
                    Match match = regexCreateBuffer.Match(line);
                    if (match.Groups.Count == 3)
                    {
                        int iBufferID = int.Parse(match.Groups[1].Value) - 1;
                        int iBufferRowCount = pipePerf.GetBufferRowCount(iBufferID);
                        int iOutputID = int.Parse(match.Groups[2].Value);
                        foreach (ExecutionTree tree in pipePerf.ExecutionTrees)
                        {
                            foreach (PipelinePath path in tree.Paths)
                            {
                                if (path.OutputID == iOutputID)
                                {
                                    tree.BufferRowCount = iBufferRowCount;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            else if (e.Event == BidsHelperCapturedDtsLogEvent.BufferSizeTuning)
            {
                DtsPipelinePerformance pipePerf = (DtsPipelinePerformance)perf;
                Match match = regexBufferSizeTuning.Match(e.Message);
                if (match.Groups.Count == 3)
                {
                    int iBufferID = int.Parse(match.Groups[1].Value);
                    int iBufferRowCount = int.Parse(match.Groups[2].Value);
                    pipePerf.SetBufferRowCount(iBufferID, iBufferRowCount);
                }
            }
            else if (e.Event == BidsHelperCapturedDtsLogEvent.OnError)
            {
                perf.IsError = true;
                this.Errors.Add(e.Message);
            }
            else if (e.Event == BidsHelperCapturedDtsLogEvent.PackageEnd)
            {
                this.PackageEndReceived = true;
            }
        }
コード例 #4
0
        public DtsLogEvent[] GetEvents(bool LogFileIsComplete)
        {
            lock (syncRoot)
            {
                ReadToEnd();

                _CharPosition = _EventParsedPosition;

                List <DtsLogEvent> list = new List <DtsLogEvent>();
                if (_EventParsedPosition == 0)
                {
                    //skip header row
                    string sHeader = ReadLine();
                    _EventParsedPosition += sHeader.Length;
                }

                StringBuilder sUnusedLines = new StringBuilder();
                while (_CharPosition < _LogFileCache.Length || LogFileIsComplete)
                {
                    long   lngLastPosition = _CharPosition;
                    string sLine           = ReadLine();

                    if (_CharPosition >= _LogFileCache.Length && LogFileIsComplete)
                    {
                        //if we've reached the end of the file, do one more loop and parse the last event
                        sLine = sUnusedLines.ToString() + sLine;
                    }

                    bool bIsNewEvent = false;
                    foreach (string sEvent in System.Enum.GetNames(typeof(BidsHelperCapturedDtsLogEvent)))
                    {
                        if (sLine.StartsWith(sEvent + ",") || sLine.StartsWith("User:"******","))
                        {
                            bIsNewEvent = true;
                            break;
                        }
                    }
                    if (bIsNewEvent && sUnusedLines.Length > 0)
                    {
                        System.Diagnostics.Debug.WriteLine("parsing event:");
                        System.Diagnostics.Debug.WriteLine(sUnusedLines.ToString());
                        DtsLogEvent e = ProcessEvent(sUnusedLines.ToString());
                        if (e != null)
                        {
                            list.Add(e);
                            sUnusedLines         = new StringBuilder();
                            _EventParsedPosition = lngLastPosition;
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("couldn't parse event: " + sUnusedLines.ToString());
                        }
                    }

                    if (_CharPosition >= _LogFileCache.Length && LogFileIsComplete)
                    {
                        break;
                    }

                    sUnusedLines.AppendLine(sLine);
                }
                System.Diagnostics.Debug.WriteLine("end of file");
                return(list.ToArray());
            }
        }