Ejemplo n.º 1
0
 private static void InitializeDiagnosticSettings()
 {
     lock (s_DiagnosticsInitializationLock)
     {
         if (s_DiagnosticSettings == DiagnosticSettings.Uninitialized)
         {
             try
             {
                 using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\Diagnostics"))
                 {
                     if ((key != null) && (0 != ((int)key.GetValue("SecurityContextStackTrace", 0))))
                     {
                         s_DiagnosticSettings |= DiagnosticSettings.CaptureStackTrace;
                     }
                 }
                 if (s_DiagnosticSettings == DiagnosticSettings.Uninitialized)
                 {
                     s_DiagnosticSettings = DiagnosticSettings.Disabled;
                 }
             }
             catch
             {
                 s_DiagnosticSettings = DiagnosticSettings.Disabled;
             }
         }
     }
 }
 private void AreEqual(DiagnosticSettings exp, DiagnosticSettings act)
 {
     if (exp != null)
     {
         Assert.Equal(exp.Description, act.Description);
         Assert.Equal(exp.Name, act.Name);
         AreEqual(exp.PublicConfiguration, act.PublicConfiguration);
     }
 }
        public PeerStatisticsCollector(IAsyncProvider asyncProvider, ISignals signals, DiagnosticSettings diagnosticSettings, INodeLifetime nodeLifetime)
        {
            this.asyncProvider      = asyncProvider;
            this.signals            = Guard.NotNull(signals, nameof(signals));
            this.nodeLifetime       = nodeLifetime;
            this.diagnosticSettings = Guard.NotNull(diagnosticSettings, nameof(diagnosticSettings));

            this.eventSubscriptions = new List <SubscriptionToken>();
            this.peersStatistics    = new Dictionary <IPEndPoint, PeerStatistics>();

            this.lockStartStopCollecting = new object();
        }
