SlideShare una empresa de Scribd logo
1 de 28
Introduction to
                                                           Terracotta
                                                                                             Cris J. Holdorph
                                                                                                 Software Architect
                                                                                                       Unicon, Inc.

                                                                                                 Sakai Conference
                                                                                                   Cambridge, MA
                                                                                                     July 9, 2009




© Copyright Unicon, Inc., 2009. Some rights reserved. This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/us/
Agenda
1. Introduction
2. Main Parts
3. Terracotta Integration Modules
4. Hello World
5. Lessons Learned using Terracotta
6. Different Uses for Terracotta
7. Resources
                                      2
Introduction




               3
Introduction
●
    Terracotta is...
    –   A Distributed Cache
    –   A Distributed Session Server
    –   Network Attached Memory


●
    Terracotta is...
    –   Open Source
    –   Java
    –   Client / Server

                                       4
Main Parts




             5
Main Parts
●
    Terracotta Server
    –   tc-config.xml


●
    Terracotta Enabled Application
    –   tc-config.xml
    –   JAVA_OPTS


●
    Terracotta Administration Console


                                        6
7
tc-config.xml
●
    Roots
●
    Locks
●
    Instrumented Classes
●
    Transient Fields
    –   Marking
    –   Resolving




                                    8
Configuring Roots in tc-config.xml

   <roots>
    <root>
      <field-name>org.pkg.MyClass.aField</field-name>
    </root>
    <root>
      <field-name>org.pkg.MyClass.field2</field-name>
    </root>
   </roots>




                                                        9
Terracotta Locks
●
    Four types of locks
    –   write (default)
    –   synchronous-write
    –   read
    –   concurrent (discouraged)
●
    All changes to a Terracotta managed object
    must be done in the scope of a lock
●
    You do not need a lock on the object you are
    changing
●
    Locks are the Transactions of Terracotta
                                                 10
Configuring Locks in tc-config.xml

<locks>
  <autolock auto-synchronized="false">
    <method-expression>*
org.pkg.MyClass.method(..)</method-expression>
    <lock-level>write</lock-level>
  </autolock>
  <autolock auto-synchronized="false">
    <method-expression>* org.pkg.SomeClass$Inny.run(..)</
method-expression>
    <lock-level>write</lock-level>
  </autolock>
</locks>

                                                            11
Instrumented Classes
●
    Each instrumented class can or must
    configure the following section
    –   class-expression (required)
    –   honor-transient (optional)
    –   on-load (optional)
●
    Optional instrumented-classes section
    –   exclude (optional)




                                            12
Configuring Instrumented
          Classes in tc-config.xml
<instrumented-classes>
  <include>
      <class-expression>org.pkg.MyClass</class-expression>
      <honor-transient>true</honor-transient>
      <on-load><execute><![CDATA[self.log =
org.apache.commons.logging.LogFactory.getLog(org.pkg.MyClass.class);
]]></execute></on-load>
  </include>
  <include>
      <class-expression>org.pkg.YourClass</class-expression>
      <honor-transient>true</honor-transient>
      <on-load>
        <method>resolveTransientFields</method>
      </on-load>
  </include>
</instrumented-classes>                                           13
Resolving Transient Fields
●
    Transient Fields may be specified 2 ways
    –   Transient keyword in the Java source file and
        corresponding property to honor transient
        keyword in tc-config.xml
    –   Explicitly declaring a field as transient in the tc-
        config.xml file
●
    Transient Fields may be resolved in 2 ways
    –   BeanShell script in tc-config.xml
    –   Calling a method on the resolved object


                                                               14
Resolving a Transient Field with
            BeanShell
<instrumented-classes>
  <include>
      <class-expression>org.pkg.MyClass</class-expression>
      <honor-transient>true</honor-transient>
      <on-load>
        <execute><![CDATA[self.log =
org.apache.commons.logging.LogFactory.getLog(org.pkg.MyClass.cla
ss);]]></execute>
      </on-load>
  </include>
</instrumented-classes>




                                                                   15
Resolving a Transient Field with Java
 <instrumented-classes>
   <include>
       <class-expression>org.pkg.YourClass</class-expression>
       <honor-transient>true</honor-transient>
       <on-load>
         <method>resolveTransientFields</method>
       </on-load>
   </include>
 </instrumented-classes>




                                                                16
