![]() |
|
The Pramati Server Management Information Model is JSR 77 compliant.
JMX defines management interfaces and services designed for distributed environments focused on providing functionality for managing networks, systems and applications.
The Console is built with components called Manageable Beans (MBeans). These beans can be either standard or dynamic. Dynamic MBeans conform to a specific interface and allow for wide flexibility at runtime. MBeans can generate and propagate notification events to components across multiple tiers. Service providers and developers can build standard management components into their products, and avoid investing in complex management systems.
To use the MBean Viewer provided, select Utilities > MBean Viewer. This displays a list of all the MBeans registered with the domains PRAMATI and History Collector. The details for the domains JMS and MY_DOMAIN that were provided separately till Pramati Server 4.1, are now available under PRAMATI.
Clicking a domain name displays all the MBeans related to it. Click on an MBean to view the various attributes, operations, and notifications related to it. You can:
To access MBean Server from within the server VM, simply look up java:comp/MBeanServer, as:
javax.naming.InitialContext ic = new javax.naming.InitialContext();
javax.management.MBeanServer mbeanServer =
(javax.management.MBeanServer)ic.lookup("java:comp/MBeanServer");
This code can be executed from a Server startup hook or any standard J2EE component such as a servlet or an EJB.
To manage Pramati Server remotely, the MBean Server must be accessed from outside the VM, through the RMI-based client connector that is bound to the Naming service by the name rmi-client-connector. The following code illustrates this:
java.util.Properties props=new java.util.Properties();
props.put("java.naming.factory.initial",
"com.pramati.naming.client.PramatiClientContextFactory");
props.put("java.naming.provider.url", "rmi://Host-IP:NamingPort");
javax.naming.InitialContext ic = new javax.naming.InitialContext(props);
com.pramati.jmx.connector.ClientConnector cc =
(com.pramati.jmx.connector.ClientConnector)ic.lookup("rmi-client-connector");
The Java API for com.pramati.jmx.connector.ClientConnector can be found at www.pramati.com/docstore/1205010/javadocs/index.html.
Pramati RMI Client Connector can also be obtained by a JSR 160 client. JSR 160 is an interoperable, transparent standard to access JMX implementations remotely using RMI or any other transport. Pramati’s JSR 160 implementations are provided over RMI transport.
For JSR 160 client's to access Pramati's implementation, set the system property jmx.remote.protocol.provider.pkgs to com.pramati.jmx.connector.
JMXService URL should be of format service:jmx:rmi:///jndi/rmi://<hostname _moz-userdefined="">:<naming _moz-userdefined="" port="">/std-rmi-connector</naming><hostname>
//create the jmxServiceURL
JMXServiceURL url =
new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9191/std-rmi-client-connector");
//initialize the properties to create the jmx connector
Map properties = new HashMap();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"com.pramati.naming.client.PramatiClientContextFactory");
properties.put(Context.URL_PKG_PREFIXES, "com.pramati.naming.url");
//set credentials else do operations on the mbean server as nobody
Properties pwProps = new Properties();
pwProps.put("com.pramati.naming.realm", "system");
pwProps.put(Context.SECURITY_PRINCIPAL, "root");
pwProps.put(Context.SECURITY_CREDENTIALS, "pramati");
properties.put(JMXConnector.CREDENTIALS, pwProps);
//connect
JMXConnector jmxc = JMXConnectorFactory.connect(url, properties);
// Get an MBeanServerConnection
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
// Perform mbean operations
mbsc.getMBeanCount();
Start navigating from com.pramati.services.j2ee.spi.admin.J2EEServerMBean or com.pramati.services.jms.spi.admin.JMSServerMBean, which can be obtained by looking up root-server-mbean or jms-servermbean either from the same VM or remotely.
The following sample code obtains a J2EEServerMBean, the management interface for managing Server, in the same VM.
javax.naming.InitialContext ic = new javax.naming.InitialContext();
com.pramati.services.j2ee.spi.admin.J2EEServerMBean
j2eeServerMBean=(com.pramati.services.j2ee.spi.admin.J2EEServerMBean)
ic.lookup("rootserver-mbean");
The following sample code obtains a J2EEServerMBean from a remote VM:
java.util.Properties props=new java.util.Properties();
props.put("java.naming.factory.initial",.
"com.pramati.naming.client.PramatiClientContextFactory");
props.put("java.naming.provider.url", "rmi://Host-IP:NamingPort");
javax.naming.InitialContext ic = new javax.naming.InitialContext(props);
com.pramati.services.j2ee.spi.admin.J2EEServerMBean
j2eeServerMBean = (com.pramati.services.j2ee.spi.admin.J2EEServerMBean)
ic.lookup("rootserver-mbean");
The following sample code obtains a JMSServerMBean, the management interface for the Pramati Message Server, in the same VM:
javax.naming.InitialContext ic = new javax.naming.InitialContext();
com.pramati.services.jms.spi.admin.JMSServerMBean
jmsServerMBean = (com.pramati.services.jms.spi.admin.JMSServerMBean)
ic.lookup("jms-server-mbean");
This sample code obtains a JMSServerMBean from a remote VM:
java.util.Properties props=new java.util.Properties();
props.put("java.naming.factory.initial",
"com.pramati.naming.client.PramatiClientContextFactory");
props.put("java.naming.provider.url", "rmi://Host-IP:NamingPort");
javax.naming.InitialContext ic = new javax.naming.InitialContext(props);
com.pramati.services.jms.spi.admin.JMSServerMBean
jmsServerMBean =(com.pramati.services.jms.spi.admin.JMSServerMBean)
ic.lookup("jms-server-mbean");
Replace Host-IP with the actual IP of the host where Server is running and NamingPort with the port that is used by the Naming Service running on the host. For example, rmi://Host-IP:NamingPort may be replaced by rmi://localhost:9191, where the lookup is on another VM on the same host with Naming Service on port 9191.
The Java API and the MBean API for Console are available at www.pramati.com/docstore/1205009/javadoc/index.html.
The m-let text file should have the following pseudo XML format:
<MLET CODE = class | OBJECT = serfile ARCHIVE = "archivelist" [CODEBASE = codebaseURL] [NAME = MBeanName] [VERSION = version] > [arglist] <MLET>
The following table contains attribute definitions:
Table 1: Attribute definitions
| Attribute | Description |
|---|---|
| code | Class name of the MBean including package name is specified here. Either the code or object attribute must be present. |
| object | Serialized representation of the MBean that is to be obtained. |
| archive | JAR name or jar comma-separated list enclosed in double quotes. |
| codebase | This specifies the URL of the MBean to be obtained. The JAR name must be stored in the URL specified here. |
| name | Name of the MBean that is to be registered. |
| version | This version number must contain non-negative integers. It can be used to specify whether or not the jar files need to be loaded from the Server to update those already loaded by the m-let service. |
addURL() method.getMBeansFromURL method with one of the added URLs. This tries to instantiate and register the newly downloaded MBeans. The method returns the object Instance of the MBeans that were successfully created and a Throwable object for those that were not.You can do all the above itemized steps from Pramati's MBean Viewer.
<MLET CODE =SimpleStandard ARCHIVE = "jmxClient.jar" CODEBASE = "file:/home/working_dir/PServer/server/lib/ext/" NAME =PRAMATI:type=MySimpleStdMBean> <MLET>
jmxClient.jar file at the location specified by the CODEBASE tag.file:/home/working_dir/PServer50/server/myDir/conf.mlet.addURL which takes java.lang.String as input parameter.addURL() method. Click Submit. You should see message that the operation has been invoked successfully.getMBeanFromURL() by copying the same URL to the input text box against the getMBeansFromURL() method.The m-let text file should be present in the same directory as the jar files and class files.
After creating the m-let text file, click View under MBean Viewer on the Console. This invokes MBean Viewer Dialog. Select domain as Pramati and click name type=mlet-service.
Specify value as the URL where the m-let text file is present. This registers the MBean to the Server and creates a new domain.
jconsole.exe in your JDK_HOME/bin. JConsole can be used to connect to Pramati's MBean Server.Note: To use JConsole, Pramati Server must be started using jdk1.4.2 or higher including jdk1.5.
JConsole can connect to a running JVM in three different ways:
com.sun.management.jmxremote to the command for starting the Server. You need to modify runserver.bat/runserver.sh file in /server/bin/ directory to include this system property.$JDK_HOME/bin>jconsole.exeThis method uses an arbitrary port to export the RMI JMX Adapter. To use a port of your choice, you need to add the com.sun.management.jmxremote.port, com.sun.management.jmxremote.authenticate, and com.sun.management.jmxremote.ssl Java system properties while starting the Server.
Example for Starting a Simple Application for Remote Monitoring
>java -Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.port=8004 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -classpath %PROJECT_DIRECTORY% SomeSimpleApplication
When you now start JConsole from a remote machine, you should now be able to connect to the JMX agent in your application by entering the relevant information under the Remote tab of the Connect to Agent dialog box.
jconsole.jar and pramati_client_all.jar in the JConsole classpath and system properties java.naming.factory.initial and java.naming.factory.url.pkgs as shown below:
jconsole.exe -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar; %JAVA_HOME%\lib\tools.jar; D:\PS\lib\pramati_client\pramati_client_all.jar -J-Djava.naming.factory.initial=com.pramati.naming.client.PramatiClientContextFactory -J-Djava.naming.factory.url.pkgs=com.pramati.naming.url
service:jmx:rmi:///jndi/rmi://localhost:9191/std-rmi-client-connector.The MBeans tab shows the list of all the domains and the mbeans in them. For example, you can access the EJB container in the domain "PRAMATI", and invoke the operations on it. The right pane consists of all the attributes, operations and notifications supported by the EjbContainerMBean.
| © Pramati Technologies 2007 | Runs on Pramati Server | Feedback | Legal |