-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Hibernate Second Level Cache Provider and Cache Monitor
PostPosted: Mon Apr 15, 2013 10:38 am 
Beginner
Beginner

Joined: Tue Feb 05, 2013 10:04 am
Posts: 20
I don't have much experience with Hibernate second level cache providers. I have achieved, following EHCache documentation, to configure in my hibernate.cfg.xml and ehcache.xml files the EHCache cache provider. I don't get any Hibernate errors, but I want to really see if the Cache works.

I have downloaded EHCache monitor (free development version) and have followed the documentation (set the probe in the application and run the script) but I always get in the monitor 0 probes registered and no cache statistics are displayed.

I have following cache parameters in my hibernate.cfg.xml:

Code:
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.generate_statistics">true</property>


my ehcache.xml file:

Code:
<?xml version="1.0" encoding="UTF-8"?>
  <ehcache>
  <cache name="com.myproject.domain.client"
   maxEntriesLocalHeap="50"
   eternal="false"
   timeToLiveSeconds="600"
   overflowToDisk="true"
   />
  <cache
   name="com.myproject.domain.product"
   maxEntriesLocalHeap="450"
   eternal="false"
   timeToLiveSeconds="600"
   overflowToDisk="true"
  />
</ehcache>


In my hibernate xml entity mapping file I have added:

Code:
<cache usage="read-write" />


I have searched for this problem in the web and in different forums, I have tried different configurations but I didn't have any results, I always get no probe registered. I am using Hibernate 4.

By the way, I would like to know if there is any other free Hibernate second cache level solution that has a good monitoring system. Which second level cache solution is easier to integrate?

Thank you for your help and advice.


Top
 Profile  
 
 Post subject: Re: Hibernate Second Level Cache Provider and Cache Monitor
PostPosted: Tue Apr 16, 2013 2:30 am 
Beginner
Beginner

Joined: Tue Feb 05, 2013 10:04 am
Posts: 20
I would also like to ask if there is any Hibernate-Memcached conector or plugin. I have found this conector:

http://code.google.com/p/hibernate-memcached/

but it is deprecated and doesn't support Hibernate 4.

Thank you for your help.


Top
 Profile  
 
 Post subject: Re: Hibernate Second Level Cache Provider and Cache Monitor
PostPosted: Tue Apr 16, 2013 1:28 pm 
Regular
Regular

Joined: Wed Apr 10, 2013 1:02 am
Posts: 50
You can look at my blog I have shown it using hibernate 4

_________________
Regards
Akash Miital
http://akash.thegrassroots.co.in/hibernate/


Top
 Profile  
 
 Post subject: Re: Hibernate Second Level Cache Provider and Cache Monitor
PostPosted: Thu Apr 18, 2013 3:17 am 
Beginner
Beginner

Joined: Tue Feb 05, 2013 10:04 am
Posts: 20
Thank you for your help.

Is there any free monitoring application to trace and observe data that is stored cache?
I know that Hibernate statistics and the executed SQL queries can be activated but I would like to find a tool that gathers all cache information.

Thank you for your help.


Top
 Profile  
 
 Post subject: Re: Hibernate Second Level Cache Provider and Cache Monitor
PostPosted: Thu Apr 18, 2013 3:59 am 
Regular
Regular

Joined: Wed Apr 10, 2013 1:02 am
Posts: 50
Hey man
I have not tried to see the cached object using any 3rd party tool.
However terracotta has a tool for ehcache monitoring.

http://ehcache.org/documentation/operations/monitor
the catch : 30 Days evalutation .
One question : If you are caching on file store why do you need a third party tools??.

Ok more on this

For checking Indexed files (If you are using hibernate search [which is built on top of lucene])
u can use LUKE https://code.google.com/p/luke/

Code:
Lucene is an Open Source, mature and high-performance Java search engine. It is highly flexible, and scalable from hundreds to millions of documents.

Luke is a handy development and diagnostic tool, which accesses already existing Lucene indexes and allows you to display and modify their content in several ways:

browse by document number, or by term
view documents / copy to clipboard
retrieve a ranked list of most frequent terms
execute a search, and browse the results
analyze search results
selectively delete documents from the index
reconstruct the original document fields, edit them and re-insert to the index
optimize indexes
open indexes consisting of multiple parts, and/or located on Hadoop filesystem
and much more...
Current stable release of Luke is 4.0.0-ALPHA and it includes Lucene 4.0.0-ALPHA and Hadoop 0.20.2. Available is also Luke 3.5.0 (using Lucene 3.5.0), Luke 1.0.1 (using Lucene 3.0.1), 0.9.9.1 based on Lucene 2.9.1, and other versions as well - please see the Downloads section.

