Wednesday, April 3, 2013

Monitoring OpenJPA's Caches on the WebSphere Liberty Profile

OpenJPA provides several types of caches that can be used to improve the performance of many applications. Several of OpenJPA's caches collect statistics such as number of entries, hit count, and object type. These attributes can be helpful for monitoring the effectiveness of the cache.  Analysis of these statistics can help you to make decisions about what to cache, how many objects to cache, or even whether to enable caching at all.  An effective caching scheme can produce significant performance benefits, while an ineffective scheme may be a drag on performance and almost certainly increase the memory requirements of the application.  A little tuning can normally go a long way.

Initally, accessing OpenJPA's cache statistics required adding custom Java code to your application.  You were required to call OpenJPA APIs to navigate through the configuration, get access to the caches, and then access their statistics.  As of OPENJPA-1739 (OpenJPA 2.1), these caches are now JMX instrumented.  This means that a application such as JConsole can be be used to monitor cache information out-of-band.  This type of monitoring can be accomplished without changing the application code and with only minor changes to the configuration.  For example, by adding set of properties to your persistence.xml, you can enable instrumentation of the data cache, query result cache, and SQL caches:

<property name="openjpa.Instrumentation
<property name="openjpa.DataCache"
<property name="openjpa.QueryCache"
<property name="openjpa.jdbc.QuerySQLCache"

Using JConsole (provided with some 1.6 and later JDKs), you can attach to your Java program and use the MBeans provided by OpenJPA to view statistics for its caches.  You can also invoke methods on the MBeans to get individual statistics about certain queries or cached object types.  In addition to direct monitoring of the MBeans, the OpenJPA project provides a data cache plugin for JConsole.  The data cache plugin provides a nice interface for monitoring the L2 data cache.

As long as the environment supports JMX, applications running Java SE and Java EE environments can be monitored. The OpenJPA documentation explains how to enable the JMX server in a Java SE environment. This blog contains some information for using JConsole with WebSphere Application Server full profile.

JPA applications deployed on the WebSphere Application Server Liberty Profile version 8.5 and the Liberty V.8.5.Next Beta can also be monitored. Configuration is a piece of cake. You simply need to add the configuration above to your persistence.xml and enable the localConnector-1.0 feature in your Liberty Profile server.xml:

<server description="Liberty Server">
    ... other configuration ...

Start the Liberty application server, and begin using your application. After performing a few operations that use JPA, start up JConsole with the OpenJPA Data Cache plugin and connect to the server. You can find the Liberty Server in the Local process list by searching for for ws-launch.jar followed by the name of your server.

JConsole will connect to the local process and the data cache plugin will discover the PUs available on the server. A tab will be created for each PU it discovers. This screen shows the DataCache statistics for the PollPU persistence unit.

You can also select the MBeans tab and browse through cache statistics of all the caches for the various persistence units in the server. The MBeans also allow you to reset cache statistics and query statistics for individual objects or queries on the fly.



srikanth said...

your giving such a nice information on ibm websphere mq and its relly usefull . WEBSPHERE Online Training.

Anonymous said...

It is very nice & useful.And also very informative article ,I also get some information from
Agility Insight

Raju Kumar said...

I am really impressed with your writing skills and also with the structure in your weblog. Is that this a paid subject or did you modify it your self? Anyway keep up the excellent high quality writing, it is rare to look a great blog like this one these days..
Hadoop Online Training

Anonymous said...

thanks for shared wonderful information of giving best information.its more useful and more helpful. great doing keep sharing
CCNA Training in Chennai

Abiya Carol said...

I just see the post i am so happy the post of information's.So I have really enjoyed and reading your blogs for these posts.Any way I’ll be subscribing to your feed and I hope you post again soon.

Branding Services in Chennai

Orange TechnoMind said...

Good information about websphere details.

Websphere Training in Chennai
IBM Integration Bus Training in Chennai
IBM Data Power Training in Chennai
Websphere MQ Training in Chennai
IBM Websphere Message Broker Training in Chennai

Abiya Carol said...

Great post! I am actually getting ready to across this information, It's very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.

Dotnet Training in Chennai

Thagappan Swamy said...

IBM BPM Training by experts in Chennai

IBM Wepsphere application Training by experts in Chennai

for IT the said...

I have read your blog its very attractive and impressive. I like it your blog.

Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

Java Online Training Java Online Training JavaEE Training in Chennai Java EE Training in Chennai

jenny Honey said...

Excellent Article, thanks for sharing
Web design company in Hyderabad
Digital Marketing company in Hyderabad

Ahkansha said...

The blog is very interesting and excellent. I have read your blog its very attractive and impressive. I like it your blog. Thanks for sharing information.
java training in chennai

Ahkansha said...

The blog is very interesting and excellent. I have read your blog its very attractive and impressive. I like it your blog. Thanks for sharing information. java training in chennai

traverse jamaica said...

Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point. | |

srinivas k said...

Hey, great work did keep going on.

svr online Training said...

Awesome article.The information I have been searching precisely. It helped me a lot, thanks. Keep coming with more such informative article. Would love to follow them.
websphere MQ training

w3 Webschool said...

Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating.
Web Design Training

Bee Yes said...

Amazing Article ! I have bookmarked this article page as i received good information from this. All the best for the upcoming articles. I will be waiting for your new articles. Thank You ! Kindly Visit Us @ Coimbatore Travels | Ooty Travels | Coimbatore Airport Taxi

svr said...

Awesome article. It is so detailed and well formatted that i enjoyed reading it as well as get some new information too.
what is ibm datapower

sandy star said...

Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
Advanced AWS Interview Questions And Answers, Top 250+AWS Interviews Questions and Answers 2018
Advanced AWS Training in Bangalore | Best Amazon Web Services Training in Bangalore
Advanced AWS Training in Pune | Best Amazon Web Services Training in Pune
Best Amazon Web Services Training in Pune | Best AWS Training in Pune
Advanced AWS Online Training | Best Online AWS Certification Course in india

Twinkle said...

Nice post. It is really interesting. Thanks for sharing the post!
Buy Domain Names Online In India, Domain Name Registration In India, Best Domain Registrar In India, Web Design Services In India, Responsive Web Design Company In India, Digital Marketing Company in India

sathya said...

Nice post. It is really interesting. Thanks for sharing the post!
fridge online shopping
refrigerator online shopping
refrigerator price online
online fridge price
Washing Machine Sale
washing machine online offers
Online Shopping

john jersy said...

Read all the information that i've given in above article. It'll give u the whole idea about it.

python training in chennai
python course institute in chennai