JMX Management
Some of the features discussed on this page are not part of the open-source edition, and are only available in the licensed editions (starting with Premium).
The Java Management Extensions (JMX specification) describe an architecture, design patterns, API's, and services for application and network management in the Java programming language. JMX functions beyond a simple API since it can specify the architecture as to how that API is used. It provides the means to construct Java code, create smart Java agents, implement distributed management middleware and managers, and integrate these solutions smoothly into existing management systems. You can integrate such solutions with either HTML or industry standards such as SNMP and WBEM. JMX is dynamic, allowing the monitoring and management of resources in real time while they are created, installed, and implemented. The JMX also works along with JVM, the Java Virtual Machine.
For more details about JMX, refer to JavaManagement.
Manageable Resource
A JMX manageable resource can be an application, an implementation of a service, a device, a user, etc. It is developed in Java, or at least offers a Java wrapper, and must also be implemented by a Java object called a managed bean (MBeans), according to JMX specifications.
Opening JMX
Step 1. The easiest way to open JConsole for a specific service is through the GigaSpaces Management Center:
-
In the Deployments tab, right-click the GSC, GSM, or LookupService tree node, or
-
In the Space Browser tab:
-
In the Grid Tree, right-click the relevant space container node, or
-
Right-click the relevant space node or clustered space node, or
-
Right-click the relevant space from the space network view:
-
Step 2. Click Launch JConsole.
Step 3. This opens the JConsole of the selected process.
Step 4. You can browse the various MBeans.
Step 5. Make sure you have a deployed space.
Step 6. Open a console and type the following command: jconsole
By default, operations in the MBeans Operations tab that have GigaSpaces classes as their type are disabled. To enable these, type the following in your console:jconsole -J-Djava.class.path=%JAVA_HOME%\lib\jconsole.jar;GS_HOME\lib\required\xap-datagrid.jar
Instead of GS_HOME
, type the directory where GigaSpaces is installed on your computer.
Step 7. Connect to the MBean server (choose one of the following options):
- Using the Advanced tab:
The JConsole: Connect to Agent window appears. Select the Advanced tab.
In the JMX URL text box, copy the URL in the log message displayed in your GigaSpaces Server,for example:
Press Connect.
New JMXConnectionServer was successfully registered into the MBeanServer using service url: service:jmx:rmi:///jndi/rmi://localhost:10098/jmxrmi.
- Using the Remote tab:
The JConsole: Connect to Agent window appears. Select the Remote tab.
In the Host or IP text box, copy the host name/IP address from JNDI URL text field in the container configuration.
In the Port text box, copy the port value from the same JNDI URL text field in the container configuration.
Step 8. Press Connect.
Here is a code example of implementing such an approach:
IJSpace spaceProxy = ( IJSpace )SpaceFinder.find( "jini://mySpace_container/mySpace");
System.out.println( "Space found: " + spaceProxy.toString() );
ContainerConfig containerConfig = ( ( IJSpaceContainerAdmin )spaceProxy.getContainer() ).getConfig();
String jndiURL = containerConfig.jndiUrl;
Runtime.getRuntime().exec( "jconsole " + jndiURL );
Remote JConsole Connection
The Grid Service Agent (GSA) exposes a JMX remote port for each child component (for example GSC). The port is determined by adding the agent id to a base port.
The base port should be defined using the environment variable GS_JMX_REMOTE_BASE_PORT
, which will be the port of the GSA, and child processes will be GS_JMX_REMOTE_BASE_PORT
+ id.
For example:
-
GSA base port 6060
-
GSC port 6061
-
GSC port 6062
JMX can be disabled by setting GS_OPTIONS_EXT
to -Dcom.gs.jndi.enabled=false
in the setenv-overrides.sh/bat
file.
Example of definition:
export GS_OPTIONS_EXT="-Dcom.sun.management.jmxremote.authenticate=true
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.access.file=[PATH_TO]/jmxremote.access
-Dcom.sun.management.jmxremote.password.file=[PATH_TO]/jmxremote.password"
export GS_JMX_REMOTE_BASE_PORT=[YOUR_PORT_VAL]
It is important to verify that all expected ports are open in the firewall.
Viewing Thread CPU Usage
JConsole includes a plugin that displays CPU usage for each JVM thread. This tab is displayed using the -pluginpath JConsole parameter (already implemented in GigaSpaces).
To view this tab in your JConsole:
-
Download the topthreads.jar file and add it to your
$GS_HOME\lib\platform\ui
folder.topthreads-1.0.0.jar
is used by default. Iftopthreads-1.0.0.jar
isn't found, theJTop.jar
file (which is part of the JDK) is used instead.
The following subsections provide some sample screenshots.
topthread.jar
JTop.jar
MBeans View
The jconsole utility (part of Sun J2SE 5.0 JDK and above) includes a MBeans view, which allows you to perform space administration operations, and to view and control space attributes. These operations are defined in the JavaSpaceMBeanDescriptors.xml file, which exists in the xap-datagrid.jar
file. If you do not want a certain operation or attribute to be exposed in the JMX MBeans tab, simply comment or remove the operation from the XML file.
Space Container MBean
The container MBean exposes the space container's attributes and operations. The space container manages the space life cycle.
Attributes Tab
The container Attributes tab displays a list of container attributes. Attribute values appearing in blue can be controlled, while values in black can not be changed. Red values are unavailable.
Operations Tab
The container Operations tab allows you to perform different space container operations:
Option | Description |
---|---|
shutdown | shuts down this container. |
restart | restarts this container. |
destroySpace | destroys a space in this container (type the space's name in the spaceName text box). |
createSpace (spaceName, schemaName, clusterConfigURL) | creates a space with a unique name in this container and writes the created space to the appropriate Storage Adapter. (Type the name of the space, the name of the schema, and the cluster configuration URL\*\*\* in the relevant text boxes). |
createSpace (spaceName, schemaName) | creates a space with a unique name in this container. |
getRuntimeConfigReport | displays a runtime configuration report. For more details, refer to the Configuration section. |
Info Tab
The container Info tab displays the MBean name and its Java class.
Space MBean
The Space MBean exposes space attributes and operations. You can get the basic space operational settings using this MBean.
Attributes Tab
The space Attributes tab displays a list of space attributes/elements by XPath, in the selected space. Attribute values appearing in blue can be controlled, while values in black can not be changed. Red values are unavailable.
Operations Tab
The space Operations tab allows you to perform different space operations:
Operation | Description |
---|---|
getSpace | returns the space proxy that this manageable bean governs. |
getStatistics | returns a StatisticsContext according to the operation code you type in the operationCode text box – each operation has a constant representing it. |
clean | cleans the selected space. |
count | when entering a specific class name in the className textbox, displays the number of Entries in this class. |
clear | when entering a specific class name in the className textbox, removes the Entries that match this template from the space. |
stop | attempts to stop the selected space. |
start | attempts to start the selected space. |
ping | checks whether the space is alive and accessible. |
restart | restarts the space. |
getClusterPolicy | displays a cluster policy instance. |
getRuntimeInfo | returns a RuntimeInfo instance. |
getURL | displays the spaceURL instance which was used to initialize the space. |
- For more information, refer to Javadoc.
- Javadoc and the statistics filter operation codes list.
- StatisticsAdmin or StatisticsContext.
Info Tab
The space Info tab displays the MBean name and its Java class.
Space MBean Extension
The Space MBean Extension exposes advanced space attributes – this includes memory management, persistency and communication settings.
Attributes Tab
The space extensions Attributes tab displays a list of advanced space attributes/elements by XPath, in the selected space. Attribute values appearing in blue can be controlled, while values in black can not be changed. Red values are unavailable.
Info Tab
The space extensions Info tab displays the MBean name and its Java class.
Restricting and Modifying MBeans
There is an option to restrict the access to space and space container operations or attributes; for example, you can decide to hide some of the attributes and configuration, and disable execution of operations.
This way, you can view, restrict or modify most of the space and space container configuration (as set in the space/container schema files), or the basic admin operations, which were discussed in the above sections.
To do this, modify the following space and space container MBean Descriptors, which are located inside the $GS_HOME\lib\required\xap-datagrid.jar
file:
ContainerMBeanDescriptors.xml
JavaSpaceExtMBeanDescriptors.xml
JavaSpaceMBeanDescriptors.xml
Settings to Modify
Following are some space/space container MBeans Attributes settings you can modify:
- Attribute – required, otherwise is optional.
- name – the name of the attribute.
- type - The type or class name of the attribute.
- description – a description of the attribute.
- isReadable – true if the attribute has a getter method, false otherwise.
- isWritable – true if the attribute has a setter method, false otherwise.
Following are some space/space container MBeans Operations settings you can modify:
- Operation – required, otherwise optional.
- name – the name of the method.
- type – the type of the method's return value.
- impact – the impact of the method, one of
INFO
,ACTION
,ACTION_INFO
,UNKNOWN
. - description – a description of the operation.
- signature –
MBeanParameterInfo
objects describing the parameters (arguments) of the method. - Signature – the list of parameters info.
- Parameter – required, otherwise optional.
- name – the name of the data.
- type - the type or class name of the data.