JBoss缓存为JBoss集群提供分布式缓存和状态复制服务。一个JBoss 集群可以持有若干JBoss Cache MBeans (像TreeCache MBean一样,被大家所熟悉), HTTP会话复制一个, 有状态会话 beans一个, cached实体beans一个, 等等. 一个普通的TreeCache MBean 配置被列出到下面的表格里。应用程序明确TreeCache MBean配置涵盖在后面的章节里,当这些应用程序被讨论的时候。
<mbean code="org.jboss.cache.TreeCach
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>
上面的列表中,省略了JGroups 的配置元素 (例如, ClusterConfig 属性).在本章的前一节你可以学习到怎么配置JGroups (Section 1, “JGroups Configuration”). TreeCache MBean 使用下列属性。
• CacheLoaderClass指定CacheLoader实现的完整的有效的类名.
• CacheLoaderConfig包含能自我配置的特殊的CacheLoader实现的properties列表。
• CacheLoaderFetchPersistentState指定是否从其他节点获取持久化状态。这个持久华被获取仅仅在CacheLoaderShared 是 false的时候. 这个属性在FetchStateOnStartup 是 true 的时候被使用。
• CacheLoaderFetchTransientState指定是否从其他节点获取内存中的状态。如果FetchStateOnStartup是true,这个属性被使用.
• CacheLoaderPreload包含需要被预载的节点列表,节点之间用逗号分隔。
(例如, /aop, /productcatalogue).
• CacheLoaderShared指定我们是否应该共享数据存储,或者每一个节点是否应该持有它的自己的本地数据存储。
• CacheMode指定在集群结点之间怎么同步cache。这可能值包括LOCAL, REPL_SYNC, or REPL_ASYNC.
• ClusterName指定集群的名称,即哪个集群。这个值需要与在集群中所有节点的集群名字一样,这样才能使它们能够找到对方。
• ClusterConfig 定制(contains)根本的JGroups堆(underlying JGroups stack)的配置 (see Section 1, “JGroups Configuration” ).
• EvictionPolicyClass指定实现了EvictionPolicy接口的类的名字。你可以使用JBoss Cache提供的EvictionPolicy类或者提供你自己policy实现。如果这个属性是空的, 没有eviction policy被激活.
• EvictionPolicyConfig包含制定eviction政策的配置参数。注意这个内容是供应商特殊的。
• FetchStateOnStartup指定从现有的成员中是否获得初始状态。它允许warm/hot 缓存 (true/false).这个可以由CacheLoaderFetchTransientState和 CacheLoaderFetchPersistentState进一步定义.
• InitialStateRetrievalTimeout指定重获初始状态等待的时间,单位是毫秒。
• IsolationLevel指定节点锁定级别。可能的值包括 SERIALIZABLE,REPEATABLE_READ (默认的), READ_COMMITTED, READ_UNCOMMITTED, 和 NONE.
• LockAcquisitionTimeout指定等待一个锁定被获得的时间,单位是毫秒。
如果一个锁定不能被获得,那么一个exception异常将被抛出(thrown)。
• ReplQueueInterval指定元素从复制队列被复制的时间,单位是毫秒。
• SyncReplTimeout指定直到复制ACKs已经被集群中的所有节点接收的等待时间,单位的毫秒。 这个属性仅仅用于同步复制方式 (例如, CacheMode 属性是REPL_SYNC).
• UseReplQueue指定是否使用复制队列(true/false). 这个属性仅仅应用于同步复制方式(例如., CacheMode 属性是 REPL_ASYNC).
• ReplQueueMaxElements指定知道开始复制时,在复制队列里元素的最大数量。
• TransactionManagerLookupClass指定实现TransactionManagerLookup接口的类的完整有效的名字。在JBoss AS里面,事务管理的默认值是JBossTransactionManagerLookup.
本文转自xudayu 51CTO博客,原文链接:http://blog.51cto.com/xudayu/72827,如需转载请自行联系原作者