JBoss Cache は、 JBoss クラスタに分散キャッシュとステート複製サービスを提供します。 JBoss クラスタは複数の JBoss Cache MBean (TreeCache MBean として知られている) を持つことができ、一つは HTTP セッション複製のために、もうひとつはステートフルセッション Bean のために、またもうひとつはキャッシュされたエンティティ Bean などのためにあります。一般的な TreeCache MBean 設定は以下にリストしてあります。アプリケーション特定の TreeCache MBean 設定は、これらのアプリケーションが論じられるときに後の章で触れます。
<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>
JGroup 設定要素 (すなわち, the ClusterConfig 属性) は上記のリストから省略されています。 JGroup の設定方法を,この章の (項2.1. 「JGroup 設定」) はじめで学びました。 TreeCache MBean は以下の属性を取得します。
CacheLoaderClass は、 CacheLoader 実装の完全修飾クラス名を指定します。
CacheLoaderConfig は、特定の CacheLoader 実装がそれ自身を設定するためのプロパティーのセットを含みます。
CacheLoaderFetchPersistentState は、他のノードからパーシステンスのステートを取り出すかどうかを指定します。パーシステンスは CacheLoaderShared が false であった場合のみ取り出されます。この属性は FetchStateOnStartup が true であった場合のみに使用されます。
CacheLoaderFetchTransientState は、他のノードから in-memory ステートを取り出すかどうかを指定します。この属性は、FetchStateOnStartup が true であった場合のみに使用されます。
CacheLoaderPreload は、プリロード (例えば, /aop および /productcatalogue) される必要のあるコンマで区切られたノードのリストを含みます。
CacheLoaderShared は、データストアを共有するか、もしくはそれぞれのノードが独自のローカルデータストアを必要とするかを指定します。
CacheMode は、ノード間でどのようにしてキャッシュを同期させるかを指定します。可能な値は LOCAL, REPL_SYNC もしくは REPL_ASYNC です。
ClusterName は、クラスタの名前を指定します。この値はそれらが互いを探しだすために、クラスタ内の全てのノードが同一でなければなりません。
ClusterConfig は、根底をなす JGroup スタックの設定を含んでいます (項2.1. 「JGroup 設定」 をご参照ください) 。
EvictionPolicyClass は、 EvictionPolicy を実装するクラス名を指定します。 EvictionPolicy クラスが提供された JBoss Cache を使用するか、独自のポリシー実装を提供することができます。もしこの属性が空であれば、 eviction ポリシー (eviction policy) は有効になりません。
EvictionPolicyConfig は、指定された eviction ポリシーの設定パラメータを含んでいます。コンテンツはプロバイダ固有になっておりますのでご注意ください。
FetchStateOnStartup は、既存のメンバーからイニシャルステートを入手するかどうかを指定します。それは warm/hot が (true/false) をキャッシュすることを可能にします。これは CacheLoaderFetchTransientState および CacheLoaderFetchPersistentState でさらに深く定義することができます。
InitialStateRetrievalTimeout は、イニシャルステート検索の待ち時間をミリ秒で指定します。
IsolationLevel は、ノードのロッキングレベルを指定します。可能な値は、 SERIALIZABLE, REPEATABLE_READ (デフォルト), READ_COMMITTED, READ_UNCOMMITTED および NONE です。
LockAcquisitionTimeout は、ロックが適用されるまでの待ち時間をミリ秒で指定します。もしロックが適用されない場合は、例外処理を実行します。
ReplQueueInterval は、複製される複製キューからの要素の時間をミリ秒で指定します。
SyncReplTimeout は、クラスタ内の全てのノードから複製 ACK を受け取るまでの待ち時間をミリ秒で指定します。この属性は、同期複製モードにのみ適用されます (すなわち、 CacheMode 属性は REPL_SYNC) 。
UseReplQueue は、複製キュー (true/false) を使用するかどうかを指定します。この属性は同期複製モードだけに適用されます (すなわち、 CacheMode 属性は REPL_ASYNC) 。
ReplQueueMaxElements は、複製が作動するまでの複製キューの中の要素の最大数を指定します。
TransactionManagerLookupClass は、 TransactionManagerLookup を実装する完全修飾クラス名を指定します。JBoss AS の中のトランザクションマネージャーのために、デフォルトで JBossTransactionManagerLookup になっています。また、シンプルなスタンドアロンののために、 DummyTransactionManagerLookup のオプションもあります。