Terracotta Integration
       Modules




                         17
Terracotta Integration Modules
●
    TIM (Terracotta Integration Module)
    –   OSGi bundle
    –   Maven artifact


●
    Use to decompose your tc-config.xml
●
    Let different application components manage
    their own tc-config.xml configuration bits
●
    Maven support for building a TIM


                                             18
Using a TIM in tc-config.xml

<clients>
   <logs>/var/logs/terracotta/client/</logs>
   <statistics>/var/logs/terracotta/clientstats</statistics>
   <modules>
      <repository>/opt/local/tc-repo/</repository>
      <module name="tim-mytim" version="1.2.3" group-
id="org.pkg"/>
      <module name="tim-yourtim" version="2.0.7" group-
id="org.pkg"/>
   </modules>
</clients>



                                                          19
Creating a TIM with Maven

       <plugins>
         <plugin>
           <groupId>org.terracotta.maven.plugins</groupId>
           <artifactId>tc-maven-plugin</artifactId>
         </plugin>
         <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-jar-plugin</artifactId>
         </plugin>
       </plugins>


For a complete example look at the following pom.xml file
https://source.sakaiproject.org/svn/kernel/trunk/kernel-tim/pom.xml
                                                                      20
Lessons Learned




                  21
Lessons Learned
●
    Serializable, Transient, Synchronization
●
    Course Grained Locking versus Fine Grained
    Locking
●
    Cluster-wide Locking
●
    TIMs




                                               22
Lessons Learned
●
    Partitioning your data
    –   Avoiding iterating over all objects in a Root
        collection
●
    Minor field updates vs Full object
    replacements
●
    Instrumenting ALL classes that access shared
    objects
●
    Avoid direct field access (use setters instead)
●
    Avoid non-static inner classes (they require
    storage of the outer class)
                                                        23
Different Uses for
    Terracotta




                     24
Different Uses for Terracotta
●
    Clustering your application for server failover
    –   Transparent session migration
●
    Hibernate second level cache mirroring
●
    General purpose cache mirroring
●
    Pseudo Object Database




                                                 25
Resources




            26
Resources
●
    Cluster-enabling Sakai with Terracotta
     –   Tuesday, 10:15 am
●
    Websites
     –   Open Source http://www.terracotta.org/
     –   Commercial http://www.terracottatech.com/
●
    Website Resources
     –   Downloads
     –   Documentation
     –   Forums
●
    Book
     –   The Definitive Guide to Terracotta, ISBN-13: 978-
         1590599860
                                                             27
Questions & Answers




          Cris J. Holdorph
          Software Architect
          Unicon, Inc.

          holdorph@unicon.net
          www.unicon.net



                                28

Más contenido relacionado

La actualidad más candente

Logging Last Resource Optimization for Distributed Transactions in Oracle…
Logging Last Resource Optimization for Distributed Transactions in  Oracle…Logging Last Resource Optimization for Distributed Transactions in  Oracle…
Logging Last Resource Optimization for Distributed Transactions in Oracle…
Gera Shegalov
 
Logging Last Resource Optimization for Distributed Transactions in Oracle We...
Logging Last Resource Optimization for Distributed Transactions in  Oracle We...Logging Last Resource Optimization for Distributed Transactions in  Oracle We...
Logging Last Resource Optimization for Distributed Transactions in Oracle We...
Gera Shegalov
 

La actualidad más candente (13)

Logging Last Resource Optimization for Distributed Transactions in Oracle…
Logging Last Resource Optimization for Distributed Transactions in  Oracle…Logging Last Resource Optimization for Distributed Transactions in  Oracle…
Logging Last Resource Optimization for Distributed Transactions in Oracle…
 
MariaDB Server on macOS - FOSDEM 2022 MariaDB Devroom
MariaDB Server on macOS -  FOSDEM 2022 MariaDB DevroomMariaDB Server on macOS -  FOSDEM 2022 MariaDB Devroom
MariaDB Server on macOS - FOSDEM 2022 MariaDB Devroom
 
MySQL Parallel Replication: inventory, use-cases and limitations
MySQL Parallel Replication: inventory, use-cases and limitationsMySQL Parallel Replication: inventory, use-cases and limitations
MySQL Parallel Replication: inventory, use-cases and limitations
 
MySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitationsMySQL Parallel Replication: inventory, use-case and limitations
MySQL Parallel Replication: inventory, use-case and limitations
 
MySQL/MariaDB Parallel Replication: inventory, use-case and limitations
MySQL/MariaDB Parallel Replication: inventory, use-case and limitationsMySQL/MariaDB Parallel Replication: inventory, use-case and limitations
MySQL/MariaDB Parallel Replication: inventory, use-case and limitations
 
Logging Last Resource Optimization for Distributed Transactions in Oracle We...
Logging Last Resource Optimization for Distributed Transactions in  Oracle We...Logging Last Resource Optimization for Distributed Transactions in  Oracle We...
Logging Last Resource Optimization for Distributed Transactions in Oracle We...
 
MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...
MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...
MySQL Parallel Replication (LOGICAL_CLOCK): all the 5.7 (and some of the 8.0)...
 
Riding the Binlog: an in Deep Dissection of the Replication Stream
Riding the Binlog: an in Deep Dissection of the Replication StreamRiding the Binlog: an in Deep Dissection of the Replication Stream
Riding the Binlog: an in Deep Dissection of the Replication Stream
 
Managing and Visualizing your Replication Topologies with Orchestrator
Managing and Visualizing your Replication Topologies with OrchestratorManaging and Visualizing your Replication Topologies with Orchestrator
Managing and Visualizing your Replication Topologies with Orchestrator
 
Configuration management I - Ansible + Packer
Configuration management I - Ansible + PackerConfiguration management I - Ansible + Packer
Configuration management I - Ansible + Packer
 
Running Pharo on the GemStone VM
Running Pharo on the GemStone VMRunning Pharo on the GemStone VM
Running Pharo on the GemStone VM
 
FlashCache
FlashCacheFlashCache
FlashCache
 
NoSQL with MySQL
NoSQL with MySQLNoSQL with MySQL
NoSQL with MySQL
 

Similar a Introduction to Terracotta

Terracotta Ch'ti Jug
Terracotta Ch'ti JugTerracotta Ch'ti Jug
Terracotta Ch'ti Jug
Ch'ti JUG
 
