With some tweaking I managed to get one of the webapps in our current project to run using terracotta to cluster caches. The only modification I had to make was related to one of my objects not being threadsafe; actually I solved a potential concurrency problem.

Configuring Terracotta proved to be a bit more complex then I anticipated; but this might be due to my lack of Terracotta knowledge.

Here is the tc-config file I created:

XML:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <tc:tc-config xmlns:tc="http://www.terracotta.org/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.   xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-3.xsd">
  4.   <servers>
  5.     <server host="%i" name="sample" />
  6.   </servers>
  7.   <clients>
  8.     <logs>/Users/peter/JavaApplications/sandbox/log/%D</logs>
  9.     <modules>
  10.       <module name="clustered-commons-collections-3.1" version="1.0.0" />
  11.       <module name="clustered-ehcache-1.3" version="1.0.0" />
  12.       <module name="clustered-hibernate-3.1.2" version="1.0.0" />
  13.       <module name="autolock-synchronizedcollection" version="1.0.0" />
  14.       <module name="autolock-synchronizedset" version="1.0.0" />
  15.     </modules>
  16.   </clients>
  17.   <application>
  18.     <spring>
  19.       <jee-application name="*">
  20.         <session-support>false</session-support>
  21.         <instrumented-classes>
  22.           <include>
  23.             <class-expression>nl.cinema..*</class-expression>
  24.           </include>
  25.           <include>
  26.             <class-expression>org.hibernate.collection..*</class-expression>
  27.           </include>
  28.           <include>
  29.             <class-expression>org.hibernate.cache..*</class-expression>
  30.           </include>
  31.           <include>
  32.             <class-expression>org.hibernate.type..*</class-expression>
  33.           </include>
  34.           <include>
  35.             <class-expression>org.hibernate.EntityMode</class-expression>
  36.           </include>
  37.         </instrumented-classes>
  38.         <transient-fields>
  39.           <field-name>net.sf.ehcache.store.DiskStore.spoolThread</field-name>
  40.           <field-name>net.sf.ehcache.Cache.shutdownHook</field-name>
  41.           <field-name>net.sf.ehcache.store.LfuMemoryStore.random</field-name>
  42.         </transient-fields>
  43.         <locks>
  44.           <autolock>
  45.             <method-expression>* nl.cinema.domain.global.Describer.*(..)</method-expression>
  46.             <lock-level>write</lock-level>
  47.           </autolock>
  48.           <autolock>
  49.             <method-expression>* nl.cinema.domain.util.CacheGroup.*(..)</method-expression>
  50.             <lock-level>write</lock-level>
  51.           </autolock>
  52.         </locks>
  53.         <application-contexts>
  54.           <application-context>
  55.             <paths>
  56.               <path>/WEB-INF/applicationContext.xml</path>
  57.             </paths>
  58.             <beans>
  59.               <bean name="pageCache">
  60.                 <non-distributed-field>logger</non-distributed-field>
  61.                 <non-distributed-field>configLocation</non-distributed-field>
  62.               </bean>
  63.               <bean name="groupCache">
  64.                 <non-distributed-field>logger</non-distributed-field>
  65.                 <non-distributed-field>configLocation</non-distributed-field>
  66.               </bean>
  67.             </beans>
  68.           </application-context>
  69.         </application-contexts>
  70.       </jee-application>
  71.     </spring>
  72.   </application>
  73. </tc:tc-config>

I'm not sure if it would be possible to specify the non-distributed-field in a more global way; without resolving to XML entities.


0 Responses to “Larger application (spring/hibernate/ehcache) running on Terracotta”

  1. No Comments

Leave a Reply





About

Welcome to the weblog of Peter Maas. Here you'll find various posts related to stuff I like (like my kids and espresso) and stuff I do (like developing software).

JavaOne 2008 Pictures


Stretched Limo pub sea_lion Scribbled Sun Logo Tim Bray introducing the (J)Ruby panel javaone2008 keynote Greenland smashmouth golden_gate_warning_sign Acme Anvile at CommunityOne Keynote Stage being build in the nearby park Java + You on a cab nearby hotel Okke en Rudie Joshua Bloch at JavaOne2008 Moscone Center - JavaOne Rudie alcatraz Golden Gate Community One Keynote
View more photos >

Categories



Meld u aan voor PayPal en begin direct met het accepteren van creditcardbetalingen.