This discussion is archived
6 Replies Latest reply: Oct 3, 2012 1:25 PM by 938644 RSS

How to to programmatically create diagnostic profile : Please , Help!

938644 Newbie
Currently Being Moderated
Hi,
I already opened a question about that , but since I got a wrong answer ( I think , or i did something wrong ..) , and , since it is very
important for me :
May I have a full example showing how to create diagnostic profile programmatically ?
I tried many ways to do that , but nothing works !
Among the things i did was ( for example ) , something like this :

.......

DiagnosticProfileBean bean=new DiagnosticProfileBean();

// setting the bean ..
bean.setLatency(latency);
               bean.setThroughput(throughput);
               String profileName="EyalProfile";
     
               
               
               //DataAggregation d;
               bean.setProfileName(profileName);
               bean.setApplicationId("com.oracle.training.jms@defaultserver");
               //bean.setApplicationId("Application");
               bean.setState(true);
               bean.setStageObjectName(this.stageObjectIn);
               bean.setServerId("defaultserver");
.... and so on ..


     try {
          
          dataServiceName =ObjectName.getInstance("com.bea.wlevs:Name=DataServiceFactory,Type=DataServiceFactory,Application=com.oracle.cep.training.jms");
     
          //     DataServiceFactoryMBeanImpl dsfmb=     (DataServiceFactoryMBeanImpl) MBeanServerInvocationHandler.newProxyInstance(connection,dataServiceName, "com.bea.wlevs:Name=DataServiceFactory,Type=DataServiceFactory,Application=com.oracle.cep.training.jms", ObjectName.class, false);
          } catch (Exception e) {
     throw new RuntimeException(e);
     }
     DataServiceFactoryMBean dataServiceFactory=null;
     DiagnosticProfileBean bean=new DiagnosticProfileBean();
     
     try {
          
          dataServiceFactory=(DataServiceFactoryMBean) MBeanServerInvocationHandler.newProxyInstance(connection, dataServiceName, DataServiceFactoryMBean.class, false);
               // dataServiceFactory=(DataServiceFactoryMBean) MBeanServerInvocationHandler.newProxyInstance(connection, dataServiceName, DataServiceFactoryMBean.class, false);

it all works fine untul now , but when the program runs this :
          dataServiceFactory.createDiagnosticProfileMBean(bean, bean.getServerId());

I got the "InstanceNotFoundException " ..

It seems that the problem related to the connection object , but I'm not sure about it.
The connection was created in 2 different ways , neither of them worked.

1. ..
connector = JMXConnectorFactory.newJMXConnector(serviceUrl, env);
                         
                         connector.connect(env);
                         connection = connector.getMBeanServerConnection();
....
2.
...............

MBeanServer connection =ManagementFactory.getPlatformMBeanServer();
....

Does anyone have a clue about it??
Example ( that works ..) will be appriciated !

If someone has anothar way that works, it is OK to.just something to create a profile ..

Again, it very important for me, i'm stuck because of that .
Thanks.
  • 1. Re: How to to programmatically create diagnostic profile : Please , Help!
    722711 Explorer
    Currently Being Moderated
    Could you please clarify what you are trying to do? Are you attempting to get latency and throughput data?

    Thanks,
    Manju.
  • 2. Re: How to to programmatically create diagnostic profile : Please , Help!
    938644 Newbie
    Currently Being Moderated
    Are you attempting to get latency and throughput data?
    There are 2 things that I want to do :

    1. Getting the latency and throughput data: I'm doing that by folowing the example written in the manual ,under the title:
    " Programming with JMX " and " Dynamically Monitoring the Throughput and Latency of a Component " ...

    2. Getting the EPN via the DataAggregationMBean object:
    DataAggregationMBean aggregationMBean;
                   aggregationMBean.getEPN(arg0)...
    My problem is that with the first ( latency and throughput ) , all works fine , but , when i disconnect from the server ,
    and than reconnect , the numbers I got the first time , reduced ( i.e if in the first time I got 300, the next time I connected ' I got ~220 , and the next time ~120 , and so on ) . If i restart the cep server , than again the fisrt time is ok , than the same routine. I'm using the " terminate" method like it's recommended , but it seems
    that the MBean server didn't realy unregister the probes, so it looks like it ( the server ) " remembers" the previuos probes ,
    This is only my assumption, but it's the only reasonable thing i can think about.

    I notice that in the visualizer , when the user builds a profile, it all works fine. That's why i wan to use DiagnosticProfile ..


    2.As in the visualizer ' i want to have the EPN , or at least the order of the stages in the EPN.
    I saw that the 'DataAggregationMBean ' can have it' but i don't know how to get this object..

    Again, it is very important for me , because my whole project depends on it.

    Thanks for you help.
  • 3. Re: How to to programmatically create diagnostic profile : Please , Help!
    722711 Explorer
    Currently Being Moderated
    +"My problem is that with the first ( latency and throughput ) , all works fine , but , when i disconnect from the server ,+
    +and than reconnect , the numbers I got the first time , reduced ( i.e if in the first time I got 300, the next time I connected ' I got ~220 , and the next time ~120 , and so on ) . If i restart the cep server , than again the fisrt time is ok , than the same routine. I'm using the " terminate" method like it's recommended , but it seems+
    +that the MBean server didn't realy unregister the probes, so it looks like it ( the server ) " remembers" the previuos probes ,+
    +This is only my assumption, but it's the only reasonable thing i can think about."+

    I apologize if you already posted it once, but could you please post the code that gets the latency/throughput numbers and terminates?

    One thing to note that the latency will be a little higher right at the start until it stabilizes to a lower value. It is possible that you are seeing that effect.
  • 4. Re: How to to programmatically create diagnostic profile : Please , Help!
    938644 Newbie
    Currently Being Moderated
    Hi
    my project includes many files, but a attached thre relevant parts here :

    // connect to server ( like in the examples )

    ...
    env.put(JMXConnectorFactory.DEFAULT_CLASS_LOADER, com.bea.core.jmx.remote.provider.msarmi.ServerProvider.class.getClassLoader());
                             env.put(JMXConnectorFactory.PROTOCOL_PROVIDER_CLASS_LOADER, com.bea.core.jmx.remote.provider.msarmi.ServerProvider.class.getClassLoader());
                             JMXServiceURL serviceUrl = new JMXServiceURL("MSARMI", "localhost", port, "/jndi/jmxconnector");
                             
                             env.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,     "com.bea.core.jmx.remote.provider");
                             System.setProperty("mx4j.remote.resolver.pkgs", "com.bea.core.jmx.remote.resolver");
                             connector = JMXConnectorFactory.newJMXConnector(serviceUrl, env);
                             
                             connector.connect(env);
                             connection = connector.getMBeanServerConnection();



    ......
    and then :getting MonitorRuntimeMBean object..
    ...

    monitorMBean = (MonitorRuntimeMBean)MBeanServerInvocationHandler.newProxyInstance(connection, monitorName, MonitorRuntimeMBean.class, false);

    ..


    and then :

    ..
    ObjectName thruputObject = monitorMBean.monitorAvgThroughput(stageObjectIn, (new Long(averageThroughputInterval)).longValue(), (new Long(averageThroughputInterval)).longValue());
                   
                   ProbeRuntimeMBean probeAvgThroughput = (ProbeRuntimeMBean)MBeanServerInvocationHandler.newProxyInstance(connection, thruputObject, ProbeRuntimeMBean.class, false);

                   listener = new AverageThroughputJMXNotificationListener(stageName,connection );


    ...

    When i done i use:

    probeAvgThroughput .terminate();


    ofcource , i just cut the relevant parts , but I'm sure that what I'm doing is right.

    My question is not about the latency but about AvgThroughput which shows wrong numbers each time i reconnect to thr server .
    The numbers get smaller each time i reconnect ( I described it in my previuos post ).



    My questions are very simple :

    *1. How to add a profile via api ? ( DiagnosticProfile )*

    *2.How to get DataAggregationMBean ?*

    *3. How to get DataServiceFactoryMBean 'and then use it to add profile?*


    PLEASE , I JUST WANT A GOOD EXAMPLE OF DOING THOSE THINGS !!!

    If there is no answer to those, just tell me , because it's been to much time trying to figure it out.

    Having my code , and asking why do I need this , does not contribute to my quetions ..
    I'm sure you ( the oracle company team ) wants to help , but the mosy helpfull help is via GOOD  examples.
    Thanks.
  • 5. Re: How to to programmatically create diagnostic profile : Please , Help!
    722711 Explorer
    Currently Being Moderated
    Hi,

    Your usage of monitoring API seems correct. The only thing I would recommend is calling probe.stop() as well before probe.terminate(). Please see if that helps. If not, can we get a simplified version of your app so that we can reproduce the issue here and fix it?

    Do you see the reduction in throughput numbers immediately or is it after a few hours or so? If it is after some time, the problem could be something else on our side, hence the question.

    DiagnosticProfile, DataAggregation and DataService are not meant to be public API. It looks like we included DiagnosticProfile in the public docs by mistake. Is there something in DiagnosticProfile that you cannot do by directly using the monitoring API?

    Thanks,
    Manju.
  • 6. Re: How to to programmatically create diagnostic profile : Please , Help!
    938644 Newbie
    Currently Being Moderated
    Thanks for your answer.
    I will try what you suggested : adding stop before terminat.
    Simpilfy my code is not very easy, but i will do that.( it is also good for me to check if this phenomena happens with only one probe - now I have some ..)

    The numbers of throughput get smaller every time I reconnect to the cep server - immediately . Each time i reconnect I get smaller numbers that the previous session.

    I will tell you if adding stop , helped , if not I'll send you a simple code so you can check it out .
    Thanks again for your answer.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points