Ejemplo n.º 4
0
        public void MonitorPerformance(Server server, string fileName)
        {
            RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Application/serverApp/Entity/process/Query/StreamableBinding_1")), "notImp.txt");

            DiagnosticSettings settings = new DiagnosticSettings(DiagnosticAspect.DiagnosticViews, DiagnosticLevel.Always);

            server.SetDiagnosticSettings(new Uri("cep:/Server"), settings);
            //RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Query")), "notImp.txt");

            RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Application/serverApp/Entity/process/Query/StreamableBinding_1")), fileName);

//            DiagnosticSettings set = server.GetDiagnosticSettings(new Uri("cep:/Server/Application/serverApp/Entity/process/Query/StreamableBinding_1"));
//            set.Aspects |= DiagnosticAspect.PerformanceCounters;
//            server.SetDiagnosticSettings(new Uri("cep:/Server/Application/serverApp/Query/StreamableBinding_1"), settings);
//
//
//
//
//            RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Application/serverApp/Entity/process/Query/StreamableBinding_1")), "counters.txt");
        }
        internal static void Main()
        {
            using (var server = Server.Create("Default"))
            {
                // If you want to publish this server, or connect to an already existing server,
                // please see the product documentation "Publishing and Connecting to a StreamInsight Server"
                // to find out how to replace, or add to the above server creation code. You must publish
                // the server for the Event Flow debugger to be able to connect to the server.
                var application = server.CreateApplication("TutorialApp");

                // Define device configuration
                var inputConfig = new CsvInputConfig
                {
                    InputFileName = @"..\..\..\TollInput.txt",
                    Delimiter     = new char[] { ',' },
                    BufferSize    = 4096,
                    CtiFrequency  = 1,
                    CultureName   = "en-US",
                    Fields        = new List <string>()
                    {
                        "TollId", "LicensePlate", "State", "Make", "Model", "VehicleType", "VehicleWeight", "Toll", "Tag"
                    },
                    NonPayloadFieldCount = 2,
                    StartTimePos         = 1,
                    EndTimePos           = 2
                };

                var outputConfigForPassThroughQuery = new CsvOutputConfig
                {
                    // The adapter recognizes empty filename as a write to console
                    OutputFileName = string.Empty,
                    Delimiter      = new string[] { "\t" },
                    CultureName    = "en-US",
                    Fields         = new List <string>()
                    {
                        "TollId", "LicensePlate", "State", "Make", "Model", "VehicleType", "VehicleWeight", "Toll", "Tag"
                    }
                };

                var outputConfigForCountQuery = new CsvOutputConfig
                {
                    OutputFileName = string.Empty,
                    Delimiter      = new string[] { "\t" },
                    CultureName    = "en-US",
                    Fields         = new List <string>()
                    {
                        "Count"
                    }
                };

                // Define console trace listener
                TraceListener tracer = new ConsoleTraceListener();

                // set up advance time settings to enqueue CTIs - to deliver output in a timely fashion
                var advanceTimeGenerationSettings = new AdvanceTimeGenerationSettings(inputConfig.CtiFrequency, TimeSpan.Zero, true);
                var advanceTimeSettings           = new AdvanceTimeSettings(advanceTimeGenerationSettings, null, AdvanceTimePolicy.Adjust);

                // Define input stream object, mapped to stream names
                // Instantiate an adapter from the input factory class
                var inputStream = CepStream <TollReading> .Create(
                    "TollStream",
                    typeof(CsvInputFactory),
                    inputConfig,
                    EventShape.Interval,
                    advanceTimeSettings);


                var passthroughQuery = from e in inputStream select e;

                var countQuery = from w in inputStream.TumblingWindow(TimeSpan.FromMinutes(3), HoppingWindowOutputPolicy.ClipToWindowEnd)
                                 select new TollCount {
                    Count = w.Count()
                };

                // Create a runnable query by binding the query template to the
                // input stream of interval events, and to an output stream of
                // fully ordered point events (through an output adapter instantiated
                // from the output factory class)
                Query query = countQuery.ToQuery(
                    application,
                    "HelloTollTutorial",
                    "Hello Toll Query",
                    typeof(CsvOutputFactory),
                    outputConfigForCountQuery,
                    EventShape.Interval,
                    StreamEventOrder.FullyOrdered);

                query.Start();

                Console.WriteLine("*** Hit Return to see Query Diagnostics after this run ***");
                Console.WriteLine();
                Console.ReadLine();

                // Retrieve  diagnostic information from the CEP server about the query.
                // See the section "Connecting to and Publishing a Server" in the StreamInsight MSDN documentation on
                // how to make the debugger client connect to the server and retrieve these diagnostics
                Console.WriteLine(string.Empty);
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/EventManager")), tracer);
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/PlanManager")), tracer);
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Application/TutorialApp/Query/HelloTollTutorial")), tracer);

                DiagnosticSettings settings = new DiagnosticSettings(DiagnosticAspect.GenerateErrorReports, DiagnosticLevel.Always);
                server.SetDiagnosticSettings(new Uri("cep:/Server"), settings);

                tracer.WriteLine("Global Server Diagnostics");
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/EventManager")), tracer);
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/PlanManager")), tracer);
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Query")), tracer);
                tracer.WriteLine(string.Empty);
                tracer.WriteLine("Summary Query Diagnostics for");
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Application/TutorialApp/Query/HelloTollTutorial")), tracer);
                tracer.WriteLine(string.Empty);

                query.Stop();

                Console.WriteLine("*** Query Completed *** Hit Return to Exit");
                Console.WriteLine();
                Console.ReadLine();
            }

            return;
        }
        /// <summary>
        /// analyze data object event flow
        /// </summary>
        public void App(int TimeStamp)
        {
            Console.WriteLine("Starting observable source...");
            using (var source = new RandomObject <Car>(NoSeconds, NoValues, CountMax, NoSegments, TimeStamp))//genereaza o data la fiecare 500 milisecunde
            {
                Console.WriteLine("Started observable source.");
                using (var server = Server.Create("Default"))
                {
                    var host = new ServiceHost(server.CreateManagementService());
                    host.AddServiceEndpoint(typeof(IManagementService), new WSHttpBinding(SecurityMode.Message), "http://localhost/MyStreamInsightApp");
                    host.Open();
                    var myApp = server.CreateApplication("serverApp");
                    Console.WriteLine("convert source to stream");
                    var stream = source.ToPointStream(myApp,
                                                      e => PointEvent.CreateInsert(DateTime.Now, new Payload <Car> {
                        Value = e
                    }),
                                                      AdvanceTimeSettings.StrictlyIncreasingStartTime,
                                                      "Observable Stream");

                    //Console.ReadLine()
                    ;
                    //query that sums of events within 2 second tumbling windows
                    var thumblingResult = from ob in stream.TumblingWindow(TimeSpan.FromSeconds(2), HoppingWindowOutputPolicy.ClipToWindowEnd)
                                          select new
                    {
                        avreageT = ob.Avg(e => e.Value.Speed),
                    };
                    //List<double> list;
                    //var query = from ob in stream
                    //            where ob.Value.Speed < 50
                    //            select ob.Value;
                    //var query = from cars in stream.SnapshotWindow()
                    //                     select new {
                    //                         avreage = cars.Avg(e => e.Value.Speed),
                    //                         groupId=1
                    //                    };
                    //var query = from ob in stream.HoppingWindow(TimeSpan.FromSeconds(WinSize), TimeSpan.FromSeconds(1))
                    //            select new
                    //            {
                    //                avreage = ob.Avg(e => e.Value.Speed),
                    //                groupId = 1
                    //            };
                    var query = from rs in stream
                                group rs by rs.Value.RoadSegment into roadSeg
                                from ob in roadSeg.HoppingWindow(TimeSpan.FromSeconds(WinSize), TimeSpan.FromSeconds(5))
                                select new
                    {
                        avreage = ob.Avg(e => e.Value.Speed),
                        groupId = roadSeg.Key
                    };
                    //var query = from rs in stream
                    //            group rs by rs.Value.RoadSegment into roadSeg
                    //            from ob in roadSeg.SnapshotWindow()
                    //            select new
                    //            {
                    //                avreage = ob.Avg(e => e.Value.Speed),
                    //                groupId = roadSeg.Key
                    //            };



                    var enumerator = query.ToPointEnumerable().GetEnumerator();

                    while (enumerator.MoveNext())
                    {
                        if (enumerator.Current.EventKind == EventKind.Insert)
                        {
                            var s = enumerator.Current.Payload.ToString();
                            //if (s.Length > 0)
                            //    DB.Write(s);
                            //Console.WriteLine(s);
                            DB.Write(TimeStamp, s);

                            RetrieveDiagnostics rD = new RetrieveDiagnostics();

                            DiagnosticSettings settings = new DiagnosticSettings(DiagnosticAspect.GenerateErrorReports, DiagnosticLevel.Always);
                            server.SetDiagnosticSettings(new Uri("cep:/Server"), settings);
                            rD.FileWrite(server.GetDiagnosticView(new Uri("cep:/Server/EventManager")), WinSize);
                            rD.FileWrite(server.GetDiagnosticView(new Uri("cep:/Server/Query")), WinSize);
                        }
                    }

                    host.Close();
                }
                //Count<Car> count = new Count<Car>(50);
                //Console.WriteLine("-------------" + count.NoOptimal);
                Console.WriteLine("The end");

                source.OnCompleted();
            }
            Console.WriteLine("Stopped observable source.");
            //Console.ReadLine();
        }
