Grails 2.1.1 with Terracotta and Ehcache integration

389 Views Asked by At

I'm trying to integrate Grails 2.1.1 with Terracotta and Ehcache but I'm not getting any good results whatsoever.

Could anybody give me some advice in order to configure it? I'm a little bit confused.

1

There are 1 best solutions below

5
On

Working on the subj now. First create ehcache.xml in your grails-app/conf directory. It should look like that:

<ehcache>                                                                                                                                                                                                                                      

 <terracottaConfig url="vm4:9510"/>                                                                                                                                                                                                           

  <defaultCache                                                                                                                                                                                                                                
      maxElementsInMemory="50"                                                                                                                                                                                                                 
      eternal="false"                                                                                                                                                                                                                          
      timeToIdleSeconds="20"                                                                                                                                                                                                                   
      timeToLiveSeconds="20"                                                                                                                                                                                                                   
      overflowToDisk="false"                                                                                                                                                                                                                   
      diskPersistent="false"                                                                                                                                                                                                                   
      memoryStoreEvictionPolicy="LRU"                                                                                                                                                                                                          
       />                                                                                                                                                                                                                                       

   <cache name="processedUrlCache"                                                                                                                                                                                                              
         maxElementsInMemory="50000"                                                                                                                                                                                                           
         eternal="true">                                                                                                                                                                                                                       
      <terracotta />                                                                                                                                                                                                                             
   </cache>                                                                                                                                                                                                                                     

</ehcache> 

Consider that terracottaConfig url should point to your actual host:port where Terracotta server lives. Make sure that your tarracotta cache node has <terracotta/> subnode (similarly to my processUrlCache entry).

Now, put these 3 jars into your project lib directory: ehcache-core-ee-2.6.2.jar, ehcache-terracotta-ee-2.6.2.jar, terracotta-toolkit-1.6-runtime-ee-5.2.0.jar

Actual version may differ (but it should be exactly the same as on your terracotta server, so my suggestion is to take those jars from server lib directories).

Now, run your server (start-tc-server.sh or start-tc-server.bat depending on Unix/Windows platform) and run your grails app. For the first start I would suggest you enabling debug logs in your Config.groovy file by putting

debug 'net.sf.ehcache'

into your log4j section.

Let me know would it help you.