Luke releases are numbered the same as the version of Lucene libraries that they use (plus a minor number in case of bugfix releases).

Below is a screenshot of the application showing the Overview section, which displays the details of the index format and some overall statistics.


if you want to check the sql queries (SQL debugger ) u can use

P6Py
Log4jdbc


I hope you it suffice your inquisitivy...:)

_________________
Regards
Akash Miital
http://akash.thegrassroots.co.in/hibernate/


Top
 Profile  
 
 Post subject: Re: Hibernate Second Level Cache Provider and Cache Monitor
PostPosted: Thu Apr 18, 2013 4:15 am 
Regular
Regular

Joined: Wed Apr 10, 2013 1:02 am
Posts: 50
Hey man one more thing if you are willing to find a tool that can help you analyse the 1st level cache or In memory then..
I dont know about any tool but i wrote a generic utility to show all cache related properties using hibernate statisitcs.

care to share in case you build GUI for the same

Code:
/** @author Akash Mittal
    @version 1.0
   Project:Hibernate4-Examples-WO-Maven
   Package:com.akash.util
   File Nam:HibernateStatistics.java
    Last Updated 06-Apr-2013
    Purpose:
*/

package com.akash.util;


import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import org.hibernate.Session;
import org.hibernate.stat.SessionStatistics;
import org.hibernate.stat.Statistics;

public class HibernateStatistics {

   public static void printSessionFactoryStatistics(Session session) throws Exception{
         final Object[] nullObject =null;
         checkIfNull(session);
          Statistics sessionFactoryStatistics = session.getSessionFactory().getStatistics();
         checkIfNull(sessionFactoryStatistics);

         System.err.println("------------------SessionFactoryStatistics------------------------");
         for(PropertyDescriptor propertyDescriptor :
             Introspector.getBeanInfo(sessionFactoryStatistics.getClass()).getPropertyDescriptors()){
            checkIfNull(propertyDescriptor);
            Method method =   propertyDescriptor.getReadMethod();
            String methodName =   method.getName().substring(3);
            Class<?> returnType = method.getReturnType();
            System.out.print(methodName+":");
            if(returnType.toString().equals("class [Ljava.lang.String;")){
               // To doo
            }else{
               System.out.print(method.invoke(sessionFactoryStatistics, nullObject));
            }
            System.out.println();   
         }
      
   }
   

   public static void printSessionStatistics(Session session) throws Exception{
      Object[] nullObject =null;
      checkIfNull(session);
      SessionStatistics sessionStatistics = session.getStatistics();
      checkIfNull(sessionStatistics);

      System.err.println("------------------SessionStatistics------------------------");
      for(PropertyDescriptor propertyDescriptor :
          Introspector.getBeanInfo(sessionStatistics.getClass()).getPropertyDescriptors()){
         checkIfNull(propertyDescriptor);
         Method method =   propertyDescriptor.getReadMethod();
         String methodName =   method.getName().substring(3);
         Class<?> returnType = method.getReturnType();
         System.out.print(methodName+":");
         if(returnType.toString().equals("class [Ljava.lang.String;")){
            // To doo
         }else{
            System.out.print(method.invoke(sessionStatistics, nullObject));
         }
         System.out.println();   
      }
   
}

   
   private static void checkIfNull(Object object) throws Exception{
      if(null==object)
         throw new Exception("Object Cannot be null");
      
   }
   
}

_________________
Regards
Akash Miital
http://akash.thegrassroots.co.in/hibernate/


Top
 Profile  
 
 Post subject: Re: Hibernate Second Level Cache Provider and Cache Monitor
PostPosted: Thu Apr 18, 2013 4:25 am 
Beginner
Beginner

Joined: Tue Feb 05, 2013 10:04 am
Posts: 20
Hello, thank you for your help.

I have downloaded EhCache monitoring tool but I didn't have any success configuring it. I always get 0 sondes registered.
My system executes complex queries and the overall performance is bad, the performance drop is dued to the the database accesses, that's why I would like to integrate a Hibernate second level cache solution and compensate a little bit the database load.

I would like to have a clear idea of the performance increase with a cache system and that's why I would like to monitor all cache cache activity.


I' m a Hibernate newbie and I don't know if EhCache is the most appropiate solution for my application but it is mature, has a great community and all is well documented.

Thank you for your help.


Top
 Profile  
 
 Post subject: Re: Hibernate Second Level Cache Provider and Cache Monitor
PostPosted: Thu Apr 18, 2013 5:02 am 
Regular
Regular

Joined: Wed Apr 10, 2013 1:02 am
Posts: 50
Hey man no issues hibernate statistic is very powerful too.

Still you dint answer my question...:)

_________________
Regards
Akash Miital
http://akash.thegrassroots.co.in/hibernate/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.