Ejemplo n.º 7
0
        internal static void Main()
        {
            using (var server = Server.Create("Default"))
            {
                // If you want to publish this server, or connect to an already existing server,
                // please see the product documentation "Publishing and Connecting to a StreamInsight Server"
                // to find out how to replace, or add to the above server creation code. You must publish
                // the server for the Event Flow debugger to be able to connect to the server.
                var application = server.CreateApplication("TutorialApp");

                // Define device configuration
                var inputConfig = new CsvInputConfig
                {
                    InputFileName = @"..\..\..\TollInput.txt",
                    Delimiter = new char[] { ',' },
                    BufferSize = 4096,
                    CtiFrequency = 1,
                    CultureName = "en-US",
                    Fields = new List<string>() { "TollId", "LicensePlate", "State", "Make", "Model", "VehicleType", "VehicleWeight", "Toll", "Tag" },
                    NonPayloadFieldCount = 2,
                    StartTimePos = 1,
                    EndTimePos = 2
                };

                var outputConfigForPassThroughQuery = new CsvOutputConfig
                {
                    // The adapter recognizes empty filename as a write to console
                    OutputFileName = string.Empty,
                    Delimiter = new string[] { "\t" },
                    CultureName = "en-US",
                    Fields = new List<string>() { "TollId", "LicensePlate", "State", "Make", "Model", "VehicleType", "VehicleWeight", "Toll", "Tag" }
                };

                var outputConfigForCountQuery = new CsvOutputConfig
                {
                    OutputFileName = string.Empty,
                    Delimiter = new string[] { "\t" },
                    CultureName = "en-US",
                    Fields = new List<string>() { "Count" }
                };

                // Define console trace listener
                TraceListener tracer = new ConsoleTraceListener();

                // set up advance time settings to enqueue CTIs - to deliver output in a timely fashion
                var advanceTimeGenerationSettings = new AdvanceTimeGenerationSettings(inputConfig.CtiFrequency, TimeSpan.Zero, true);
                var advanceTimeSettings = new AdvanceTimeSettings(advanceTimeGenerationSettings, null, AdvanceTimePolicy.Adjust);

                // Define input stream object, mapped to stream names
                // Instantiate an adapter from the input factory class
                var inputStream = CepStream<TollReading>.Create(
                                    "TollStream",
                                    typeof(CsvInputFactory),
                                    inputConfig,
                                    EventShape.Interval,
                                    advanceTimeSettings);

                var passthroughQuery = from e in inputStream select e;

                var countQuery = from w in inputStream.TumblingWindow(TimeSpan.FromMinutes(3), HoppingWindowOutputPolicy.ClipToWindowEnd)
                                    select new TollCount { Count = w.Count() };

                // Create a runnable query by binding the query template to the
                // input stream of interval events, and to an output stream of
                // fully ordered point events (through an output adapter instantiated
                // from the output factory class)
                Query query = countQuery.ToQuery(
                                    application,
                                    "HelloTollTutorial",
                                    "Hello Toll Query",
                                    typeof(CsvOutputFactory),
                                    outputConfigForCountQuery,
                                    EventShape.Interval,
                                    StreamEventOrder.FullyOrdered);

                query.Start();

                Console.WriteLine("*** Hit Return to see Query Diagnostics after this run ***");
                Console.WriteLine();
                Console.ReadLine();

                // Retrieve  diagnostic information from the CEP server about the query.
                // See the section "Connecting to and Publishing a Server" in the StreamInsight MSDN documentation on
                // how to make the debugger client connect to the server and retrieve these diagnostics
                Console.WriteLine(string.Empty);
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/EventManager")), tracer);
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/PlanManager")), tracer);
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Application/TutorialApp/Query/HelloTollTutorial")), tracer);

                DiagnosticSettings settings = new DiagnosticSettings(DiagnosticAspect.GenerateErrorReports, DiagnosticLevel.Always);
                server.SetDiagnosticSettings(new Uri("cep:/Server"), settings);

                tracer.WriteLine("Global Server Diagnostics");
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/EventManager")), tracer);
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/PlanManager")), tracer);
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Query")), tracer);
                tracer.WriteLine(string.Empty);
                tracer.WriteLine("Summary Query Diagnostics for");
                RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Application/TutorialApp/Query/HelloTollTutorial")), tracer);
                tracer.WriteLine(string.Empty);

                query.Stop();

                Console.WriteLine("*** Query Completed *** Hit Return to Exit");
                Console.WriteLine();
                Console.ReadLine();
            }

            return;
        }