Lessons Learned on Java Tuning for Our Cassandra Clusters (Carlos Monroy, Kne...
Lessons Learned on Java Tuning for Our Cassandra Clusters (Carlos Monroy, Kne...Lessons Learned on Java Tuning for Our Cassandra Clusters (Carlos Monroy, Kne...
Lessons Learned on Java Tuning for Our Cassandra Clusters (Carlos Monroy, Kne...
DataStax
 
From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2
Alessandro Molina
 

Similar a Introduction to Terracotta (20)

Clustering Sakai with Terracotta
Clustering Sakai with TerracottaClustering Sakai with Terracotta
Clustering Sakai with Terracotta
 
Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !Java and Containers - Make it Awesome !
Java and Containers - Make it Awesome !
 
Lightweight Grids With Terracotta
Lightweight Grids With TerracottaLightweight Grids With Terracotta
Lightweight Grids With Terracotta
 
Ob1k presentation at Java.IL
Ob1k presentation at Java.ILOb1k presentation at Java.IL
Ob1k presentation at Java.IL
 
Terracotta Ch'ti Jug
Terracotta Ch'ti JugTerracotta Ch'ti Jug
Terracotta Ch'ti Jug
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
 
JVM Performance Tuning
JVM Performance TuningJVM Performance Tuning
JVM Performance Tuning
 
Writing Plugged-in Java EE Apps: Jason Lee
Writing Plugged-in Java EE Apps: Jason LeeWriting Plugged-in Java EE Apps: Jason Lee
Writing Plugged-in Java EE Apps: Jason Lee
 
Software Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and FlamegraphsSoftware Profiling: Java Performance, Profiling and Flamegraphs
Software Profiling: Java Performance, Profiling and Flamegraphs
 
Terraform training 🎒 - Basic
Terraform training 🎒 - BasicTerraform training 🎒 - Basic
Terraform training 🎒 - Basic
 
Lessons Learned on Java Tuning for Our Cassandra Clusters (Carlos Monroy, Kne...
Lessons Learned on Java Tuning for Our Cassandra Clusters (Carlos Monroy, Kne...Lessons Learned on Java Tuning for Our Cassandra Clusters (Carlos Monroy, Kne...
Lessons Learned on Java Tuning for Our Cassandra Clusters (Carlos Monroy, Kne...
 
Kommons
KommonsKommons
Kommons
 
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
 
Microservices with Micronaut
Microservices with MicronautMicroservices with Micronaut
Microservices with Micronaut
 
Self-service PR-based Terraform
Self-service PR-based TerraformSelf-service PR-based Terraform
Self-service PR-based Terraform
 
Java is Container Ready - Vaibhav - Container Conference 2018
Java is Container Ready - Vaibhav - Container Conference 2018Java is Container Ready - Vaibhav - Container Conference 2018
Java is Container Ready - Vaibhav - Container Conference 2018
 
Clug 2012 March web server optimisation
Clug 2012 March   web server optimisationClug 2012 March   web server optimisation
Clug 2012 March web server optimisation
 
From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2
 
Tomcat from a cluster to the cloud on RP3
Tomcat from a cluster to the cloud on RP3Tomcat from a cluster to the cloud on RP3
Tomcat from a cluster to the cloud on RP3
 
Golden Gate - How to start such a project?
Golden Gate  - How to start such a project?Golden Gate  - How to start such a project?
Golden Gate - How to start such a project?
 

Más de Cris Holdorph

Más de Cris Holdorph (8)

Programming for Performance
Programming for PerformanceProgramming for Performance
Programming for Performance
 
Introduction to International MyLabs
Introduction to International MyLabsIntroduction to International MyLabs
Introduction to International MyLabs
 
Using Sakai Site Archive for Good not Evil
Using Sakai Site Archive for Good not EvilUsing Sakai Site Archive for Good not Evil
Using Sakai Site Archive for Good not Evil
 
No SQL Technologies
No SQL TechnologiesNo SQL Technologies
No SQL Technologies
 
Clustering Made Easier: Using Terracotta with Hibernate and/or EHCache
Clustering Made Easier: Using Terracotta with Hibernate and/or EHCacheClustering Made Easier: Using Terracotta with Hibernate and/or EHCache
Clustering Made Easier: Using Terracotta with Hibernate and/or EHCache
 
Developing JSR 286 Portlets
Developing JSR 286 PortletsDeveloping JSR 286 Portlets
Developing JSR 286 Portlets
 
Adding Performance Testing to a Software Development Project
Adding Performance Testing to a Software Development ProjectAdding Performance Testing to a Software Development Project
Adding Performance Testing to a Software Development Project
 
Sakai and IMS LIS Integration
Sakai and IMS LIS IntegrationSakai and IMS LIS Integration
Sakai and IMS LIS Integration
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Introduction to Terracotta

  • 1. Introduction to Terracotta Cris J. Holdorph Software Architect Unicon, Inc. Sakai Conference Cambridge, MA July 9, 2009 © Copyright Unicon, Inc., 2009. Some rights reserved. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/us/
  • 2. Agenda 1. Introduction 2. Main Parts 3. Terracotta Integration Modules 4. Hello World 5. Lessons Learned using Terracotta 6. Different Uses for Terracotta 7. Resources 2
  • 4. Introduction ● Terracotta is... – A Distributed Cache – A Distributed Session Server – Network Attached Memory ● Terracotta is... – Open Source – Java – Client / Server 4
  • 6. Main Parts ● Terracotta Server – tc-config.xml ● Terracotta Enabled Application – tc-config.xml – JAVA_OPTS ● Terracotta Administration Console 6
  • 7. 7
  • 8. tc-config.xml ● Roots ● Locks ● Instrumented Classes ● Transient Fields – Marking – Resolving 8
  • 9. Configuring Roots in tc-config.xml <roots> <root> <field-name>org.pkg.MyClass.aField</field-name> </root> <root> <field-name>org.pkg.MyClass.field2</field-name> </root> </roots> 9
  • 10. Terracotta Locks ● Four types of locks – write (default) – synchronous-write – read – concurrent (discouraged) ● All changes to a Terracotta managed object must be done in the scope of a lock ● You do not need a lock on the object you are changing ● Locks are the Transactions of Terracotta 10
  • 11. Configuring Locks in tc-config.xml <locks> <autolock auto-synchronized="false"> <method-expression>* org.pkg.MyClass.method(..)</method-expression> <lock-level>write</lock-level> </autolock> <autolock auto-synchronized="false"> <method-expression>* org.pkg.SomeClass$Inny.run(..)</ method-expression> <lock-level>write</lock-level> </autolock> </locks> 11
  • 12. Instrumented Classes ● Each instrumented class can or must configure the following section – class-expression (required) – honor-transient (optional) – on-load (optional) ● Optional instrumented-classes section – exclude (optional) 12
  • 13. Configuring Instrumented Classes in tc-config.xml <instrumented-classes> <include> <class-expression>org.pkg.MyClass</class-expression> <honor-transient>true</honor-transient> <on-load><execute><![CDATA[self.log = org.apache.commons.logging.LogFactory.getLog(org.pkg.MyClass.class); ]]></execute></on-load> </include> <include> <class-expression>org.pkg.YourClass</class-expression> <honor-transient>true</honor-transient> <on-load> <method>resolveTransientFields</method> </on-load> </include> </instrumented-classes> 13
  • 14. Resolving Transient Fields ● Transient Fields may be specified 2 ways – Transient keyword in the Java source file and corresponding property to honor transient keyword in tc-config.xml – Explicitly declaring a field as transient in the tc- config.xml file ● Transient Fields may be resolved in 2 ways – BeanShell script in tc-config.xml – Calling a method on the resolved object 14
  • 15. Resolving a Transient Field with BeanShell <instrumented-classes> <include> <class-expression>org.pkg.MyClass</class-expression> <honor-transient>true</honor-transient> <on-load> <execute><![CDATA[self.log = org.apache.commons.logging.LogFactory.getLog(org.pkg.MyClass.cla ss);]]></execute> </on-load> </include> </instrumented-classes> 15
  • 16. Resolving a Transient Field with Java <instrumented-classes> <include> <class-expression>org.pkg.YourClass</class-expression> <honor-transient>true</honor-transient> <on-load> <method>resolveTransientFields</method> </on-load> </include> </instrumented-classes> 16
  • 18. Terracotta Integration Modules ● TIM (Terracotta Integration Module) – OSGi bundle – Maven artifact ● Use to decompose your tc-config.xml ● Let different application components manage their own tc-config.xml configuration bits ● Maven support for building a TIM 18
  • 19. Using a TIM in tc-config.xml <clients> <logs>/var/logs/terracotta/client/</logs> <statistics>/var/logs/terracotta/clientstats</statistics> <modules> <repository>/opt/local/tc-repo/</repository> <module name="tim-mytim" version="1.2.3" group- id="org.pkg"/> <module name="tim-yourtim" version="2.0.7" group- id="org.pkg"/> </modules> </clients> 19
  • 20. Creating a TIM with Maven <plugins> <plugin> <groupId>org.terracotta.maven.plugins</groupId> <artifactId>tc-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> </plugin> </plugins> For a complete example look at the following pom.xml file https://source.sakaiproject.org/svn/kernel/trunk/kernel-tim/pom.xml 20
  • 22. Lessons Learned ● Serializable, Transient, Synchronization ● Course Grained Locking versus Fine Grained Locking ● Cluster-wide Locking ● TIMs 22
  • 23. Lessons Learned ● Partitioning your data – Avoiding iterating over all objects in a Root collection ● Minor field updates vs Full object replacements ● Instrumenting ALL classes that access shared objects ● Avoid direct field access (use setters instead) ● Avoid non-static inner classes (they require storage of the outer class) 23
  • 24. Different Uses for Terracotta 24
  • 25. Different Uses for Terracotta ● Clustering your application for server failover – Transparent session migration ● Hibernate second level cache mirroring ● General purpose cache mirroring ● Pseudo Object Database 25
  • 26. Resources 26
  • 27. Resources ● Cluster-enabling Sakai with Terracotta – Tuesday, 10:15 am ● Websites – Open Source http://www.terracotta.org/ – Commercial http://www.terracottatech.com/ ● Website Resources – Downloads – Documentation – Forums ● Book – The Definitive Guide to Terracotta, ISBN-13: 978- 1590599860 27
  • 28. Questions & Answers Cris J. Holdorph Software Architect Unicon, Inc. holdorph@unicon.net www.unicon.net 28