none
Using the Event Flow Debugger

    问题

  • I have gone through the suggestions in various blogs (eg SQL Server Developer Center > SQL Server Forums > Microsoft StreamInsight > How to work with Event Flow Debugger? ) trying to connect to and get any useful data out of the event flow debugger.

    I have done the following:

    1. Started the StreamInsight service (not really sure if this is necessary)
    2. Added the user I am logged on as into the StreamInsight users group and logged off/on
    3. Added this code as suggested in the reference above:
                        ServiceHost host = new ServiceHost(CepServer.CreateManagementService());

                        host.AddServiceEndpoint(
                           typeof(IManagementService),
                           new WSHttpBinding(SecurityMode.Message),
                            "http://localhost/MyStreamInsightServer");
                        host.Open();

               below the line

                         CepServer = Server.Create(MyInstanceNamei);

    where u are instantiating server :-)

     

    and then u may connect to 
    http://localhost/MyStreamInsightServer

     

    4. I am able to connect the event flow debugger to the URL "http://localhost/MyStreamInsightServer/MyInstanceName, but not, as suggested immediately above, to http://localhost/MyStreamInsightServer. With the connection to the url above, though, I never actually see anything. If I try to expand the Applications node in the tree, it is always empty.

    I'd appreciate someone pointing out what I am missing here

    2012年3月13日 15:35

