In this post I'll present an example about how to perform custom management measurements in Coherence and then build custom reports based on that measurements.Example Scenario: In this example I am performing some sort of coherence benchmark. Several operations (insert, update and continuous query) are performed against the coherence cache. I am measuring the time results for this operations and then I am providing the custom Mbeans with the results. Example topology: 1 coherence storage enabled nodes, 1 proxy node, 3 coherence extend clients and 1 management node.
Based on the custom MBeans I am building custom reports with Coherence JMX Reporter.
The necessary steps for achieving this are:
- Custom Configuration of Coherence Mbeans
- Crate and configure Coherence Management Node
- Create a Custom Mbean
- create a new package in your project called "mbeans"
- create a generic mbean interface class
- implement the PerformanceMBean interface
- inherit the Performance class for each operation that you want to measure
- add Mbeans classes to the Coherence Management node classpath
- create a custom Mbean XML configuration file
- specify the name and location of a custom MBean configuration file to the coherence management nod
- Connect to the JMX custom Mbeans to update them with the latest results
- Use JConsole to watch your custom Mbean
- Create a custom report
- Localize and extract your custom reports configuration file
- Configure the management node to load your custom report configuration file
- Create and configure a new configuration file for each report that you want to be generated
- Add your new report configuration file to the general Coherence JMX Reporter configuration file
1. Custom Configuration of Coherence Mbeans
1. Create and configure Coherence Management NodeCoherence can be configured to load platform and standard MBeans.
To manage a Coherence cluster using JMX, ensure that you have the necessary JMX 1.0 or later classes (javax.management.*) in the classpath of at least one Coherence cluster node, known as an MBeanServer host. The cluster nodes that are not MBeanServer hosts will be managed by the MBeanServer host(s) by using the Coherence Invocation service.
Management node start file:
9: $JAVAEXEC -server -showversion $JAVA_OPTS -cp
11: com.tangosol.net.management.MBeanConnector -rmi
com.tangosol.net.management.MBeanConnector -rmi = Start a Coherence cluster node that enables JMX agents such as a web browser or JConsole to connect to the in-process JMX MBeanServer and manage Coherence MBeans. -rmi is used when connecting via Jconsole.
2. Create a Custom Mbean
For more information about standard Mbeans please access the following documentation:
In the following example you will see how I've created a custom MBean for measuring insert, update and continuous query operations:
1. create a new package in your project: "mbeans" for instance
2. create a generic mbean interface class called PerformanceMBean that describes what are the measurables for a certain operation:
3. implement the PerformanceMBean interface:
4. inherit the Performance class for each operation that you want to measure:
5. add Mbeans classes to the Coherence Management node classpath:
6. create a custom Mbean XML file
7. specify the name and location of a custom MBean configuration file to the coherence management node:
3. Connect to the JMX custom Mbeans to update them with the latest results
4. Use JConsole to watch your custom Mbeans
II. Create a custom report
The Coherence reporting feature provides a capable query definition that allows for any information residing in the Coherence JMX data source to be logged to a text file. After a custom report has been created, it can be included in a report batch and executed on a specified time interval by the
Coherence provides a JMX reporting capability (the Reporter). The Reporter provides out-of-the-box reports that help administrators and developers manage capacity and trouble shoot problems. Custom reports can also be created.
1. Localize and extract your custom reports configuration files:
- Go to your COHERENCE_HOME/lib location, go to the archive coherence.jar and extract from there into your project folder the reports folder. In that folder you should find a report-group.xml file together with other configuration files
2. Configure the management node to load your custom report configuration files
- In your management node start file specify from where the management node could access the reports configuration files: -Dtangosol.coherence.management.report.configuration=$TEST_HOME/reportsIntel/report-group.xml Without this specification the reports configuration files are loaded from the default location: coherence.jar\reports. You can modify the configuration from that location as well but the best practice is to copy them in your project location.
3. Create and configure a new configuration file for each report that you want to be generated
- Create an xml file for each report that you want to be generated. As an example you can see the following xml report configuration file for the insert operation:
The element <file-name> defines the reports file name. As you can see it includes the the keyword date which means that every report name will contain the creation date.
The next element defines the Mbean that will be used in your custom report:
Then use your Mbean attributes and report default attributes to build your custom report:
- Report default attributes:
- Mbean attributes:
4. Add your new report configuration file to the general Coherence JMX Reporter configuration file:
- Add your custom report xml configuration file to the report-group.xml Coherence JMX Reporter configuration file:
The following can be also specified:
- reporting frequency: <frequency>30s</frequency>
- The reports output directory: <output-directory>/media/Software/reports/</output-directory>
Report example (the reports are generated as txt documents by they are comma separated, so they are csv actually):