2.2. JBossCache Configuration

2.2. JBossCache Configuration

JBoss Cache provides distributed cache and state replication services for the JBoss cluster. A JBoss cluster can have multiple JBoss Cache MBeans (known as the TreeCache MBean), one for HTTP session replication, one for stateful session beans, one for cached entity beans, etc. A generic TreeCache MBean configuration is listed below. Application specific TreeCache MBean configurations are covered in later chapters when those applications are discussed.

<mbean code="org.jboss.cache.TreeCache" 
        name="jboss.cache:service=TreeCache">
    
    <depends>jboss:service=Naming</depends> 
    <depends>jboss:service=TransactionManager</depends> 

    <! -- Configure the TransactionManager --> 
    <attribute name="TransactionManagerLookupClass">
        org.jboss.cache.DummyTransactionManagerLookup
    </attribute> 

    <! -- 
            Node locking level : SERIALIZABLE
                                 REPEATABLE_READ (default)
                                 READ_COMMITTED
                                 READ_UNCOMMITTED
                                 NONE        
    --> 
    <attribute name="IsolationLevel">REPEATABLE_READ</attribute> 

    <! --     Valid modes are LOCAL
                             REPL_ASYNC
                             REPL_SYNC
    --> 
    <attribute name="CacheMode">LOCAL</attribute>
 
    <! -- Name of cluster. Needs to be the same for all clusters, in order
             to find each other --> 
    <attribute name="ClusterName">TreeCache-Cluster</attribute> 

    <! --    The max amount of time (in milliseconds) we wait until the
            initial state (ie. the contents of the cache) are 
            retrieved from existing members in a clustered environment
    --> 
    <attribute name="InitialStateRetrievalTimeout">5000</attribute> 

    <! --    Number of milliseconds to wait until all responses for a
            synchronous call have been received.
    --> 
    <attribute name="SyncReplTimeout">10000</attribute> 

    <! --  Max number of milliseconds to wait for a lock acquisition --> 
    <attribute name="LockAcquisitionTimeout">15000</attribute> 

    <! --  Name of the eviction policy class. --> 
    <attribute name="EvictionPolicyClass">
        org.jboss.cache.eviction.LRUPolicy
    </attribute> 

    <! --  Specific eviction policy configurations. This is LRU --> 
    <attribute name="EvictionPolicyConfig">
        <config>
            <attribute name="wakeUpIntervalSeconds">5</attribute> 
            <!--  Cache wide default --> 
            <region name="/_default_">
                <attribute name="maxNodes">5000</attribute> 
                <attribute name="timeToLiveSeconds">1000</attribute> 
            </region>

            <region name="/org/jboss/data">
                <attribute name="maxNodes">5000</attribute> 
                <attribute name="timeToLiveSeconds">1000</attribute> 
            </region>

            <region name="/org/jboss/test/data">
                <attribute name="maxNodes">5</attribute> 
                <attribute name="timeToLiveSeconds">4</attribute> 
            </region>
        </config>
    </attribute>

    <attribute name="CacheLoaderClass">
        org.jboss.cache.loader.bdbje.BdbjeCacheLoader
    </attribute>
    
    <attribute name="CacheLoaderConfig">
       location=c:\\tmp
    </attribute>
    <attribute name="CacheLoaderShared">true</attribute>
    <attribute name="CacheLoaderPreload">
        /a/b/c,/all/my/objects
    </attribute>
    <attribute name="CacheLoaderFetchTransientState">false</attribute>
    <attribute name="CacheLoaderFetchPersistentState">true</attribute>
    
    <attribute name="ClusterConfig">
        ... JGroups config for the cluster ...
    </attribute>
</mbean>
        

The JGroups configuration element (i.e., the ClusterConfig attribute) is omitted from the above listing. You have learned how to configure JGroups earlier in this chapter (Section 2.1, “JGroups Configuration”). The TreeCache MBean takes the following attributes.