Forum Stats

  • 3,855,268 Users
  • 2,264,494 Discussions
  • 7,905,954 Comments

Discussions

How to to programmatically create diagnostic profile ?

938644
938644 Member Posts: 50
edited Sep 17, 2012 10:16AM in Complex Event Processing
Hi,
I'm trying to create a diaganostic profile programmatically .
I didn't see any example like this. My purpose is to create a profile like in the ' Visualizer ' tool.
I'm trying to use these lines:
...

Application a=new ApplicationImpl(myApp);
DiagnosticProfileManagerImpl diagnosticProfileManagerImpl=new DiagnosticProfileManagerImpl(a);

probeNames=new ObjectName;
diagnosticProfileManagerImpl.createDiagnosticProfile(profileName, probeNames);
....

I got a NullPointerException .
Any ideas? examples ?

Answers

  • 877753
    877753 Member Posts: 25
    Hi,
    I'm pasting few lines in which you can fetch the diagnosticManager and then do the appropriate Mbean calls for creating Diagnostic profiles via java code.

    import com.bea.wlevs.management.diagnostic.DiagnosticProfileMBean;
    import com.bea.wlevs.management.diagnostic.DiagnosticProfileManagerMBean;
    import javax.management.MBeanServerConnection;
    import javax.management.MBeanServerInvocationHandler;
    import java.lang.management.ManagementFactory;
    import javax.management.ObjectName;
    import javax.management.ObjectInstance;
    import org.w3c.dom.Node;


    MBeanServerConnection conn=ManagementFactory.getPlatformMBeanServer();
    private static DiagnosticProfileManagerMBean diagNosticManager=null;
    private static Node updateprofileNode=null;
    ObjectName diagProfileObjectName;
    try {
    diagProfileObjectName = ObjectName.getInstance("com.bea.wlevs:Name=ProfileManager,Type=ProfileManager,Application=diagnostic");
    } catch (Exception e) {
    throw new RuntimeException(e);
    }
    diagNosticManager=(DiagnosticProfileManagerMBean) MBeanServerInvocationHandler.newProxyInstance(conn, diagProfileObjectName, DiagnosticProfileManagerMBean.class, false);

    Now we can use diagNosticManager.createDiagnosticProfile(String profileName, ObjectName[] probeNames) method to create the diagnostic profile.

    Thanks
    Patha
  • 938644
    938644 Member Posts: 50
    Tnanks,
    I tried this. now I'm getting :

    javax.management.InstanceNotFoundException: com.bea.wlevs:Name=ProfileManager,Type=ProfileManager,Application=diagnostic
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1094)

    What did I do wrong?
  • 938644
    938644 Member Posts: 50
    Hi again ..

    I think I know where is the problem but I don't know how to solve it:
    i use these lines to make a connection :
    ..

    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 you suggested to use this :

    connection=ManagementFactory.getPlatformMBeanServer();


    I think there is inconsistency in the typs of the connection mbean.
    Neither of of them works fine:

    The first one works fine for getting troughput , averageLatency and so on ,
    BUT, when i try to terminate ( unregister from the mbean server ),
    and than re-connect again, the numbers i'm getting are wrong.

    In the second type (ManagementFactory.getPlatformMBeanServer() ) , when I want to use as a profile creator ( like in the 'Visualizer' tool - which works fine )
    I don't know which of the types to use.

    What is your recommendation to to use : for temintinag the probeRuntime, and for making a profile .

    again, neither of them works all the way!
    Plz help.
This discussion has been closed.