答案

  • Well, actually, if you aren't getting an exception with the event flow debugger, it is connecting to your endpoint.

    Now, I did run your code as Administrator (not just an admin on the box but as administrator with UAC) and it was all fine. When I ran without using "as Administrator" in UAC, the server was not created. Alternatively, you can run without UAC by using the netsh command. I mentioned this earlier. Also, try recording with trace.cmd as that will provide all of the events from initial startup through when you turn off the ETW session. Take a look at this, about halfway down, in the docs

    Now, your code does have an empty catch when you create the service and that may be hiding anything that's going on.


    DevBiker (aka J Sawyer)
    My Blog
    My Bike - Concours 14


    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.

    2012年3月14日 16:32
    版主
  • Thanks. I got it sorted out.

    I ran the netsh command:

    C:\Users\Administrator>netsh http add urlacl url=http://+:80/streaminsight/MyInstance user=<domain\user>

    I then modified my registerEndPoint method as follows: Changed the port to match the port I referred to in the netsh command and also add MyInstance to the URI

            private static void RegisterEndpoint(Server cepServer)
            {
                try
                {
                    RegisterManagementService(cepServer,
                        http://localhost:80/StreamInsight/MyInstance);
                }
                catch (Exception ex0)
                {
                }
            }       


    2012年3月14日 20:47

全部回复

  • I don't see anything wrong with you code to create the service ... that should work. And if the query debugger isn't giving you an error when you try to connect to the URL, it is. I don't see that your code creates the application ... is that in some code that you've not posted?


    DevBiker (aka J Sawyer)
    My Blog
    My Bike - Concours 14


    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.

    2012年3月13日 16:15
    版主
  • To try to get things working, I have been working on the TrafficJoinQuery sample rather than my production environment, and have been trying to view it in EventFlowDebugger. This is a snippet from that code:

    using (Server server = Server.Create("MyInstance"))
                {
                    try
                    {
                        RegisterEndpoint(server);
                        // Create application in the server. The application will serve 
                        // as a container for actual CEP objects ad queries.
                        Console.WriteLine("Creating CEP Application");
                        Application application = server.CreateApplication("TrafficJoinSample");
                        // Create query logic as a query template
                        Console.WriteLine("Registering LINQ query template");
                        QueryTemplate queryTemplate = CreateQueryTemplate(application);
                        // Register adapter factories, so that the engine will be able 
                        // to instantiate adapters when the query starts.
                        Console.WriteLine("Registering Adapter Factories");
                        InputAdapter csvInputAdapter = application.CreateInputAdapter<TextFileReaderFactory>("CSV Input", "Reading tuples from a CSV file");
                        OutputAdapter csvOutputAdapter = application.CreateOutputAdapter<TextFileWriterFactory>("CSV Output", "Writing result events to a CSV file");
                        // bind query to event producers and consumers
                        QueryBinder queryBinder = BindQuery(csvInputAdapter, csvOutputAdapter, queryTemplate);
                        // Create bound query that can be run
                        Console.WriteLine("Registering bound query");
                        Query query = application.CreateQuery("TrafficSensorQuery", "Minute average count, filtered by location threshold", queryBinder);
                        Console.WriteLine("Start query");
                        // Start the query
                        query.Start();
                        // Wait for the query to be suspended - that is the state
                        // it will be in as soon as the output adapter stops due to
                        // the end of the stream.
                        DiagnosticView dv = server.GetDiagnosticView(query.Name);
                        while ((string)dv[DiagnosticViewProperty.QueryState] == "Running")
                        {
                            // Sleep for 1s and check again
                            Thread.Sleep(1000);
                            dv = server.GetDiagnosticView(query.Name);
                        }
                        // Retrieve some diagnostic information from the CEP server
                        // about the query.
                        Console.WriteLine(string.Empty);
                        RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/EventManager")), Console.Out);
                        RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/PlanManager")), Console.Out);
                        RetrieveDiagnostics(server.GetDiagnosticView(new Uri("cep:/Server/Application/TrafficJoinSample/Query/TrafficSensorQuery")), Console.Out);
                        Console.WriteLine("\npress enter to exit application");
                        Console.ReadLine();
                        query.Stop();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        Console.ReadLine();
                    }
                }

    and the RegsiterEndPoint methods

            private static void RegisterEndpoint(Server cepServer)
            {
                try
                {
                    RegisterManagementService(cepServer,
                        "http://localhost:8080/StreamInsight");
                }
                catch (Exception ex0)
                {
                }
            }       
            private static void RegisterManagementService(Server cepServer, 
                string hostUrl)
            {         
                /////////////////////////////////////////////////////////
                // Register the management service
                var service = cepServer.CreateManagementService();
                System.ServiceModel.ServiceHost cepManagementHost = new System.ServiceModel.ServiceHost(service);
                cepManagementHost.AddServiceEndpoint(
                    typeof(IManagementService),
                    new System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.Message),
                    hostUrl);
                cepManagementHost.Open();
     
            }

    2012年3月14日 11:05
  • Have you tried using trace.cmd to record the events?

    DevBiker (aka J Sawyer)
    My Blog
    My Bike - Concours 14


    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.

    2012年3月14日 14:59
    版主
  • Also, do you get an exception when registering the management service? You should write to the console in your catch block to see what happens. If you haven't used netsh to add an ACL to that URL or run Visual Studio as Adminnistrator, the registration will not work and you'll get an exception.

    DevBiker (aka J Sawyer)
    My Blog
    My Bike - Concours 14


    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.

    2012年3月14日 15:05
    版主
  • I am running it in CS as an admin on the machine. There is no exception being thrown when registering the management service. It all appears to be working as expected, except that I don't see anything useful in the event flow debugger
    2012年3月14日 15:35
  • Well, actually, if you aren't getting an exception with the event flow debugger, it is connecting to your endpoint.

    Now, I did run your code as Administrator (not just an admin on the box but as administrator with UAC) and it was all fine. When I ran without using "as Administrator" in UAC, the server was not created. Alternatively, you can run without UAC by using the netsh command. I mentioned this earlier. Also, try recording with trace.cmd as that will provide all of the events from initial startup through when you turn off the ETW session. Take a look at this, about halfway down, in the docs

    Now, your code does have an empty catch when you create the service and that may be hiding anything that's going on.


    DevBiker (aka J Sawyer)
    My Blog
    My Bike - Concours 14


    If I answered your question, please mark as answer.
    If my post was helpful, please mark as helpful.

    2012年3月14日 16:32
    版主
  • Thanks. I got it sorted out.

    I ran the netsh command:

    C:\Users\Administrator>netsh http add urlacl url=http://+:80/streaminsight/MyInstance user=<domain\user>

    I then modified my registerEndPoint method as follows: Changed the port to match the port I referred to in the netsh command and also add MyInstance to the URI

            private static void RegisterEndpoint(Server cepServer)
            {
                try
                {
                    RegisterManagementService(cepServer,
                        http://localhost:80/StreamInsight/MyInstance);
                }
                catch (Exception ex0)
                {
                }
            }       


    2012年3月14日 20:47