JBoss Cache SVN: r5743 - core/trunk/src/main/java/org/jboss/cache/interceptors/base.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-29 07:04:05 -0400 (Tue, 29 Apr 2008)
New Revision: 5743
Removed:
core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingChainedInterceptor.java
Log:
Refactoring
Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingChainedInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingChainedInterceptor.java 2008-04-29 10:26:00 UTC (rev 5742)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingChainedInterceptor.java 2008-04-29 11:04:05 UTC (rev 5743)
@@ -1,382 +0,0 @@
-package org.jboss.cache.interceptors.base;
-
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.read.GravitateDataCommand;
-import org.jboss.cache.commands.read.RemoteExistsCommand;
-import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.commands.write.InvalidateCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveDataCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
-
-/**
- * This interceptor will call {@link #doAfterCall(org.jboss.cache.InvocationContext)} after invoking each handler method.
- * e.g. it is usefull if same resource needs to be released after all invocations.
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 2.2
- */
-public abstract class PostProcessingChainedInterceptor extends CommandInterceptor
-{
- @Override
- public final Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- try
- {
- return executePutDataMapCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- try
- {
- return executePutKeyValueCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
- {
- try
- {
- return executeRemoveNodeCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
- {
- try
- {
- return executeRemoveDataCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
- {
- try
- {
- return executeEvictFqnCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
- {
- try
- {
- return executeInvalidateCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
- {
- try
- {
- return executeRemoveKeyCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
- {
- try
- {
- return executeGetDataMapCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitExistsNodeCommand(InvocationContext ctx, RemoteExistsCommand command) throws Throwable
- {
- try
- {
- return executeExistsNodeCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeExistsNodeCommand(InvocationContext ctx, RemoteExistsCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
- {
- try
- {
- return executeGetKeyValueCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
- {
- try
- {
- return executeGetNodeCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
- {
- try
- {
- return executeGetKeysCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
- {
- try
- {
- return executeGetChildrenNamesCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
- {
- try
- {
- return executeMoveCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
- {
- try
- {
- return executeGravitateDataCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
- {
- try
- {
- return executePrepareCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
- {
- try
- {
- return executeRollbackCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
- {
- try
- {
- return executeCommitCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- @Override
- public final Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- try
- {
- return executeOptimisticPrepareCommand(ctx, command);
- }
- finally
- {
- doAfterCall(ctx);
- }
- }
-
- public Object executeOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- return executeAll(ctx, command);
- }
-
- public Object executeAll(InvocationContext ctx, VisitableCommand command) throws Throwable
- {
- return invokeNextInterceptor(ctx, command);
- }
-
- public abstract void doAfterCall(InvocationContext ctx);
-}
16 years, 8 months
JBoss Cache SVN: r5742 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-04-29 06:26:00 -0400 (Tue, 29 Apr 2008)
New Revision: 5742
Added:
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-async-br.xml
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-async.xml
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-sync-br.xml
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-sync.xml
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async.xml
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync.xml
Log:
updated configs
Copied: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-async-br.xml (from rev 5741, benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async-br.xml)
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-async-br.xml (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-async-br.xml 2008-04-29 10:26:00 UTC (rev 5742)
@@ -0,0 +1,171 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample TreeCache Service Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager
+ -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </attribute>
+
+ <attribute name="NodeLockingScheme">Optimistic</attribute>
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
+ <attribute name="CacheMode">REPL_ASYNC</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+ cluster in order to find each other.
+ -->
+ <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+ <!--Uncomment next three statements to enable JGroups multiplexer.
+This configuration is dependent on the JGroups multiplexer being
+registered in an MBean server such as JBossAS. -->
+ <!--
+ <depends>jgroups.mux:name=Multiplexer</depends>
+ <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+ <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+ -->
+
+ <!-- JGroups protocol stack properties.
+ ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+ -->
+ <attribute name="ClusterConfig">
+ <config>
+ <TCP recv_buf_size="20000000" use_send_queues="false"
+ loopback="false"
+ discard_incompatible_packets="true"
+ max_bundle_size="64000"
+ max_bundle_timeout="30"
+ use_incoming_packet_handler="true"
+ enable_bundling="false"
+ enable_unicast_bundling="false"
+ enable_diagnostics="false"
+
+ use_concurrent_stack="true"
+
+ thread_naming_pattern="pl"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="4"
+ thread_pool.keep_alive_time="30000"
+ thread_pool.queue_enabled="true"
+ thread_pool.queue_max_size="50000"
+ thread_pool.rejection_policy="discard"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="2"
+ oob_thread_pool.max_threads="4"
+ oob_thread_pool.keep_alive_time="10000"
+ oob_thread_pool.queue_enabled="false"
+ oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run"/>
+
+ <!--<PING timeout="2000" num_initial_members="3"/>-->
+ <MPING mcast_addr="232.1.2.3" timeout="2000" num_initial_members="3"/>
+ <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/>
+ <FD timeout="10000" max_tries="5" shun="true"/>
+ <VERIFY_SUSPECT timeout="1500"/>
+ <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
+ retransmit_timeout="300,600,1200,2400,4800"
+ discard_delivered_msgs="true"/>
+ <!--<UNICAST timeout="30,60,120,300,600,1200,2400,3600"/>-->
+ <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+ max_bytes="400000"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="5000"
+ join_retry_timeout="2000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/>
+ <FC max_credits="5000000"
+ min_threshold="0.20"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <!-- <pbcast.STATE_TRANSFER/> -->
+ <pbcast.FLUSH timeout="0"/>
+ </config>
+ </attribute>
+
+
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">10000</attribute>
+
+
+ <!-- Buddy Replication config -->
+ <attribute name="BuddyReplicationConfig">
+ <config>
+ <buddyReplicationEnabled>true</buddyReplicationEnabled>
+ <!-- these are the default values anyway -->
+ <buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>
+ <!-- numBuddies is the number of backup nodes each node maintains. ignoreColocatedBuddies means that
+ each node will *try* to select a buddy on a different physical host. If not able to do so though,
+ it will fall back to colocated nodes. -->
+ <buddyLocatorProperties>
+ numBuddies = 1
+ ignoreColocatedBuddies = true
+ </buddyLocatorProperties>
+
+ <!-- A way to specify a preferred replication group. If specified, we try and pick a buddy why shares
+ the same pool name (falling back to other buddies if not available). This allows the sysdmin to hint at
+ backup buddies are picked, so for example, nodes may be hinted topick buddies on a different physical rack
+ or power supply for added fault tolerance. -->
+ <buddyPoolName>myBuddyPoolReplicationGroup</buddyPoolName>
+ <!-- communication timeout for inter-buddy group organisation messages (such as assigning to and removing
+ from groups -->
+ <buddyCommunicationTimeout>2000</buddyCommunicationTimeout>
+
+ <!-- the following three elements, all relating to data gravitation, default to false -->
+ <!-- Should data gravitation be attempted whenever there is a cache miss on finding a node?
+If false, data will only be gravitated if an Option is set enabling it -->
+ <autoDataGravitation>false</autoDataGravitation>
+ <!-- removes data on remote caches' trees and backup subtrees when gravitated to a new data owner -->
+ <dataGravitationRemoveOnFind>true</dataGravitationRemoveOnFind>
+ <!-- search backup subtrees as well for data when gravitating. Results in backup nodes being able to
+ answer data gravitation requests. -->
+ <dataGravitationSearchBackupTrees>true</dataGravitationSearchBackupTrees>
+
+ </config>
+ </attribute>
+ </mbean>
+
+
+</server>
Copied: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-async.xml (from rev 5741, benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async.xml)
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-async.xml (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-async.xml 2008-04-29 10:26:00 UTC (rev 5742)
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample for total replication. -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager
+ -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </attribute>
+
+
+ <attribute name="NodeLockingScheme">Optimistic</attribute>
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
+ <attribute name="CacheMode">REPL_ASYNC</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+ cluster in order to find each other.
+ -->
+ <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+ <!--Uncomment next three statements to enable JGroups multiplexer.
+ This configuration is dependent on the JGroups multiplexer being
+ registered in an MBean server such as JBossAS. -->
+ <!--
+ <depends>jgroups.mux:name=Multiplexer</depends>
+ <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+ <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+ -->
+
+ <!-- JGroups protocol stack properties.
+ ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+ -->
+ <attribute name="ClusterConfig">
+ <config>
+ <UDP mcast_addr="228.10.10.10"
+ mcast_port="45588"
+ tos="8"
+ ucast_recv_buf_size="20000000"
+ ucast_send_buf_size="640000"
+ mcast_recv_buf_size="25000000"
+ mcast_send_buf_size="640000"
+ loopback="false"
+ discard_incompatible_packets="true"
+ max_bundle_size="64000"
+ max_bundle_timeout="30"
+ use_incoming_packet_handler="true"
+ ip_ttl="2"
+ enable_bundling="false"
+ enable_diagnostics="false"
+
+ use_concurrent_stack="true"
+
+ thread_naming_pattern="pl"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="25"
+ thread_pool.keep_alive_time="30000"
+ thread_pool.queue_enabled="true"
+ thread_pool.queue_max_size="10"
+ thread_pool.rejection_policy="Run"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="1"
+ oob_thread_pool.max_threads="4"
+ oob_thread_pool.keep_alive_time="10000"
+ oob_thread_pool.queue_enabled="true"
+ oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run"/>
+
+ <PING timeout="2000" num_initial_members="3"/>
+ <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/>
+ <FD timeout="10000" max_tries="5" shun="true"/>
+ <VERIFY_SUSPECT timeout="1500"/>
+ <pbcast.NAKACK
+ use_mcast_xmit="false" gc_lag="0"
+ retransmit_timeout="300,600,1200,2400,4800"
+ discard_delivered_msgs="true"/>
+ <UNICAST timeout="300,600,1200,2400,3600"/>
+ <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+ max_bytes="400000"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <!-- <pbcast.STATE_TRANSFER/> -->
+ <pbcast.FLUSH timeout="0"/>
+ </config>
+ </attribute>
+
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">10000</attribute>
+
+
+ </mbean>
+</server>
Copied: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-sync-br.xml (from rev 5741, benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync-br.xml)
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-sync-br.xml (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-sync-br.xml 2008-04-29 10:26:00 UTC (rev 5742)
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample TreeCache Service Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager
+ -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </attribute>
+
+
+ <attribute name="NodeLockingScheme">Optimistic</attribute>
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
+ <attribute name="CacheMode">REPL_SYNC</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+ cluster in order to find each other.
+ -->
+ <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+ <!--Uncomment next three statements to enable JGroups multiplexer.
+This configuration is dependent on the JGroups multiplexer being
+registered in an MBean server such as JBossAS. -->
+ <!--
+ <depends>jgroups.mux:name=Multiplexer</depends>
+ <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+ <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+ -->
+
+ <!-- JGroups protocol stack properties.
+ ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+ -->
+ <attribute name="ClusterConfig">
+ <config>
+ <TCP recv_buf_size="20000000" use_send_queues="false"
+ loopback="false"
+ discard_incompatible_packets="true"
+ max_bundle_size="64000"
+ max_bundle_timeout="30"
+ use_incoming_packet_handler="true"
+ enable_bundling="false"
+ enable_unicast_bundling="false"
+ enable_diagnostics="false"
+
+ use_concurrent_stack="true"
+
+ thread_naming_pattern="pl"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="4"
+ thread_pool.keep_alive_time="30000"
+ thread_pool.queue_enabled="true"
+ thread_pool.queue_max_size="50000"
+ thread_pool.rejection_policy="discard"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="2"
+ oob_thread_pool.max_threads="4"
+ oob_thread_pool.keep_alive_time="10000"
+ oob_thread_pool.queue_enabled="false"
+ oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run"/>
+
+ <!--<PING timeout="2000" num_initial_members="3"/>-->
+ <MPING mcast_addr="232.1.2.3" timeout="2000" num_initial_members="3"/>
+ <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/>
+ <FD timeout="10000" max_tries="5" shun="true"/>
+ <VERIFY_SUSPECT timeout="1500"/>
+ <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
+ retransmit_timeout="300,600,1200,2400,4800"
+ discard_delivered_msgs="true"/>
+ <!--<UNICAST timeout="30,60,120,300,600,1200,2400,3600"/>-->
+ <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+ max_bytes="400000"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="5000"
+ join_retry_timeout="2000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/>
+ <FC max_credits="5000000"
+ min_threshold="0.20"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <!-- <pbcast.STATE_TRANSFER/> -->
+ <pbcast.FLUSH timeout="0"/>
+ </config>
+ </attribute>
+
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">10000</attribute>
+
+
+ <!-- Buddy Replication config -->
+ <attribute name="BuddyReplicationConfig">
+ <config>
+ <buddyReplicationEnabled>true</buddyReplicationEnabled>
+ <!-- these are the default values anyway -->
+ <buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>
+ <!-- numBuddies is the number of backup nodes each node maintains. ignoreColocatedBuddies means that
+ each node will *try* to select a buddy on a different physical host. If not able to do so though,
+ it will fall back to colocated nodes. -->
+ <buddyLocatorProperties>
+ numBuddies = 1
+ ignoreColocatedBuddies = true
+ </buddyLocatorProperties>
+
+ <!-- A way to specify a preferred replication group. If specified, we try and pick a buddy why shares
+ the same pool name (falling back to other buddies if not available). This allows the sysdmin to hint at
+ backup buddies are picked, so for example, nodes may be hinted topick buddies on a different physical rack
+ or power supply for added fault tolerance. -->
+ <buddyPoolName>myBuddyPoolReplicationGroup</buddyPoolName>
+ <!-- communication timeout for inter-buddy group organisation messages (such as assigning to and removing
+ from groups -->
+ <buddyCommunicationTimeout>2000</buddyCommunicationTimeout>
+
+ <!-- the following three elements, all relating to data gravitation, default to false -->
+ <!-- Should data gravitation be attempted whenever there is a cache miss on finding a node?
+If false, data will only be gravitated if an Option is set enabling it -->
+ <autoDataGravitation>false</autoDataGravitation>
+ <!-- removes data on remote caches' trees and backup subtrees when gravitated to a new data owner -->
+ <dataGravitationRemoveOnFind>true</dataGravitationRemoveOnFind>
+ <!-- search backup subtrees as well for data when gravitating. Results in backup nodes being able to
+ answer data gravitation requests. -->
+ <dataGravitationSearchBackupTrees>true</dataGravitationSearchBackupTrees>
+
+ </config>
+ </attribute>
+ </mbean>
+
+
+</server>
Copied: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-sync.xml (from rev 5741, benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync.xml)
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-sync.xml (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/opt-repl-sync.xml 2008-04-29 10:26:00 UTC (rev 5742)
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample for total replication. -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager
+ -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </attribute>
+
+
+ <attribute name="NodeLockingScheme">Optimistic</attribute>
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
+ <attribute name="CacheMode">REPL_SYNC</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+ cluster in order to find each other.
+ -->
+ <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+ <!--Uncomment next three statements to enable JGroups multiplexer.
+ This configuration is dependent on the JGroups multiplexer being
+ registered in an MBean server such as JBossAS. -->
+ <!--
+ <depends>jgroups.mux:name=Multiplexer</depends>
+ <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+ <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+ -->
+
+ <!-- JGroups protocol stack properties.
+ ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+ -->
+ <attribute name="ClusterConfig">
+ <config>
+ <UDP mcast_addr="228.10.10.10"
+ mcast_port="45588"
+ tos="8"
+ ucast_recv_buf_size="20000000"
+ ucast_send_buf_size="640000"
+ mcast_recv_buf_size="25000000"
+ mcast_send_buf_size="640000"
+ loopback="false"
+ discard_incompatible_packets="true"
+ max_bundle_size="64000"
+ max_bundle_timeout="30"
+ use_incoming_packet_handler="true"
+ ip_ttl="2"
+ enable_bundling="false"
+ enable_diagnostics="false"
+
+ use_concurrent_stack="true"
+
+ thread_naming_pattern="pl"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="25"
+ thread_pool.keep_alive_time="30000"
+ thread_pool.queue_enabled="true"
+ thread_pool.queue_max_size="10"
+ thread_pool.rejection_policy="Run"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="1"
+ oob_thread_pool.max_threads="4"
+ oob_thread_pool.keep_alive_time="10000"
+ oob_thread_pool.queue_enabled="true"
+ oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run"/>
+
+ <PING timeout="2000" num_initial_members="3"/>
+ <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/>
+ <FD timeout="10000" max_tries="5" shun="true"/>
+ <VERIFY_SUSPECT timeout="1500"/>
+ <pbcast.NAKACK
+ use_mcast_xmit="false" gc_lag="0"
+ retransmit_timeout="300,600,1200,2400,4800"
+ discard_delivered_msgs="true"/>
+ <UNICAST timeout="300,600,1200,2400,3600"/>
+ <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+ max_bytes="400000"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <!-- <pbcast.STATE_TRANSFER/> -->
+ <pbcast.FLUSH timeout="0"/>
+ </config>
+ </attribute>
+
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">10000</attribute>
+
+
+ </mbean>
+</server>
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async.xml 2008-04-29 09:50:42 UTC (rev 5741)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async.xml 2008-04-29 10:26:00 UTC (rev 5742)
@@ -79,7 +79,7 @@
use_incoming_packet_handler="true"
ip_ttl="2"
enable_bundling="false"
- enable_diagnostics="true"
+ enable_diagnostics="false"
use_concurrent_stack="true"
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync.xml 2008-04-29 09:50:42 UTC (rev 5741)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync.xml 2008-04-29 10:26:00 UTC (rev 5742)
@@ -79,7 +79,7 @@
use_incoming_packet_handler="true"
ip_ttl="2"
enable_bundling="false"
- enable_diagnostics="true"
+ enable_diagnostics="false"
use_concurrent_stack="true"
16 years, 8 months
JBoss Cache SVN: r5741 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-04-29 05:50:42 -0400 (Tue, 29 Apr 2008)
New Revision: 5741
Added:
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync-br.xml
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async-br.xml
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async.xml
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync.xml
Log:
updated configs
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async-br.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async-br.xml 2008-04-29 08:11:34 UTC (rev 5740)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async-br.xml 2008-04-29 09:50:42 UTC (rev 5741)
@@ -1,115 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample TreeCache Service Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
<server>
<classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
- <mbean code="org.jboss.cache.CacheImpl"
- name="jboss.cache:service=TreeCache">
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>
+ <!--
+ Configure the TransactionManager
+ -->
<attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
</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
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
<attribute name="CacheMode">REPL_ASYNC</attribute>
- <attribute name="UseReplQueue">false</attribute>
- <attribute name="ReplQueueInterval">0</attribute>
- <attribute name="ReplQueueMaxElements">0</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+ cluster in order to find each other.
+ -->
<attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+ <!--Uncomment next three statements to enable JGroups multiplexer.
+This configuration is dependent on the JGroups multiplexer being
+registered in an MBean server such as JBossAS. -->
+ <!--
+ <depends>jgroups.mux:name=Multiplexer</depends>
+ <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+ <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+ -->
+
+ <!-- JGroups protocol stack properties.
+ ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+ -->
<attribute name="ClusterConfig">
<config>
- <TCP start_port="7580"
+ <TCP recv_buf_size="20000000" use_send_queues="false"
loopback="false"
discard_incompatible_packets="true"
max_bundle_size="64000"
max_bundle_timeout="30"
use_incoming_packet_handler="true"
- enable_bundling="true"
- enable_diagnostics="true"
- thread_naming_pattern="cl"
+ enable_bundling="false"
+ enable_unicast_bundling="false"
+ enable_diagnostics="false"
+
use_concurrent_stack="true"
- recv_buf_size="20000000"
- send_buf_size="20000000"
+ thread_naming_pattern="pl"
thread_pool.enabled="true"
- thread_pool.min_threads="2"
+ thread_pool.min_threads="1"
thread_pool.max_threads="4"
- thread_pool.keep_alive_time="5000"
+ thread_pool.keep_alive_time="30000"
thread_pool.queue_enabled="true"
- thread_pool.queue_max_size="100000"
+ thread_pool.queue_max_size="50000"
thread_pool.rejection_policy="discard"
oob_thread_pool.enabled="true"
- oob_thread_pool.min_threads="1"
+ oob_thread_pool.min_threads="2"
oob_thread_pool.max_threads="4"
- oob_thread_pool.keep_alive_time="5000"
+ oob_thread_pool.keep_alive_time="10000"
oob_thread_pool.queue_enabled="false"
- oob_thread_pool.queue_max_size="100"
+ oob_thread_pool.queue_max_size="10"
oob_thread_pool.rejection_policy="Run"/>
- <MPING timeout="2000" mcast_addr="232.1.2.3"
- num_initial_members="2"/>
- <MERGE2 max_interval="30000"
- min_interval="10000"/>
+ <!--<PING timeout="2000" num_initial_members="3"/>-->
+ <MPING mcast_addr="232.1.2.3" timeout="2000" num_initial_members="3"/>
+ <MERGE2 max_interval="30000" min_interval="10000"/>
<FD_SOCK/>
<FD timeout="10000" max_tries="5" shun="true"/>
<VERIFY_SUSPECT timeout="1500"/>
- <BARRIER/>
<pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
- retransmit_timeout="50,300,600,1200"
+ retransmit_timeout="300,600,1200,2400,4800"
discard_delivered_msgs="true"/>
+ <!--<UNICAST timeout="30,60,120,300,600,1200,2400,3600"/>-->
<pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
- max_bytes="1000000"/>
- <VIEW_SYNC avg_send_interval="60000"/>
- <pbcast.GMS print_local_addr="true" join_timeout="3000"
- shun="false"
- view_bundling="true"/>
- <FC max_credits="10000000"
- min_threshold="0.20"/>
+ max_bytes="400000"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="5000"
+ join_retry_timeout="2000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/>
+ <FC max_credits="5000000"
+ min_threshold="0.20"/>
<FRAG2 frag_size="60000"/>
- <pbcast.STATE_TRANSFER/>
-
+ <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <!-- <pbcast.STATE_TRANSFER/> -->
+ <pbcast.FLUSH timeout="0"/>
</config>
</attribute>
- <attribute name="FetchInMemoryState">false</attribute>
- <attribute name="InitialStateRetrievalTimeout">15000</attribute>
- <attribute name="SyncReplTimeout">60000</attribute>
+
+
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
<attribute name="LockAcquisitionTimeout">10000</attribute>
- <attribute name="EvictionPolicyConfig">
- </attribute>
- <attribute name="CacheLoaderConfiguration">
- </attribute>
- <attribute name="UseRegionBasedMarshalling">false</attribute>
-
<!-- Buddy Replication config -->
<attribute name="BuddyReplicationConfig">
<config>
<buddyReplicationEnabled>true</buddyReplicationEnabled>
+ <!-- these are the default values anyway -->
<buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>
+ <!-- numBuddies is the number of backup nodes each node maintains. ignoreColocatedBuddies means that
+ each node will *try* to select a buddy on a different physical host. If not able to do so though,
+ it will fall back to colocated nodes. -->
<buddyLocatorProperties>
numBuddies = 1
ignoreColocatedBuddies = true
</buddyLocatorProperties>
+ <!-- A way to specify a preferred replication group. If specified, we try and pick a buddy why shares
+ the same pool name (falling back to other buddies if not available). This allows the sysdmin to hint at
+ backup buddies are picked, so for example, nodes may be hinted topick buddies on a different physical rack
+ or power supply for added fault tolerance. -->
<buddyPoolName>myBuddyPoolReplicationGroup</buddyPoolName>
+ <!-- communication timeout for inter-buddy group organisation messages (such as assigning to and removing
+ from groups -->
+ <buddyCommunicationTimeout>2000</buddyCommunicationTimeout>
- <buddyCommunicationTimeout>10000</buddyCommunicationTimeout>
-
-
+ <!-- the following three elements, all relating to data gravitation, default to false -->
+ <!-- Should data gravitation be attempted whenever there is a cache miss on finding a node?
+If false, data will only be gravitated if an Option is set enabling it -->
<autoDataGravitation>false</autoDataGravitation>
-
+ <!-- removes data on remote caches' trees and backup subtrees when gravitated to a new data owner -->
<dataGravitationRemoveOnFind>true</dataGravitationRemoveOnFind>
-
+ <!-- search backup subtrees as well for data when gravitating. Results in backup nodes being able to
+ answer data gravitation requests. -->
<dataGravitationSearchBackupTrees>true</dataGravitationSearchBackupTrees>
</config>
</attribute>
+ </mbean>
- </mbean>
+
</server>
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async.xml 2008-04-29 08:11:34 UTC (rev 5740)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-async.xml 2008-04-29 09:50:42 UTC (rev 5741)
@@ -1,28 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample for total replication. -->
+<!-- -->
+<!-- ===================================================================== -->
+
<server>
<classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
- <mbean code="org.jboss.cache.CacheImpl"
- name="jboss.cache:service=TreeCache">
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>
+ <!--
+ Configure the TransactionManager
+ -->
<attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
</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
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
<attribute name="CacheMode">REPL_ASYNC</attribute>
- <attribute name="UseReplQueue">false</attribute>
- <attribute name="ReplQueueInterval">0</attribute>
- <attribute name="ReplQueueMaxElements">0</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+ cluster in order to find each other.
+ -->
<attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+ <!--Uncomment next three statements to enable JGroups multiplexer.
+ This configuration is dependent on the JGroups multiplexer being
+ registered in an MBean server such as JBossAS. -->
+ <!--
+ <depends>jgroups.mux:name=Multiplexer</depends>
+ <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+ <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+ -->
+
+ <!-- JGroups protocol stack properties.
+ ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+ -->
<attribute name="ClusterConfig">
<config>
- <UDP mcast_addr="232.10.10.10"
- mcast_port="45599"
+ <UDP mcast_addr="228.10.10.10"
+ mcast_port="45588"
tos="8"
ucast_recv_buf_size="20000000"
ucast_send_buf_size="640000"
@@ -33,39 +77,68 @@
max_bundle_size="64000"
max_bundle_timeout="30"
use_incoming_packet_handler="true"
- ip_ttl="1"
- enable_bundling="false"/>
- <PING timeout="2000" num_initial_members="2"/>
- <MERGE2 max_interval="100000" min_interval="20000"/>
+ ip_ttl="2"
+ enable_bundling="false"
+ enable_diagnostics="true"
+
+ use_concurrent_stack="true"
+
+ thread_naming_pattern="pl"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="25"
+ thread_pool.keep_alive_time="30000"
+ thread_pool.queue_enabled="true"
+ thread_pool.queue_max_size="10"
+ thread_pool.rejection_policy="Run"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="1"
+ oob_thread_pool.max_threads="4"
+ oob_thread_pool.keep_alive_time="10000"
+ oob_thread_pool.queue_enabled="true"
+ oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run"/>
+
+ <PING timeout="2000" num_initial_members="3"/>
+ <MERGE2 max_interval="30000" min_interval="10000"/>
<FD_SOCK/>
<FD timeout="10000" max_tries="5" shun="true"/>
<VERIFY_SUSPECT timeout="1500"/>
- <pbcast.NAKACK max_xmit_size="60000"
- use_mcast_xmit="false" gc_lag="0"
- retransmit_timeout="300,600,1200,2400,4800"
- discard_delivered_msgs="true"/>
+ <pbcast.NAKACK
+ use_mcast_xmit="false" gc_lag="0"
+ retransmit_timeout="300,600,1200,2400,4800"
+ discard_delivered_msgs="true"/>
<UNICAST timeout="300,600,1200,2400,3600"/>
<pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
max_bytes="400000"/>
- <pbcast.GMS print_local_addr="true" join_timeout="3000"
- join_retry_timeout="2000" shun="false" view_bundling="true"/>
- <FC max_credits="10000000"
- min_threshold="0.20"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/>
<FRAG2 frag_size="60000"/>
- <pbcast.STATE_TRANSFER/>
- <pbcast.FLUSH timeout="8000"/>
+ <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <!-- <pbcast.STATE_TRANSFER/> -->
+ <pbcast.FLUSH timeout="0"/>
</config>
</attribute>
- <attribute name="FetchInMemoryState">false</attribute>
- <attribute name="InitialStateRetrievalTimeout">15000</attribute>
- <attribute name="SyncReplTimeout">60000</attribute>
+
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
<attribute name="LockAcquisitionTimeout">10000</attribute>
- <attribute name="EvictionPolicyConfig">
- </attribute>
- <attribute name="CacheLoaderConfiguration">
- </attribute>
- <attribute name="UseRegionBasedMarshalling">false</attribute>
</mbean>
</server>
Added: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync-br.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync-br.xml (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync-br.xml 2008-04-29 09:50:42 UTC (rev 5741)
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample TreeCache Service Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager
+ -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </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
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
+ <attribute name="CacheMode">REPL_SYNC</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+ cluster in order to find each other.
+ -->
+ <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+ <!--Uncomment next three statements to enable JGroups multiplexer.
+This configuration is dependent on the JGroups multiplexer being
+registered in an MBean server such as JBossAS. -->
+ <!--
+ <depends>jgroups.mux:name=Multiplexer</depends>
+ <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+ <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+ -->
+
+ <!-- JGroups protocol stack properties.
+ ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+ -->
+ <attribute name="ClusterConfig">
+ <config>
+ <TCP recv_buf_size="20000000" use_send_queues="false"
+ loopback="false"
+ discard_incompatible_packets="true"
+ max_bundle_size="64000"
+ max_bundle_timeout="30"
+ use_incoming_packet_handler="true"
+ enable_bundling="false"
+ enable_unicast_bundling="false"
+ enable_diagnostics="false"
+
+ use_concurrent_stack="true"
+
+ thread_naming_pattern="pl"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="4"
+ thread_pool.keep_alive_time="30000"
+ thread_pool.queue_enabled="true"
+ thread_pool.queue_max_size="50000"
+ thread_pool.rejection_policy="discard"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="2"
+ oob_thread_pool.max_threads="4"
+ oob_thread_pool.keep_alive_time="10000"
+ oob_thread_pool.queue_enabled="false"
+ oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run"/>
+
+ <!--<PING timeout="2000" num_initial_members="3"/>-->
+ <MPING mcast_addr="232.1.2.3" timeout="2000" num_initial_members="3"/>
+ <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/>
+ <FD timeout="10000" max_tries="5" shun="true"/>
+ <VERIFY_SUSPECT timeout="1500"/>
+ <pbcast.NAKACK use_mcast_xmit="false" gc_lag="0"
+ retransmit_timeout="300,600,1200,2400,4800"
+ discard_delivered_msgs="true"/>
+ <!--<UNICAST timeout="30,60,120,300,600,1200,2400,3600"/>-->
+ <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+ max_bytes="400000"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="5000"
+ join_retry_timeout="2000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/>
+ <FC max_credits="5000000"
+ min_threshold="0.20"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <!-- <pbcast.STATE_TRANSFER/> -->
+ <pbcast.FLUSH timeout="0"/>
+ </config>
+ </attribute>
+
+
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">10000</attribute>
+
+
+ <!-- Buddy Replication config -->
+ <attribute name="BuddyReplicationConfig">
+ <config>
+ <buddyReplicationEnabled>true</buddyReplicationEnabled>
+ <!-- these are the default values anyway -->
+ <buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>
+ <!-- numBuddies is the number of backup nodes each node maintains. ignoreColocatedBuddies means that
+ each node will *try* to select a buddy on a different physical host. If not able to do so though,
+ it will fall back to colocated nodes. -->
+ <buddyLocatorProperties>
+ numBuddies = 1
+ ignoreColocatedBuddies = true
+ </buddyLocatorProperties>
+
+ <!-- A way to specify a preferred replication group. If specified, we try and pick a buddy why shares
+ the same pool name (falling back to other buddies if not available). This allows the sysdmin to hint at
+ backup buddies are picked, so for example, nodes may be hinted topick buddies on a different physical rack
+ or power supply for added fault tolerance. -->
+ <buddyPoolName>myBuddyPoolReplicationGroup</buddyPoolName>
+ <!-- communication timeout for inter-buddy group organisation messages (such as assigning to and removing
+ from groups -->
+ <buddyCommunicationTimeout>2000</buddyCommunicationTimeout>
+
+ <!-- the following three elements, all relating to data gravitation, default to false -->
+ <!-- Should data gravitation be attempted whenever there is a cache miss on finding a node?
+If false, data will only be gravitated if an Option is set enabling it -->
+ <autoDataGravitation>false</autoDataGravitation>
+ <!-- removes data on remote caches' trees and backup subtrees when gravitated to a new data owner -->
+ <dataGravitationRemoveOnFind>true</dataGravitationRemoveOnFind>
+ <!-- search backup subtrees as well for data when gravitating. Results in backup nodes being able to
+ answer data gravitation requests. -->
+ <dataGravitationSearchBackupTrees>true</dataGravitationSearchBackupTrees>
+
+ </config>
+ </attribute>
+ </mbean>
+
+
+</server>
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync.xml 2008-04-29 08:11:34 UTC (rev 5740)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-repl-sync.xml 2008-04-29 09:50:42 UTC (rev 5741)
@@ -1,28 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample for total replication. -->
+<!-- -->
+<!-- ===================================================================== -->
+
<server>
<classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
- <mbean code="org.jboss.cache.CacheImpl"
- name="jboss.cache:service=TreeCache">
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>
+ <!--
+ Configure the TransactionManager
+ -->
<attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
</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
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
<attribute name="CacheMode">REPL_SYNC</attribute>
- <attribute name="UseReplQueue">false</attribute>
- <attribute name="ReplQueueInterval">0</attribute>
- <attribute name="ReplQueueMaxElements">0</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+ cluster in order to find each other.
+ -->
<attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+ <!--Uncomment next three statements to enable JGroups multiplexer.
+ This configuration is dependent on the JGroups multiplexer being
+ registered in an MBean server such as JBossAS. -->
+ <!--
+ <depends>jgroups.mux:name=Multiplexer</depends>
+ <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+ <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+ -->
+
+ <!-- JGroups protocol stack properties.
+ ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+ -->
<attribute name="ClusterConfig">
<config>
- <UDP mcast_addr="232.10.10.10"
- mcast_port="45599"
+ <UDP mcast_addr="228.10.10.10"
+ mcast_port="45588"
tos="8"
ucast_recv_buf_size="20000000"
ucast_send_buf_size="640000"
@@ -33,40 +77,68 @@
max_bundle_size="64000"
max_bundle_timeout="30"
use_incoming_packet_handler="true"
- ip_ttl="1"
- enable_bundling="false"/>
- <PING timeout="2000" num_initial_members="2"/>
- <MERGE2 max_interval="100000" min_interval="20000"/>
+ ip_ttl="2"
+ enable_bundling="false"
+ enable_diagnostics="true"
+
+ use_concurrent_stack="true"
+
+ thread_naming_pattern="pl"
+
+ thread_pool.enabled="true"
+ thread_pool.min_threads="1"
+ thread_pool.max_threads="25"
+ thread_pool.keep_alive_time="30000"
+ thread_pool.queue_enabled="true"
+ thread_pool.queue_max_size="10"
+ thread_pool.rejection_policy="Run"
+
+ oob_thread_pool.enabled="true"
+ oob_thread_pool.min_threads="1"
+ oob_thread_pool.max_threads="4"
+ oob_thread_pool.keep_alive_time="10000"
+ oob_thread_pool.queue_enabled="true"
+ oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run"/>
+
+ <PING timeout="2000" num_initial_members="3"/>
+ <MERGE2 max_interval="30000" min_interval="10000"/>
<FD_SOCK/>
<FD timeout="10000" max_tries="5" shun="true"/>
<VERIFY_SUSPECT timeout="1500"/>
- <pbcast.NAKACK max_xmit_size="60000"
- use_mcast_xmit="false" gc_lag="0"
- retransmit_timeout="300,600,1200,2400,4800"
- discard_delivered_msgs="true"/>
+ <pbcast.NAKACK
+ use_mcast_xmit="false" gc_lag="0"
+ retransmit_timeout="300,600,1200,2400,4800"
+ discard_delivered_msgs="true"/>
<UNICAST timeout="300,600,1200,2400,3600"/>
<pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
max_bytes="400000"/>
- <pbcast.GMS print_local_addr="true" join_timeout="3000"
- join_retry_timeout="2000" shun="false"
- view_bundling="true"/>
- <FC max_credits="10000000"
- min_threshold="0.20"/>
+ <pbcast.GMS print_local_addr="true" join_timeout="5000" shun="false"
+ view_bundling="true" view_ack_collection_timeout="5000"/>
<FRAG2 frag_size="60000"/>
- <pbcast.STATE_TRANSFER/>
- <pbcast.FLUSH timeout="8000"/>
+ <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <!-- <pbcast.STATE_TRANSFER/> -->
+ <pbcast.FLUSH timeout="0"/>
</config>
</attribute>
- <attribute name="FetchInMemoryState">false</attribute>
- <attribute name="InitialStateRetrievalTimeout">15000</attribute>
- <attribute name="SyncReplTimeout">60000</attribute>
+
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
<attribute name="LockAcquisitionTimeout">10000</attribute>
- <attribute name="EvictionPolicyConfig">
- </attribute>
- <attribute name="CacheLoaderConfiguration">
- </attribute>
- <attribute name="UseRegionBasedMarshalling">false</attribute>
</mbean>
</server>
16 years, 8 months
JBoss Cache SVN: r5740 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-29 04:11:34 -0400 (Tue, 29 Apr 2008)
New Revision: 5740
Modified:
core/trunk/src/main/java/org/jboss/cache/LifecycleManager.java
Log:
Set cache status to STOPPED after stopping cache
Modified: core/trunk/src/main/java/org/jboss/cache/LifecycleManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/LifecycleManager.java 2008-04-28 23:24:31 UTC (rev 5739)
+++ core/trunk/src/main/java/org/jboss/cache/LifecycleManager.java 2008-04-29 08:11:34 UTC (rev 5740)
@@ -208,6 +208,10 @@
}
handleLifecycleTransitionFailure(t);
}
+ finally
+ {
+ if (!failed) cacheStatus = CacheStatus.STOPPED;
+ }
}
/**
16 years, 8 months
JBoss Cache SVN: r5739 - core/trunk/src/test/java/org/jboss/cache/lock/pessimistic.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-28 19:24:31 -0400 (Mon, 28 Apr 2008)
New Revision: 5739
Modified:
core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java
Log:
This test should be disabled till 3.0.0
Modified: core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java 2008-04-28 23:19:14 UTC (rev 5738)
+++ core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java 2008-04-28 23:24:31 UTC (rev 5739)
@@ -24,7 +24,7 @@
// The problem is in the way READ_COMMITTED is implemented, i.e., writers are not blocked by readers and this
// allows a reader to hold a lock when a writer comes in and deletes the node in question.
-@Test(groups = {"functional"}, enabled = true)
+@Test(groups = "functional", enabled = false)
// Known issue - See JBCACHE-1164 and JBCACHE-1165
public class ConcurrentPutRemoveTest
{
@@ -61,7 +61,7 @@
}
}
- @Test(invocationCount = 500, enabled = true)
+ @Test(invocationCount = 500, enabled = false)
// TODO: 3.0.0: This is still a known failure. MVCC in 3.0.0 will fix this; enable it in 3.0.0.
public void testLock() throws Exception
{
16 years, 8 months
JBoss Cache SVN: r5738 - in core/trunk/src: test/java/org/jboss/cache/loader and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-28 19:19:14 -0400 (Mon, 28 Apr 2008)
New Revision: 5738
Modified:
core/trunk/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java
core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheLoaderTest.java
Log:
Improved test
Modified: core/trunk/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java 2008-04-28 19:09:53 UTC (rev 5737)
+++ core/trunk/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java 2008-04-28 23:19:14 UTC (rev 5738)
@@ -55,7 +55,6 @@
STOPPED, STARTING, STARTED
}
-
static
{
try
@@ -108,7 +107,6 @@
*/
protected Object invokeWithRetries(Method m, Object... params)
{
-// assertValidState(); // needs more thought
long endTime = System.currentTimeMillis() + config.getTimeout();
do
{
@@ -412,22 +410,6 @@
}
}
- private void assertValidState()
- {
- while (state == State.STARTING)
- {
- try
- {
- Thread.sleep(100);
- }
- catch (InterruptedException e)
- {
- // do nothing
- }
- }
- if (state != State.STARTED) throw new CacheException("Cache Loader not started!");
- }
-
protected void restart() throws IOException
{
stop();
Modified: core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheLoaderTest.java 2008-04-28 19:09:53 UTC (rev 5737)
+++ core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheLoaderTest.java 2008-04-28 23:19:14 UTC (rev 5738)
@@ -20,6 +20,8 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
/**
* Tests the TcpDelegatingCacheLoader
@@ -33,11 +35,13 @@
protected static final int CACHE_SERVER_RESTART_DELAY_MS = 1000;
protected static final int TCP_CACHE_LOADER_TIMEOUT_MS = 2000;
protected static int START_COUNT = 0;
- static TcpCacheServer cache_server = null;
+ static TcpCacheServer cacheServer = null;
@BeforeClass
public static void startCacheServer()
{
+ final CountDownLatch startedSignal = new CountDownLatch(1);
+
Thread t = new Thread()
{
public void run()
@@ -45,15 +49,16 @@
try
{
System.out.println("Starting TcpCacheServer");
- cache_server = new TcpCacheServer();
- cache_server.setBindAddress("127.0.0.1");
- cache_server.setPort(12121);
+ cacheServer = new TcpCacheServer();
+ cacheServer.setBindAddress("127.0.0.1");
+ cacheServer.setPort(12121);
Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
CacheSPI cache = (CacheSPI) new DefaultCacheFactory().createCache(config);
- cache_server.setCache(cache);
- cache_server.create();
- cache_server.start();
+ cacheServer.setCache(cache);
+ cacheServer.create();
+ cacheServer.start();
START_COUNT++;
+ startedSignal.countDown();
}
catch (Exception ex)
{
@@ -64,17 +69,32 @@
};
t.setDaemon(true);
t.start();
- // give the cache server 2 secs to start up
- TestingUtil.sleepThread(2000);
+
+ // Wait for the cache server to start up.
+ boolean started = false;
+ try
+ {
+ started = startedSignal.await(120, TimeUnit.SECONDS);
+ }
+ catch (InterruptedException e)
+ {
+ // do nothing
+ }
+
+ if (!started)
+ {
+ // the TcpCacheServer was unable to start up for some reason!!
+ throw new RuntimeException("Unable to start the TcpCacheServer after 120 seconds!!");
+ }
}
@AfterClass
public static void stopCacheServer()
{
- if (cache_server != null)
+ if (cacheServer != null)
{
System.out.println("Stopping TcpCacheServer");
- cache_server.stop();
+ cacheServer.stop();
}
}
@@ -104,7 +124,6 @@
}
// restart tests
-
public void testCacheServerRestartMidCall() throws Exception
{
CacheServerRestarter restarter = new CacheServerRestarter();
16 years, 8 months
JBoss Cache SVN: r5737 - in core/trunk/src: test/java/org/jboss/cache/api and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-28 15:09:53 -0400 (Mon, 28 Apr 2008)
New Revision: 5737
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
Log:
Fixed regressions
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-04-28 18:56:13 UTC (rev 5736)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-04-28 19:09:53 UTC (rev 5737)
@@ -54,13 +54,13 @@
public Object perform(InvocationContext ctx)
{
- _move(fqn, to, false, ctx);
+ move(fqn, to, false, ctx);
return null;
}
public void rollback()
{
- _move(Fqn.fromRelativeElements(to, fqn.getLastElement()), fqn.getParent(), true, null);
+ move(Fqn.fromRelativeElements(to, fqn.getLastElement()), fqn.getParent(), true, null);
}
@@ -75,7 +75,7 @@
return visitor.visitMoveCommand(ctx, this);
}
- public void _move(Fqn nodeToMoveFqn, Fqn newParentFqn, boolean skipNotifications, InvocationContext ctx)
+ private void move(Fqn nodeToMoveFqn, Fqn newParentFqn, boolean skipNotifications, InvocationContext ctx)
{
// the actual move algorithm.
NodeSPI newParent = dataContainer.findNode(newParentFqn);
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-04-28 18:56:13 UTC (rev 5736)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-04-28 19:09:53 UTC (rev 5737)
@@ -312,7 +312,12 @@
nodeD.put(k, vD);
nodeE = nodeD.addChild(E);
nodeE.put(k, vE);
- cache.evict(Fqn.ROOT, true);
+ cache.evict(Fqn.ROOT);
+ cache.evict(A);
+ cache.evict(B);
+ cache.evict(C);
+ cache.evict(D);
+ cache.evict(E);
// move
if (useTx) tm.begin();
@@ -346,8 +351,17 @@
assertEquals(nodeC, nodeD.getParent());
assertEquals(nodeD, nodeE.getParent());
- if (pasv) cache.evict(Fqn.ROOT, true);
+ if (pasv)
+ {
+ cache.evict(Fqn.ROOT);
+ cache.evict(nodeA.getFqn());
+ cache.evict(nodeB.getFqn());
+ cache.evict(nodeC.getFqn());
+ cache.evict(nodeD.getFqn());
+ cache.evict(nodeE.getFqn());
+ }
+
//now inspect the loader.
assertEquals(vA, loader.get(nodeA.getFqn()).get(k));
assertEquals(vB, loader.get(nodeB.getFqn()).get(k));
16 years, 8 months
JBoss Cache SVN: r5736 - in core/trunk/src/main/java/org/jboss/cache: commands/remote and 5 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-28 14:56:13 -0400 (Mon, 28 Apr 2008)
New Revision: 5736
Removed:
core/trunk/src/main/java/org/jboss/cache/transaction/GlobalTransactionContainer.java
Modified:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
Log:
Consolidated GlobalTransactionContainer and TransactionTable
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -13,7 +13,7 @@
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.GlobalTransactionContainer;
+import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.Transaction;
import java.util.ArrayList;
@@ -452,7 +452,7 @@
public boolean isValidTransaction()
{
- return transaction != null && GlobalTransactionContainer.isValid(transaction);
+ return transaction != null && TransactionTable.isValid(transaction);
}
public void throwIfNeeded(Throwable e) throws Throwable
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -14,7 +14,7 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.GlobalTransactionContainer;
+import org.jboss.cache.transaction.TransactionTable;
import java.util.List;
@@ -33,7 +33,7 @@
/* dependencies */
private BuddyManager buddyManager;
- private GlobalTransactionContainer transactionHelper;
+ private TransactionTable transactionTable;
private InterceptorChain invoker;
private CommandsFactory commandsFactory;
private DataContainer dataContainer;
@@ -60,12 +60,12 @@
}
@Inject
- public void initialize(BuddyManager buddyManager, InterceptorChain invoker, GlobalTransactionContainer transactionHelper,
+ public void initialize(BuddyManager buddyManager, InterceptorChain invoker, TransactionTable transactionTable,
CommandsFactory commandsFactory, DataContainer dataContainer)
{
this.buddyManager = buddyManager;
this.invoker = invoker;
- this.transactionHelper = transactionHelper;
+ this.transactionTable = transactionTable;
this.commandsFactory = commandsFactory;
this.dataContainer = dataContainer;
}
@@ -77,7 +77,7 @@
if (trace)
log.trace("DataGravitationCleanup: Removing primary (" + fqn + ") and backup (" + backup + ")");
- GlobalTransaction gtx = transactionHelper.getCurrentTransaction();
+ GlobalTransaction gtx = transactionTable.getCurrentTransaction();
if (!executeRemove(gtx, fqn))
{
// only attempt to clean up the backup if the primary did not exist - a waste of a call otherwise.
Modified: core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -13,7 +13,6 @@
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.remoting.jgroups.ChannelMessageListener;
import org.jboss.cache.statetransfer.StateTransferManager;
-import org.jboss.cache.transaction.GlobalTransactionContainer;
import org.jboss.cache.transaction.TransactionTable;
/**
@@ -22,10 +21,10 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.1.0
*/
-@DefaultFactoryFor(classes = {StateTransferManager.class, TransactionTable.class, RegionManager.class, Notifier.class,
+@DefaultFactoryFor(classes = {StateTransferManager.class, RegionManager.class, Notifier.class,
ChannelMessageListener.class, CacheLoaderManager.class, Marshaller.class,
InvocationContextContainer.class, CacheInvocationDelegate.class,
- GlobalTransactionContainer.class, DataContainer.class, CommandsFactory.class, LockManager.class})
+ TransactionTable.class, DataContainer.class, CommandsFactory.class, LockManager.class})
public class EmptyConstructorFactory extends ComponentFactory
{
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -34,7 +34,7 @@
private BuddyManager buddyManager;
private boolean usingBuddyReplication;
private ReplicationQueue replicationQueue;
- private TransactionTable txTable;
+ protected TransactionTable txTable;
private CommandsFactory commandsFactory;
protected RPCManager rpcManager;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -8,9 +8,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.RPCManager;
-import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.cluster.ReplicationQueue;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.VisitableCommand;
@@ -34,7 +31,6 @@
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.GlobalTransactionContainer;
import org.jboss.cache.transaction.OptimisticTransactionEntry;
import org.jboss.cache.transaction.TransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
@@ -64,28 +60,18 @@
public class InvalidationInterceptor extends BaseRpcInterceptor implements InvalidationInterceptorMBean
{
private long invalidations = 0;
- protected TransactionTable txTable;
protected Map<GlobalTransaction, List<ReversibleCommand>> txMods;
protected boolean optimistic;
private CommandsFactory commandsFactory;
- @Override
@Inject
- public void injectComponents(RPCManager rpcManager, BuddyManager buddyManager, ReplicationQueue replicationQueue,
- Configuration config, TransactionTable txTable, CommandsFactory commandsFactory)
+ public void injectDependencies(Configuration config, CommandsFactory commandsFactory)
{
- super.injectComponents(rpcManager, buddyManager, replicationQueue, config, txTable, commandsFactory);
optimistic = config.isNodeLockingOptimistic();
if (optimistic) txMods = new ConcurrentHashMap<GlobalTransaction, List<ReversibleCommand>>();
this.commandsFactory = commandsFactory;
}
- @Inject
- private void injectDependencies(TransactionTable txTable)
- {
- this.txTable = txTable;
- }
-
private boolean skipInvalidation(InvocationContext ctx)
{
Option optionOverride = ctx.getOptionOverrides();
@@ -230,7 +216,7 @@
if (!fqns.isEmpty())
{
// could be potentially TRANSACTIONAL. Ignore if it is, until we see a prepare().
- if (tx == null || !GlobalTransactionContainer.isValid(tx))
+ if (tx == null || !TransactionTable.isValid(tx))
{
// the no-tx case:
//replicate an evict call.
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -21,7 +21,7 @@
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.GlobalTransactionContainer;
+import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
@@ -33,13 +33,11 @@
*/
public class InvocationContextInterceptor extends BaseTransactionalContextInterceptor implements InvocationContextInterceptorMBean
{
- private GlobalTransactionContainer txHelper;
private RPCManager rpcManager;
@Inject
- public void setDependencies(GlobalTransactionContainer cth, RPCManager rpcManager)
+ public void setDependencies(RPCManager rpcManager)
{
- this.txHelper = cth;
this.rpcManager = rpcManager;
}
@@ -174,7 +172,7 @@
}
else
{
- if (ctx.getTransaction() != null && (GlobalTransactionContainer.isValid(ctx.getTransaction())))
+ if (ctx.getTransaction() != null && (TransactionTable.isValid(ctx.getTransaction())))
{
copyInvocationScopeOptionsToTxScope(ctx);
}
@@ -188,7 +186,7 @@
private GlobalTransaction getGlobalTransaction(Transaction tx, GlobalTransaction gtx)
{
- if (gtx == null) gtx = txHelper.getCurrentTransaction(tx, false);
+ if (gtx == null) gtx = txTable.getCurrentTransaction(tx, false);
if (gtx != null) gtx.setRemote(isRemoteGlobalTx(gtx));
return gtx;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -22,7 +22,6 @@
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionEntry;
-import org.jboss.cache.transaction.TransactionTable;
/**
* Locks nodes during transaction boundaries. Only affects prepare/commit/rollback method calls; other method calls
@@ -34,13 +33,11 @@
public class OptimisticLockingInterceptor extends OptimisticInterceptor
{
private long lockAcquisitionTimeout;
- private TransactionTable txTable;
private Configuration configuration;
@Inject
- public void initialize(TransactionTable transactionTable, Configuration configuration)
+ public void initialize(Configuration configuration)
{
- this.txTable = transactionTable;
this.configuration = configuration;
lockAcquisitionTimeout = configuration.getLockAcquisitionTimeout();
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -36,7 +36,6 @@
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.OptimisticTransactionEntry;
-import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
import java.util.ArrayList;
@@ -63,15 +62,12 @@
private CommandsFactory commandsFactory;
- private TransactionTable transactionTable;
-
private Configuration configuration;
@Inject
- public void initialize(CommandsFactory commandsFactory, TransactionTable transactionTable, Configuration configuration)
+ public void initialize(CommandsFactory commandsFactory, Configuration configuration)
{
this.commandsFactory = commandsFactory;
- this.transactionTable = transactionTable;
this.configuration = configuration;
}
@@ -177,7 +173,7 @@
return invokeNextInterceptor(ctx, command);
}
GlobalTransaction gtx = getGlobalTransaction(ctx);
- if (command.isPutForExternalRead()) transactionTable.get(gtx).setForceAsyncReplication(true);
+ if (command.isPutForExternalRead()) txTable.get(gtx).setForceAsyncReplication(true);
return invokeNextInterceptor(ctx, command);
}
@@ -397,7 +393,7 @@
protected TransactionWorkspace getTransactionWorkspace(GlobalTransaction gtx) throws CacheException
{
- OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry) transactionTable.get(gtx);
+ OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry) txTable.get(gtx);
if (transactionEntry == null)
{
throw new CacheException("unable to map global transaction " + gtx + " to transaction entry");
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -13,9 +13,7 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionTable;
/**
* Takes care of replicating modifications to other nodes in a cluster. Also
@@ -27,14 +25,7 @@
*/
public class ReplicationInterceptor extends BaseRpcInterceptor
{
- private TransactionTable transactionTable;
- @Inject
- public void setDependencies(TransactionTable txTable)
- {
- this.transactionTable = txTable;
- }
-
protected boolean skipReplication(InvocationContext ctx)
{
Option optionOverride = ctx.getOptionOverrides();
@@ -81,7 +72,7 @@
Object returnValue = invokeNextInterceptor(ctx, command);
if (command.isPutForExternalRead())
{
- transactionTable.get(command.getGlobalTransaction()).setForceAsyncReplication(true);
+ txTable.get(command.getGlobalTransaction()).setForceAsyncReplication(true);
}
return returnValue;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -34,9 +34,9 @@
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.GlobalTransactionContainer;
import org.jboss.cache.transaction.OptimisticTransactionEntry;
import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.InvalidTransactionException;
import javax.transaction.Status;
@@ -66,7 +66,6 @@
private Configuration configuration;
private CommandsFactory commandsFactory;
private RPCManager rpcManager;
- private GlobalTransactionContainer transactionHelper;
private Notifier notifier;
private InvocationContextContainer invocationContextContainer;
private LifecycleManager lifecycleManager;
@@ -85,13 +84,12 @@
@Inject
public void intialize(Configuration configuration, RPCManager rpcManager,
- GlobalTransactionContainer transactionHelper, Notifier notifier, InvocationContextContainer icc,
+ Notifier notifier, InvocationContextContainer icc,
LifecycleManager lifecycleManager, CommandsFactory factory)
{
this.configuration = configuration;
this.commandsFactory = factory;
this.rpcManager = rpcManager;
- this.transactionHelper = transactionHelper;
this.notifier = notifier;
this.invocationContextContainer = icc;
this.lifecycleManager = lifecycleManager;
@@ -533,7 +531,7 @@
replayVisitorWithInject.visitCollection(ctx, command.getModifications());
retval = invokeNextInterceptor(ctx, command);
// JBCACHE-361 Confirm that the transaction is ACTIVE
- if (!GlobalTransactionContainer.isActive(ltx))
+ if (!TransactionTable.isActive(ltx))
{
throw new ReplicationException("prepare() failed -- local transaction status is not STATUS_ACTIVE;" +
" is " + ltx.getStatus());
@@ -710,7 +708,7 @@
private void assertTxIsActive(InvocationContext ctx)
throws SystemException
{
- if (!GlobalTransactionContainer.isActive(ctx.getTransaction()))
+ if (!TransactionTable.isActive(ctx.getTransaction()))
{
throw new ReplicationException("prepare() failed -- " + "local transaction status is not STATUS_ACTIVE; is " + ctx.getTransaction().getStatus());
}
@@ -980,9 +978,9 @@
private GlobalTransaction registerTransaction(Transaction tx, InvocationContext ctx) throws Exception
{
GlobalTransaction gtx;
- if (GlobalTransactionContainer.isValid(tx) && transactions.put(tx, NULL) == null)
+ if (TransactionTable.isValid(tx) && transactions.put(tx, NULL) == null)
{
- gtx = transactionHelper.getCurrentTransaction(tx, true);
+ gtx = txTable.getCurrentTransaction(tx, true);
if (gtx.isRemote())
{
// should be no need to register a handler since this a remotely initiated globalTransaction
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -25,7 +25,6 @@
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.GlobalTransactionContainer;
import org.jboss.cache.transaction.TransactionTable;
import org.jgroups.Address;
@@ -58,14 +57,13 @@
private RegionManager regionManager;
private Marshaller marshaller;
private DataContainer dataContainer;
- private CommandsFactory commandsFactory;// tu be built here and imjected within any CacheCommand instance. Also pass this to the interceptor chain
- private GlobalTransactionContainer transactionHelper;
+ private CommandsFactory commandsFactory;
@Inject
public void initialize(StateTransferManager stateTransferManager, CacheLoaderManager cacheLoaderManager, Notifier notifier,
TransactionManager transactionManager, BuddyManager buddyManager, TransactionTable transactionTable,
RPCManager rpcManager, RegionManager regionManager, Marshaller marshaller,
- GlobalTransactionContainer transactionHelper, CommandsFactory commandsFactory, DataContainer dataContainer)
+ CommandsFactory commandsFactory, DataContainer dataContainer)
{
this.stateTransferManager = stateTransferManager;
this.cacheLoaderManager = cacheLoaderManager;
@@ -78,7 +76,6 @@
this.marshaller = marshaller;
this.dataContainer = dataContainer;
this.commandsFactory = commandsFactory;
- this.transactionHelper = transactionHelper;
}
private void reset()
@@ -187,12 +184,12 @@
public GlobalTransaction getCurrentTransaction(Transaction tx, boolean createIfNotExists)
{
- return transactionHelper.getCurrentTransaction(tx, createIfNotExists);
+ return transactionTable.getCurrentTransaction(tx, createIfNotExists);
}
public GlobalTransaction getCurrentTransaction()
{
- return transactionHelper.getCurrentTransaction();
+ return transactionTable.getCurrentTransaction();
}
public Set<Fqn> getInternalFqns()
@@ -389,7 +386,7 @@
{
InvocationContext ctx = invocationContextContainer.get();
cacheStatusCheck(ctx);
- GlobalTransaction tx = transactionHelper.getCurrentTransaction();
+ GlobalTransaction tx = transactionTable.getCurrentTransaction();
RemoveNodeCommand command = commandsFactory.buildRemoveNodeCommand(tx, fqn, false, false, true);
Object retval = invoker.invoke(ctx, command);
return retval != null && (Boolean) retval;
@@ -418,7 +415,7 @@
{
InvocationContext ctx = invocationContextContainer.get();
cacheStatusCheck(ctx);
- GlobalTransaction tx = transactionHelper.getCurrentTransaction();
+ GlobalTransaction tx = transactionTable.getCurrentTransaction();
RemoveKeyCommand command = commandsFactory.buildRemoveKeyCommand(tx, fqn, key, true);
return (V) invoker.invoke(ctx, command);
}
@@ -464,7 +461,7 @@
{
InvocationContext ctx = invocationContextContainer.get();
cacheStatusCheck(ctx);
- GlobalTransaction tx = transactionHelper.getCurrentTransaction();
+ GlobalTransaction tx = transactionTable.getCurrentTransaction();
PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(tx, fqn, key, value, false, false);
return (V) invoker.invoke(ctx, command);
}
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -11,7 +11,6 @@
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.GlobalTransactionContainer;
import org.jboss.cache.transaction.TransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
@@ -84,7 +83,7 @@
*
* @param createIfNotExists if true, then missing nodes will be cretaed on the fly. If false, method returns if we
* reach a node that does not exists
- * @param reverseRemoveCheck see {@link #manageReverseRemove(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.NodeSPI, boolean)}
+ * @param reverseRemoveCheck see {@link #manageReverseRemove(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.NodeSPI, boolean, java.util.List)}
* @param createdNodes a list to which any nodes created can register their Fqns so that calling code is aware of which nodes have been newly created.
* @param skipNotification
*/
@@ -96,10 +95,8 @@
GlobalTransaction gtx = ctx.getGlobalTransaction();
boolean created = false;
// if the tx associated with the current thread is rolling back, barf! JBCACHE-923
- if (gtx != null)
- {
- GlobalTransactionContainer.assertTransactionValid(ctx);
- }
+ if (gtx != null) TransactionTable.assertTransactionValid(ctx);
+
Object owner = (gtx != null) ? gtx : currentThread;
NodeSPI currentNode;
if (log.isTraceEnabled()) log.trace("Attempting to lock node " + fqn + " for owner " + owner);
@@ -258,14 +255,15 @@
if (gtx != null) //if no tx then reverse remove does not make sense
{
Fqn fqn = childNode.getFqn();
- boolean needToReverseRemove = reverseRemoveCheck && childNode.isDeleted() && txTable.isNodeRemovedInTx(gtx, fqn);
+ TransactionEntry entry = txTable.get(gtx);
+ boolean needToReverseRemove = reverseRemoveCheck && childNode.isDeleted() && isNodeRemovedInCurrentTransaction(entry, fqn);
if (!needToReverseRemove) return;
childNode.markAsDeleted(false);
//if we'll rollback the tx data should be added to the node again
Map oldData = new HashMap(childNode.getDataDirect());
PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(gtx, fqn, oldData, false, false);
// txTable.get(gtx).addUndoOperation(command); --- now need to make sure this is added to the normal mods list instead
- txTable.get(gtx).addModification(command);
+ entry.addModification(command);
//we're prepared for rollback, now reset the node
childNode.clearDataDirect();
if (createdNodes != null)
@@ -275,6 +273,11 @@
}
}
+ private boolean isNodeRemovedInCurrentTransaction(TransactionEntry entry, Fqn fqn)
+ {
+ return entry != null && entry.getRemovedNodes().contains(fqn);
+ }
+
public void acquireLocksOnChildren(NodeSPI parentNode, NodeLock.LockType lockType, InvocationContext ctx) throws InterruptedException
{
acquireLocksOnChildren(parentNode, lockType, ctx, null, false);
Deleted: core/trunk/src/main/java/org/jboss/cache/transaction/GlobalTransactionContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/GlobalTransactionContainer.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/GlobalTransactionContainer.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -1,236 +0,0 @@
-package org.jboss.cache.transaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.RPCManager;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jgroups.Address;
-
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-/**
- * A container class that holds, retrieves or creates {@link GlobalTransaction} objects and associates them with {@link Transaction} objects.
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 2.2
- */
-public class GlobalTransactionContainer
-{
- // TODO: 2.2.0: Can this be combined with TransactionTable?
- private static final Log log = LogFactory.getLog(GlobalTransactionContainer.class);
-
- /**
- * Maintains mapping of transactions (keys) and Modifications/Undo-Operations
- */
- private TransactionTable transactionTable;
-
- /**
- * Used to get the Transaction associated with the current thread
- */
- private TransactionManager transactionManager = null;
-
- private RPCManager rpcManager;
-
- private boolean isOptimisticLocking;
-
- @Inject
- public void initialize(TransactionTable transactionTable, TransactionManager transactionManager,
- RPCManager rpcManager, Configuration configuration)
- {
- this.transactionTable = transactionTable;
- this.transactionManager = transactionManager;
- this.rpcManager = rpcManager;
- isOptimisticLocking = configuration.isNodeLockingOptimistic();
- }
-
- /**
- * Returns the transaction associated with the current thread.
- * If a local transaction exists, but doesn't yet have a mapping to a
- * GlobalTransaction, a new GlobalTransaction will be created and mapped to
- * the local transaction. Note that if a local transaction exists, but is
- * not ACTIVE or PREPARING, null is returned.
- *
- * @return A GlobalTransaction, or null if no (local) transaction was associated with the current thread
- */
- public GlobalTransaction getCurrentTransaction()
- {
- return getCurrentTransaction(true);
- }
-
-
- /**
- * Returns the transaction associated with the thread; optionally creating
- * it if is does not exist.
- */
- public GlobalTransaction getCurrentTransaction(boolean createIfNotExists)
- {
- Transaction tx;
-
- if ((tx = getLocalTransaction()) == null)
- {// no transaction is associated with the current thread
- return null;
- }
-
- if (!isValid(tx))
- {// we got a non-null transaction, but it is not active anymore
- int status = -1;
- try
- {
- status = tx.getStatus();
- }
- catch (SystemException e)
- {
- }
-
- // JBCACHE-982 -- don't complain if COMMITTED
- if (status != Status.STATUS_COMMITTED)
- {
- log.warn("status is " + status + " (not ACTIVE or PREPARING); returning null)");
- }
- else
- {
- log.trace("status is COMMITTED; returning null");
- }
-
- return null;
- }
-
- return getCurrentTransaction(tx, createIfNotExists);
- }
-
- /**
- * Returns the transaction associated with the current thread. We get the
- * initial context and a reference to the TransactionManager to get the
- * transaction. This method is used by {@link #getCurrentTransaction()}
- */
- protected Transaction getLocalTransaction()
- {
- if (transactionManager == null)
- {
- return null;
- }
- try
- {
- return transactionManager.getTransaction();
- }
- catch (Throwable t)
- {
- return null;
- }
- }
-
- /**
- * Returns true if transaction is ACTIVE, false otherwise
- */
- public static boolean isActive(Transaction tx)
- {
- if (tx == null) return false;
- int status = -1;
- try
- {
- status = tx.getStatus();
- return status == Status.STATUS_ACTIVE;
- }
- catch (SystemException e)
- {
- return false;
- }
- }
-
- /**
- * Returns true if transaction is PREPARING, false otherwise
- */
- public static boolean isPreparing(Transaction tx)
- {
- if (tx == null) return false;
- int status = -1;
- try
- {
- status = tx.getStatus();
- return status == Status.STATUS_PREPARING;
- }
- catch (SystemException e)
- {
- return false;
- }
- }
-
- /**
- * Return s true of tx's status is ACTIVE or PREPARING
- *
- * @param tx
- * @return true if the tx is active or preparing
- */
- public static boolean isValid(Transaction tx)
- {
- return isActive(tx) || isPreparing(tx);
- }
-
- /**
- * Tests whether the caller is in a valid transaction. If not, will throw a CacheException.
- */
- public static void assertTransactionValid(InvocationContext ctx)
- {
- Transaction tx = ctx.getTransaction();
- if (!isValid(tx)) try
- {
- throw new CacheException("Invalid transaction " + tx + ", status = " + (tx == null ? null : tx.getStatus()));
- }
- catch (SystemException e)
- {
- throw new CacheException("Exception trying to analyse status of transaction " + tx, e);
- }
- }
-
-
- /**
- * Returns the global transaction for this local transaction.
- */
- public GlobalTransaction getCurrentTransaction(Transaction tx)
- {
- return getCurrentTransaction(tx, true);
- }
-
- /**
- * Returns the global transaction for this local transaction.
- *
- * @param createIfNotExists if true, if a global transaction is not found; one is created
- */
- public GlobalTransaction getCurrentTransaction(Transaction tx, boolean createIfNotExists)
- {
- // removed synchronization on txTable because underlying implementation is thread safe
- // and JTA spec (section 3.4.3 Thread of Control, par 2) says that only one thread may
- // operate on the transaction at one time so no concern about 2 threads trying to call
- // this method for the same Transaction instance at the same time
- //
- GlobalTransaction gtx = transactionTable.get(tx);
- if (gtx == null && createIfNotExists)
- {
- Address addr = rpcManager.getLocalAddress();
- gtx = GlobalTransaction.create(addr);
- transactionTable.put(tx, gtx);
- TransactionEntry ent = null;
- try
- {
- ent = isOptimisticLocking ? new OptimisticTransactionEntry(tx) : new TransactionEntry(tx);
- }
- catch (Exception e)
- {
- throw new CacheException("Unable to create a transaction entry!", e);
- }
-
- transactionTable.put(gtx, ent);
- if (log.isTraceEnabled())
- {
- log.trace("created new GTX: " + gtx + ", local TX=" + tx);
- }
- }
- return gtx;
- }
-}
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-04-28 18:31:24 UTC (rev 5735)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-04-28 18:56:13 UTC (rev 5736)
@@ -9,11 +9,18 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.RPCManager;
import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.lock.NodeLock;
+import org.jgroups.Address;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -28,6 +35,7 @@
public class TransactionTable
{
private static final Log log = LogFactory.getLog(TransactionTable.class);
+ private static boolean trace;
/**
* Mapping between local (javax.transaction.Transaction)
@@ -41,6 +49,21 @@
*/
protected final Map<GlobalTransaction, TransactionEntry> gtx2EntryMap = new ConcurrentHashMap<GlobalTransaction, TransactionEntry>();
+ private TransactionManager transactionManager = null;
+
+ private RPCManager rpcManager;
+
+ private boolean isOptimisticLocking;
+
+ @Inject
+ public void initialize(TransactionManager transactionManager, RPCManager rpcManager, Configuration configuration)
+ {
+ this.transactionManager = transactionManager;
+ this.rpcManager = rpcManager;
+ isOptimisticLocking = configuration.isNodeLockingOptimistic();
+ trace = log.isTraceEnabled();
+ }
+
/**
* Returns the number of local transactions.
*/
@@ -234,7 +257,7 @@
public void cleanup(GlobalTransaction gtx)
{
- if (log.isTraceEnabled()) log.trace("Cleaning up locks for globalTransaction " + gtx);
+ if (trace) log.trace("Cleaning up locks for globalTransaction " + gtx);
TransactionEntry entry = this.get(gtx);
// Let's do it in stack style, LIFO
if (entry != null)
@@ -297,9 +320,188 @@
}
}
- public boolean isNodeRemovedInTx(GlobalTransaction gtx, Fqn fqn)
+ /**
+ * Returns the transaction associated with the current thread.
+ * If a local transaction exists, but doesn't yet have a mapping to a
+ * GlobalTransaction, a new GlobalTransaction will be created and mapped to
+ * the local transaction. Note that if a local transaction exists, but is
+ * not ACTIVE or PREPARING, null is returned.
+ *
+ * @return A GlobalTransaction, or null if no (local) transaction was associated with the current thread
+ */
+ public GlobalTransaction getCurrentTransaction()
{
- TransactionEntry te = get(gtx);
- return te != null && te.getRemovedNodes().contains(fqn);
+ return getCurrentTransaction(true);
}
+
+
+ /**
+ * Returns the transaction associated with the thread; optionally creating
+ * it if is does not exist.
+ */
+ public GlobalTransaction getCurrentTransaction(boolean createIfNotExists)
+ {
+ Transaction tx;
+
+ if ((tx = getLocalTransaction()) == null)
+ {// no transaction is associated with the current thread
+ return null;
+ }
+
+ if (!isValid(tx))
+ {// we got a non-null transaction, but it is not active anymore
+ int status = -1;
+ try
+ {
+ status = tx.getStatus();
+ }
+ catch (SystemException e)
+ {
+ }
+
+ // JBCACHE-982 -- don't complain if COMMITTED
+ if (status != Status.STATUS_COMMITTED)
+ {
+ log.warn("status is " + status + " (not ACTIVE or PREPARING); returning null)");
+ }
+ else
+ {
+ log.trace("status is COMMITTED; returning null");
+ }
+
+ return null;
+ }
+
+ return getCurrentTransaction(tx, createIfNotExists);
+ }
+
+ /**
+ * Returns the transaction associated with the current thread. We get the
+ * initial context and a reference to the TransactionManager to get the
+ * transaction. This method is used by {@link #getCurrentTransaction()}
+ */
+ protected Transaction getLocalTransaction()
+ {
+ if (transactionManager == null)
+ {
+ return null;
+ }
+ try
+ {
+ return transactionManager.getTransaction();
+ }
+ catch (Throwable t)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns true if transaction is ACTIVE, false otherwise
+ */
+ public static boolean isActive(Transaction tx)
+ {
+ if (tx == null) return false;
+ int status = -1;
+ try
+ {
+ status = tx.getStatus();
+ return status == Status.STATUS_ACTIVE;
+ }
+ catch (SystemException e)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Returns true if transaction is PREPARING, false otherwise
+ */
+ public static boolean isPreparing(Transaction tx)
+ {
+ if (tx == null) return false;
+ int status = -1;
+ try
+ {
+ status = tx.getStatus();
+ return status == Status.STATUS_PREPARING;
+ }
+ catch (SystemException e)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Return s true of tx's status is ACTIVE or PREPARING
+ *
+ * @param tx
+ * @return true if the tx is active or preparing
+ */
+ public static boolean isValid(Transaction tx)
+ {
+ return isActive(tx) || isPreparing(tx);
+ }
+
+ /**
+ * Tests whether the caller is in a valid transaction. If not, will throw a CacheException.
+ */
+ public static void assertTransactionValid(InvocationContext ctx)
+ {
+ Transaction tx = ctx.getTransaction();
+ if (!isValid(tx)) try
+ {
+ throw new CacheException("Invalid transaction " + tx + ", status = " + (tx == null ? null : tx.getStatus()));
+ }
+ catch (SystemException e)
+ {
+ throw new CacheException("Exception trying to analyse status of transaction " + tx, e);
+ }
+ }
+
+
+ /**
+ * Returns the global transaction for this local transaction.
+ */
+ public GlobalTransaction getCurrentTransaction(Transaction tx)
+ {
+ return getCurrentTransaction(tx, true);
+ }
+
+ /**
+ * Returns the global transaction for this local transaction.
+ *
+ * @param createIfNotExists if true, if a global transaction is not found; one is created
+ */
+ public GlobalTransaction getCurrentTransaction(Transaction tx, boolean createIfNotExists)
+ {
+ // removed synchronization on txTable because underlying implementation is thread safe
+ // and JTA spec (section 3.4.3 Thread of Control, par 2) says that only one thread may
+ // operate on the transaction at one time so no concern about 2 threads trying to call
+ // this method for the same Transaction instance at the same time
+ //
+ GlobalTransaction gtx = get(tx);
+ if (gtx == null && createIfNotExists)
+ {
+ Address addr = rpcManager.getLocalAddress();
+ gtx = GlobalTransaction.create(addr);
+ put(tx, gtx);
+ TransactionEntry ent;
+ try
+ {
+ ent = isOptimisticLocking ? new OptimisticTransactionEntry(tx) : new TransactionEntry(tx);
+ }
+ catch (Exception e)
+ {
+ throw new CacheException("Unable to create a transaction entry!", e);
+ }
+
+ put(gtx, ent);
+ if (trace)
+ {
+ log.trace("created new GTX: " + gtx + ", local TX=" + tx);
+ }
+ }
+ return gtx;
+ }
}
16 years, 8 months
JBoss Cache SVN: r5735 - in core/trunk/src/main/java/org/jboss/cache: invocation and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-28 14:31:24 -0400 (Mon, 28 Apr 2008)
New Revision: 5735
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainer.java
core/trunk/src/main/java/org/jboss/cache/LifecycleManager.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
core/trunk/src/main/java/org/jboss/cache/transaction/GlobalTransactionContainer.java
Log:
Javadoc and method naming
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainer.java 2008-04-28 17:27:58 UTC (rev 5734)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainer.java 2008-04-28 18:31:24 UTC (rev 5735)
@@ -6,6 +6,7 @@
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -18,15 +19,16 @@
import java.util.Set;
/**
- * A container for the root node in the cache - should be used to access any nodes, walk trees, etc.
+ * A container for the root node in the cache, which also provides helpers for efficiently accessing nodes, walking trees, etc.
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
public class DataContainer
{
-
+ // TODO: 2.2.0: Refactor and standardise method names, consolidate where possible. A lot of these can be moved into commands.
private static final Log log = LogFactory.getLog(DataContainer.class);
+ private static boolean trace;
private Configuration configuration;
@@ -35,18 +37,30 @@
*/
private NodeSPI root;
+
@Inject
public void injectDependencies(Configuration configuration)
{
this.configuration = configuration;
}
+ @Start
+ public void start()
+ {
+ trace = log.isTraceEnabled();
+ }
+
/**
* Set<Fqn> of Fqns of the topmost node of internal regions that should
* not included in standard state transfers.
*/
private final Set<Fqn> internalFqns = new HashSet<Fqn>();
+ /**
+ * Adds the specified Fqn to the list of Fqns to be considered "internal".
+ *
+ * @param fqn fqn to add to list
+ */
public void registerInternalFqn(Fqn fqn)
{
internalFqns.add(fqn);
@@ -90,21 +104,37 @@
return findNode(fqn, version, false);
}
+ /**
+ * Similar to {@link #findNode(Fqn, org.jboss.cache.optimistic.DataVersion)} except that it throws a {@link org.jboss.cache.NodeNotExistsException}
+ * if the node cannot be found.
+ *
+ * @param tx global transaction
+ * @param fqn fqn to fine
+ * @param includeInvalid if true, invalid nodes are considered as well.
+ * @return the node
+ */
public NodeSPI findNodeCheck(GlobalTransaction tx, Fqn fqn, boolean includeInvalid)
{
NodeSPI n = findNode(fqn, null, includeInvalid);
if (n == null)
{
- String errStr = "node " + fqn + " not found (globalTransaction=" + tx + ", caller=" + Thread.currentThread() + ")";
- if (log.isTraceEnabled())
- {
- log.trace(errStr);
- }
+ StringBuilder builder = new StringBuilder();
+ builder.append("Node ").append(fqn).append(" not found (gtx=").append(tx).append(")");
+ String errStr = builder.toString();
+ if (trace) log.trace(errStr);
throw new NodeNotExistsException(errStr);
}
return n;
}
+ /**
+ * Searches for a specific node.
+ *
+ * @param fqn Fqn to find
+ * @param version version of the node to find
+ * @param includeInvalidNodes if true, invalid nodes are considered
+ * @return the node, if found, or null otherwise.
+ */
public NodeSPI findNode(Fqn fqn, DataVersion version, boolean includeInvalidNodes)
{
if (fqn == null) return null;
@@ -115,7 +145,7 @@
{
// we need to check the version of the data node...
DataVersion nodeVersion = toReturn.getVersion();
- if (log.isTraceEnabled())
+ if (trace)
{
log.trace("looking for optimistic node [" + fqn + "] with version [" + version + "]. My version is [" + nodeVersion + "]");
}
@@ -128,7 +158,14 @@
return toReturn;
}
-
+ /**
+ * Peeks for a specified node.
+ *
+ * @param fqn Fqn of the node to find
+ * @param includeDeletedNodes if true, deleted nodes are also considered
+ * @param includeInvalidNodes if true, invalid nodes are also considered
+ * @return the node, if found, or null otherwise.
+ */
public NodeSPI peek(Fqn<?> fqn, boolean includeDeletedNodes, boolean includeInvalidNodes)
{
if (fqn == null || fqn.size() == 0) return getRoot();
@@ -154,7 +191,13 @@
return n;
}
-
+ /**
+ * Prepares a list of {@link NodeData} objects for a specified node and all its children.
+ *
+ * @param list List of NodeData objects, which will be added to.
+ * @param node node to recursively add to the list
+ * @return the same list passed in
+ */
public List<NodeData> getNodeData(List<NodeData> list, NodeSPI node)
{
NodeData data = new NodeData(BuddyFqnTransformer.getActualFqn(node.getFqn()), node.getDataDirect());
@@ -166,14 +209,23 @@
return list;
}
-
+ /**
+ * Same as calling <tt>peek(fqn, includeDeletedNodes, false)</tt>.
+ *
+ * @param fqn Fqn to find
+ * @param includeDeletedNodes if true, deleted nodes are considered
+ * @return the node, if found, or null otherwise.
+ */
public NodeSPI peek(Fqn<?> fqn, boolean includeDeletedNodes)
{
return peek(fqn, includeDeletedNodes, false);
}
/**
- * Returns true if the FQN exists and the node has children.
+ * Returns true if the Fqn exists and the node has children.
+ *
+ * @param fqn the fqn to test
+ * @return true if the Fqn exists and the node has children.
*/
public boolean hasChild(Fqn fqn)
{
@@ -183,16 +235,26 @@
return n != null && n.hasChildrenDirect();
}
-
+ /**
+ * @return the root node
+ */
public NodeSPI getRoot()
{
return root;
}
- public List<Fqn> getNodesForEviction(Fqn parent, boolean recursive)
+ /**
+ * Generates a list of nodes for eviction. This filters out nodes that cannot be evicted, such as those which are
+ * marked as resident. See {@link NodeSPI#setResident(boolean)}.
+ *
+ * @param fqn the node to consider for eviction
+ * @param recursive if recursive, child nodes are also considered
+ * @return a list of Fqns that can be considered for eviction
+ */
+ public List<Fqn> getNodesForEviction(Fqn fqn, boolean recursive)
{
List<Fqn> result = new ArrayList<Fqn>();
- NodeSPI node = peek(parent, false);
+ NodeSPI node = peek(fqn, false);
if (recursive)
{
recursiveAddEvictionNodes(node, result);
@@ -201,7 +263,7 @@
{
if (node == null)
{
- result.add(parent);
+ result.add(fqn);
return result;
}
buildNodesForEviction(node, result);
@@ -244,6 +306,12 @@
return toString(false);
}
+ /**
+ * Tests if an Fqn exists and is valid and not deleted.
+ *
+ * @param fqn the fqn representing the node to test
+ * @return true if the node exists, false otherwise.
+ */
public boolean exists(Fqn fqn)
{
return peek(fqn, false, false) != null;
@@ -401,10 +469,11 @@
}
/**
- * Internal method; not to be used externally.
- * Returns true if the node was found, false if not.
+ * Removes the actual node from the tree data structure.
*
- * @param f
+ * @param f the Fqn of the node to remove
+ * @param skipMarkerCheck if true, skips checking the boolean {@link org.jboss.cache.NodeSPI#isDeleted()} flag and deletes the node anyway.
+ * @return Returns true if the node was found and removed, false if not.
*/
public boolean realRemove(Fqn f, boolean skipMarkerCheck)
{
@@ -415,7 +484,7 @@
}
- if (log.isTraceEnabled()) log.trace("Performing a real remove for node " + f + ", marked for removal.");
+ if (trace) log.trace("Performing a real remove for node " + f + ", marked for removal.");
if (skipMarkerCheck || n.isDeleted())
{
if (n.getFqn().isRoot())
@@ -457,21 +526,21 @@
/**
* @return true if the FQN is leaf and was removed; false if is an intermediate FQN and only contained data
- * is droped.
+ * is droped.
*/
public boolean evict(Fqn fqn)
{
if (peek(fqn, false, true) == null) return true;
if (hasChild(fqn))
{
- if (log.isTraceEnabled())
+ if (trace)
log.trace("removing DATA as node has children: evict(" + fqn + ")");
removeData(fqn);
return false;
}
else
{
- if (log.isTraceEnabled())
+ if (trace)
log.trace("removing NODE as it is a leaf: evict(" + fqn + ")");
removeNode(fqn);
return true;
@@ -555,7 +624,7 @@
NodeSPI childNode = n.addChildDirect(Fqn.fromElements(childName));
if (childNode == null)
{
- if (log.isTraceEnabled())
+ if (trace)
{
log.trace("failed to find or create child " + childName + " of node " + n.getFqn());
}
Modified: core/trunk/src/main/java/org/jboss/cache/LifecycleManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/LifecycleManager.java 2008-04-28 17:27:58 UTC (rev 5734)
+++ core/trunk/src/main/java/org/jboss/cache/LifecycleManager.java 2008-04-28 18:31:24 UTC (rev 5735)
@@ -18,6 +18,15 @@
import java.util.ArrayList;
/**
+ * Added in 2.2.0 to handle the lifecycle of the cache. I.e., to control the starting and stopping process, as defined
+ * by the {@link org.jboss.cache.Cache#start()} and {@link org.jboss.cache.Cache#stop()} API methods.
+ * <p/>
+ * This class also acts as a container for the {@link ComponentRegistry}, which it constructs in its constructor
+ * as a place to hold all components of a given cache instance.
+ * <p/>
+ * It also holds the status of the cache, which can be queried.
+ * <p/>
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
@@ -63,6 +72,12 @@
*/
private boolean invokedFromShutdownHook;
+ /**
+ * Constructs a new instance, also constructs a {@link org.jboss.cache.factories.ComponentRegistry} instance which can
+ * then be retrieved using {@link #getComponentRegistry()}. When constructed, the cache status is set to {@link org.jboss.cache.CacheStatus#INSTANTIATED}.
+ *
+ * @param configuration with which to create this class.
+ */
public LifecycleManager(Configuration configuration)
{
this.configuration = configuration;
@@ -71,9 +86,10 @@
}
/**
- * Lifecycle method. This is like initialize.
+ * Creates the components needed by a cache instance and sets the cache status to {@link org.jboss.cache.CacheStatus#CREATED}
+ * when it is done.
*
- * @throws Exception
+ * @throws CacheException if there is a problem with construction.
*/
public void create() throws CacheException
{
@@ -95,9 +111,14 @@
}
/**
- * Lifecyle method.
+ * Starts the components needed by a cache instance, and then starts the cache instance itself. Sets the cache status to
+ * {@link org.jboss.cache.CacheStatus#STARTED} once it is done.
+ * <p/>
+ * If the cache status is not {@link org.jboss.cache.CacheStatus#CREATED} when this is called, it will first call {@link #create()}
+ * to create the cache.
+ * <p/>
*
- * @throws CacheException
+ * @throws CacheException if there is a problem with starting the cache.
*/
public void start() throws CacheException
{
@@ -124,7 +145,10 @@
}
/**
- * Lifecycle method.
+ * Destroys the cache and frees up any resources. Sets the cache status to {@link CacheStatus#DESTROYED} when it is done.
+ * <p/>
+ * If the cache is in {@link org.jboss.cache.CacheStatus#STARTED} when this method is called, it will first call {@link #stop()}
+ * to stop the cache.
*/
public void destroy()
{
@@ -158,7 +182,8 @@
}
/**
- * Lifecycle method.
+ * Stops the cache and sets the cache status to {@link org.jboss.cache.CacheStatus#STOPPED} once it is done. If the cache is not in
+ * the {@link org.jboss.cache.CacheStatus#STARTED} state, this is a no-op.
*/
public void stop()
{
@@ -412,7 +437,7 @@
log = LogFactory.getLog(category.toString());
}
- public void startManualComponents()
+ private void startManualComponents()
{
// these 2 components need to be started manually since they can only be started after ALL other components have started.
// i.e., rpcManager's start() method may do state transfers. State transfers will rely on the interceptor chain being started.
@@ -430,19 +455,22 @@
}
/**
- * For local calls, if chache is not in STARTED mode will throw an IllegalStateException.
- * For remote cache, if cache is STRTED returns true. If cache is STARTING waits for the cache to wait
- * for {@link org.jboss.cache.config.Configuration#getStateRetrievalTimeout()} milliseconds, if cache starts
- * returns true, otherwise returns false.
+ * Asserts whether invocations are allowed on the cache or not. Returns <tt>true</tt> if invocations are to be allowed,
+ * <tt>false</tt> otherwise. If the origin of the call is remote and the cache status is {@link org.jboss.cache.CacheStatus#STARTING},
+ * this method will block for up to {@link org.jboss.cache.config.Configuration#getStateRetrievalTimeout()} millis, checking
+ * for a valid state.
+ *
+ * @param originLocal true if the call originates locally (i.e., from the {@link org.jboss.cache.invocation.CacheInvocationDelegate} or false if it originates remotely, i.e., from the {@link org.jboss.cache.marshall.CommandAwareRpcDispatcher}.
+ * @return true if invocations are allowed, false otherwise.
*/
- public boolean allowsInvocation(boolean originLocal)
+ public boolean invocationsAllowed(boolean originLocal)
{
if (getCacheStatus().allowInvocations()) return true;
- // only throw an exception if this is a locally originating call - JBCACHE-1179
- if (originLocal)
- {
- throw new IllegalStateException("Cache not in STARTED state!");
- }
+
+ // if this is a locally originating call and the cache is not in a valid state, return false.
+ if (originLocal) return false;
+
+ // else if this is a remote call and the status is STARTING, wait until the cache starts.
if (getCacheStatus() == CacheStatus.STARTING)
{
try
@@ -487,7 +515,6 @@
throw new IllegalStateException("Cache not in STARTED state, even after waiting " + configuration.getStateRetrievalTimeout() + " millis.");
}
-
public CacheStatus getCacheStatus()
{
return cacheStatus;
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-28 17:27:58 UTC (rev 5734)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-28 18:31:24 UTC (rev 5735)
@@ -585,7 +585,10 @@
assertIsConstructed();
if (!ctx.getOptionOverrides().isSkipCacheStatusCheck())
{
- lifecycleManager.allowsInvocation(true);
+ if (!lifecycleManager.invocationsAllowed(true))
+ {
+ throw new IllegalStateException("Cache not in STARTED state!");
+ }
}
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-04-28 17:27:58 UTC (rev 5734)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-04-28 18:31:24 UTC (rev 5735)
@@ -129,7 +129,7 @@
{
InvocationContext ctx = invocationContextContainer.get();
ctx.setOriginLocal(false);
- if (!lifecycleManager.allowsInvocation(false))
+ if (!lifecycleManager.invocationsAllowed(false))
{
return null;
}
@@ -143,7 +143,7 @@
if (!(cmd instanceof AnnounceBuddyPoolNameCommand ||
cmd instanceof AssignToBuddyGroupCommand ||
cmd instanceof RemoveFromBuddyGroupCommand)
- && !lifecycleManager.allowsInvocation(false))
+ && !lifecycleManager.invocationsAllowed(false))
{
return null;
}
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/GlobalTransactionContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/GlobalTransactionContainer.java 2008-04-28 17:27:58 UTC (rev 5734)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/GlobalTransactionContainer.java 2008-04-28 18:31:24 UTC (rev 5735)
@@ -15,12 +15,14 @@
import javax.transaction.TransactionManager;
/**
+ * A container class that holds, retrieves or creates {@link GlobalTransaction} objects and associates them with {@link Transaction} objects.
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
public class GlobalTransactionContainer
{
-
+ // TODO: 2.2.0: Can this be combined with TransactionTable?
private static final Log log = LogFactory.getLog(GlobalTransactionContainer.class);
/**
16 years, 8 months
JBoss Cache SVN: r5734 - in core/trunk/src/main/java/org/jboss/cache/interceptors: base and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-28 13:27:58 -0400 (Mon, 28 Apr 2008)
New Revision: 5734
Added:
core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
Log:
Javadoc and method naming
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-04-28 16:56:40 UTC (rev 5733)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-04-28 17:27:58 UTC (rev 5734)
@@ -8,6 +8,7 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
@@ -88,7 +89,7 @@
* if this is a shared cache loader and the call is of remote origin, pass up the chain
*/
@Override
- public boolean skipInterception(InvocationContext ctx)
+ public boolean skipInterception(InvocationContext ctx, VisitableCommand command)
{
if (!ctx.isOriginLocal() && loaderConfig.isShared())
{
@@ -102,7 +103,7 @@
}
@Override
- public Object executeCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+ public Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
{
if (inTransaction())
{
@@ -151,7 +152,7 @@
}
@Override
- public Object executeRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+ public Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
{
if (inTransaction())
{
@@ -179,7 +180,7 @@
}
@Override
- public Object executeOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+ public Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
{
if (inTransaction())
{
@@ -190,7 +191,7 @@
}
@Override
- public Object executePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+ public Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
{
if (inTransaction())
{
@@ -205,7 +206,7 @@
* access an element just removed, causing the CacheLoader to *load* the element before *removing* it.
*/
@Override
- public Object executeRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
if (!inTransaction())
{
@@ -215,7 +216,7 @@
}
@Override
- public Object executeRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+ public Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
{
if (!inTransaction())
{
@@ -227,7 +228,7 @@
}
@Override
- public Object executeRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
+ public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
if (!inTransaction())
{
@@ -243,7 +244,7 @@
}
@Override
- public Object executeMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+ public Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
{
Object returnValue = invokeNextInterceptor(ctx, command);
if (inTransaction())
@@ -257,7 +258,7 @@
}
@Override
- public Object executePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+ public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
Object returnValue = invokeNextInterceptor(ctx, command);
if (inTransaction())
@@ -284,7 +285,7 @@
}
@Override
- public Object executePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
Object result;
Object returnValue = invokeNextInterceptor(ctx, command);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-28 16:56:40 UTC (rev 5733)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-28 17:27:58 UTC (rev 5734)
@@ -11,6 +11,7 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.DataCommand;
+import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetKeyValueCommand;
import org.jboss.cache.commands.read.GetKeysCommand;
@@ -27,7 +28,7 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.interceptors.base.PostProcessingChainedInterceptor;
+import org.jboss.cache.interceptors.base.PostProcessingCommandInterceptor;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.lock.NodeLock;
@@ -55,7 +56,7 @@
* @author Bela Ban
* @version $Id$
*/
-public class PessimisticLockInterceptor extends PostProcessingChainedInterceptor
+public class PessimisticLockInterceptor extends PostProcessingCommandInterceptor
{
private TransactionTable txTable;
private DataContainer dataContainer;
@@ -74,13 +75,13 @@
}
@Override
- public Object executePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+ public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
return handlePutCommand(ctx, command, false);
}
@Override
- public Object executePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
return handlePutCommand(ctx, command, command.isPutForExternalRead());
}
@@ -112,7 +113,7 @@
}
@Override
- public Object executePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+ public Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
{
// 2-phase commit prepares are no-ops here.
if (!command.isOnePhaseCommit()) return invokeNextInterceptor(ctx, command);
@@ -125,7 +126,7 @@
}
@Override
- public Object executeCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+ public Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
{
commit(command.getGlobalTransaction());
if (trace) log.trace("bypassed locking as method commit() doesn't require locking");
@@ -135,7 +136,7 @@
}
@Override
- public Object executeRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+ public Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
{
TransactionEntry entry = txTable.get(command.getGlobalTransaction());
if (trace)
@@ -165,7 +166,7 @@
}
@Override
- public Object executeMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+ public Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
{
if (ctx.isLockingSuppressed()) return invokeNextInterceptor(ctx, command);
long timeout = ctx.getContextLockAcquisitionTimeout(lockAcquisitionTimeout);
@@ -198,7 +199,7 @@
}
@Override
- public Object executeRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
if (ctx.isLockingSuppressed()) return invokeNextInterceptor(ctx, command);
// need to make a note of ALL nodes created here!!
@@ -247,56 +248,56 @@
}
@Override
- public Object executeRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+ public Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.WRITE, false, false, false, false, null, false);
return invokeNextInterceptor(ctx, command);
}
@Override
- public Object executeRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
+ public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.WRITE, false, false, false, false, null, false);
return invokeNextInterceptor(ctx, command);
}
@Override
- public Object executeEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+ public Object handleEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.WRITE, false, true, false, false, null, false);
return invokeNextInterceptor(ctx, command);
}
@Override
- public Object executeGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+ public Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.READ, false, false, false, false, null, false);
return invokeNextInterceptor(ctx, command);
}
@Override
- public Object executeGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+ public Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.READ, false, false, false, false, null, false);
return invokeNextInterceptor(ctx, command);
}
@Override
- public Object executeGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+ public Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.READ, false, false, false, false, null, false);
return invokeNextInterceptor(ctx, command);
}
@Override
- public Object executeGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+ public Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.READ, false, false, false, false, null, false);
return invokeNextInterceptor(ctx, command);
}
@Override
- public void doAfterCall(InvocationContext ctx)
+ public void doAfterCall(InvocationContext ctx, VisitableCommand command)
{
ctx.clearInvocationLocksAcquired();
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java 2008-04-28 16:56:40 UTC (rev 5733)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java 2008-04-28 17:27:58 UTC (rev 5734)
@@ -11,7 +11,26 @@
import java.util.Map;
/**
+ * This is the base class for all interceptors to extend, and implements the {@link org.jboss.cache.commands.Visitor} interface
+ * allowing it to intercept invocations on {@link org.jboss.cache.commands.VisitableCommand}s.
+ * <p/>
+ * Commands are created either by the {@link org.jboss.cache.invocation.CacheInvocationDelegate} (for invocations on the {@link org.jboss.cache.Cache}
+ * public interface), the {@link org.jboss.cache.invocation.NodeInvocationDelegate} for invocations on the {@link org.jboss.cache.Node}
+ * public interface, or by the {@link org.jboss.cache.marshall.CommandAwareRpcDispatcher} for remotely originating invocations, and
+ * are passed up the interceptor chain by using the {@link org.jboss.cache.interceptors.InterceptorChain} helper class.
+ * <p/>
+ * When writing interceptors, authors can either override a specific visitXXX() method (such as {@link #visitGetKeyValueCommand(org.jboss.cache.InvocationContext, org.jboss.cache.commands.read.GetKeyValueCommand)})
+ * or the more generic {@link #handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)} which is the default behaviour of
+ * any visit method, as defined in {@link org.jboss.cache.commands.AbstractVisitor#handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}.
+ * <p/>
+ * The preferred approach is to override the specific visitXXX() methods that are of interest rather than to override {@link #handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}
+ * and then write a series of if statements or a switch block, if command-specific behaviour is needed.
+ * <p/>
+ *
* @author Mircea.Markus(a)jboss.com
+ * @see VisitableCommand
+ * @see org.jboss.cache.commands.Visitor
+ * @see org.jboss.cache.interceptors.InterceptorChain
* @since 2.2
*/
public class CommandInterceptor extends AbstractVisitor implements InterceptorMBean
@@ -29,47 +48,94 @@
trace = log.isTraceEnabled();
}
+ /**
+ * @return true if gathering statistics for JMX is enabled on this interceptor.
+ */
public boolean getStatisticsEnabled()
{
return statsEnabled;
}
+ /**
+ * @param enabled whether gathering statistics for JMX are enabled.
+ */
public void setStatisticsEnabled(boolean enabled)
{
statsEnabled = enabled;
}
+ /**
+ * Returns a map of statistics. This is a default implementation which returns an empty map and should be overridden
+ * if it is to be meaningful.
+ *
+ * @return an empty map
+ */
public Map<String, Object> dumpStatistics()
{
return Collections.emptyMap();
}
+ /**
+ * Resets statistics gathered. Is a no-op, and should be overridden if it is to be meaningful.
+ */
public void resetStatistics()
{
}
+ /**
+ * Retrieves the next interceptor in the chain.
+ *
+ * @return the next interceptor in the chain.
+ */
public CommandInterceptor getNext()
{
return next;
}
+ /**
+ * @return true if there is another interceptor in the chain after this; false otherwise.
+ */
public boolean hasNext()
{
return getNext() != null;
}
+ /**
+ * Sets the next interceptor in the chain to the interceptor passed in.
+ *
+ * @param next next interceptor in the chain.
+ */
public void setNext(CommandInterceptor next)
{
this.next = next;
}
+ /**
+ * Invokes the next interceptor in the chain. This is how interceptor implementations should pass a call up the chain
+ * to the next interceptor. In previous (pre-2.2.0) implementations of JBoss Cache, this was done by calling
+ * <pre>super.invoke()</pre>.
+ *
+ * @param ctx invocation context
+ * @param command command to pass up the chain.
+ * @return return value of the invocation
+ * @throws Throwable in the event of problems
+ */
public Object invokeNextInterceptor(InvocationContext ctx, VisitableCommand command) throws Throwable
{
- return command.acceptVisitor(ctx, getNext());
+ return command.acceptVisitor(ctx, next);
}
+ /**
+ * The default behaviour of the visitXXX methods, which is to ignore the call and pass the call up to the next
+ * interceptor in the chain.
+ *
+ * @param ctx invocation context
+ * @param command command to invoke
+ * @return return value
+ * @throws Throwable in the event of problems
+ */
@Override
- public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
+ protected Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
{
return invokeNextInterceptor(ctx, command);
}
Copied: core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java (from rev 5728, core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingChainedInterceptor.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java 2008-04-28 17:27:58 UTC (rev 5734)
@@ -0,0 +1,389 @@
+package org.jboss.cache.interceptors.base;
+
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.read.RemoteExistsCommand;
+import org.jboss.cache.commands.tx.CommitCommand;
+import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
+import org.jboss.cache.commands.tx.PrepareCommand;
+import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.EvictCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveDataCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
+
+/**
+ * This interceptor will call {@link #doAfterCall(org.jboss.cache.InvocationContext,org.jboss.cache.commands.VisitableCommand)} after invoking each visit method
+ * (and the {@link #handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)} method) in
+ * a <tt>finally</tt> block.
+ * <p/>
+ * It is useful if common cleanup code is required at the end of each call.
+ * <p/>
+ * Instead of overriding visitXXX() methods, implementations should override their handleXXX() counterparts defined in this class
+ * instead, as well as the {@link #doAfterCall(org.jboss.cache.InvocationContext,org.jboss.cache.commands.VisitableCommand)} method.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 2.2
+ */
+public abstract class PostProcessingCommandInterceptor extends CommandInterceptor
+{
+ @Override
+ public final Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+ {
+ try
+ {
+ return handlePutDataMapCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ {
+ try
+ {
+ return handlePutKeyValueCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+ {
+ try
+ {
+ return handleRemoveNodeCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
+ {
+ try
+ {
+ return handleRemoveDataCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+ {
+ try
+ {
+ return handleEvictFqnCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+ {
+ try
+ {
+ return handleInvalidateCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+ {
+ try
+ {
+ return handleRemoveKeyCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+ {
+ try
+ {
+ return handleGetDataMapCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitExistsNodeCommand(InvocationContext ctx, RemoteExistsCommand command) throws Throwable
+ {
+ try
+ {
+ return handleExistsNodeCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleExistsNodeCommand(InvocationContext ctx, RemoteExistsCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+ {
+ try
+ {
+ return handleGetKeyValueCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+ {
+ try
+ {
+ return handleGetNodeCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+ {
+ try
+ {
+ return handleGetKeysCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+ {
+ try
+ {
+ return handleGetChildrenNamesCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+ {
+ try
+ {
+ return handleMoveCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+ {
+ try
+ {
+ return handleGravitateDataCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+ {
+ try
+ {
+ return handlePrepareCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+ {
+ try
+ {
+ return handleRollbackCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+ {
+ try
+ {
+ return handleCommitCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ @Override
+ public final Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+ {
+ try
+ {
+ return handleOptimisticPrepareCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+ protected Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+ /**
+ * Callback that is invoked after every handleXXX() method defined above.
+ *
+ * @param ctx invocation context
+ * @param command command which was invoked
+ */
+ protected abstract void doAfterCall(InvocationContext ctx, VisitableCommand command);
+}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-04-28 16:56:40 UTC (rev 5733)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-04-28 17:27:58 UTC (rev 5734)
@@ -23,9 +23,15 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
/**
- * Chained command interceptor that performs a skip check before calling each handler method.
- * This is usefull in scenarios where all handlers methods should be skiped if the same condition is true.
- * E.g. CacheStoreInteceptor would skip all method calls if we have a shared storage and this is not the designated node.
+ * This interceptor will call {@link #skipInterception(org.jboss.cache.InvocationContext,org.jboss.cache.commands.VisitableCommand)} before invoking each visit method
+ * (and the {@link #handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)} method). If
+ * {@link #skipInterception(org.jboss.cache.InvocationContext,org.jboss.cache.commands.VisitableCommand)} returns <tt>false</tt>, the invocation will be skipped
+ * and passed up the interceptor chain instead.
+ * <p/>
+ * Instead of overriding visitXXX() methods, implementations should override their handleXXX() counterparts defined in this class
+ * instead, as well as the {@link #skipInterception(org.jboss.cache.InvocationContext,org.jboss.cache.commands.VisitableCommand)} method.
+ * Also, instead of overriding {@link #handleDefault(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}, implementors
+ * should override {@link #handleAll(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}.
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
@@ -35,302 +41,317 @@
@Override
public final Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executePutDataMapCommand(ctx, command);
+ return handlePutDataMapCommand(ctx, command);
}
- public Object executePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+ protected Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executePutKeyValueCommand(ctx, command);
+ return handlePutKeyValueCommand(ctx, command);
}
- public Object executePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ protected Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeRemoveNodeCommand(ctx, command);
+ return handleRemoveNodeCommand(ctx, command);
}
- public Object executeRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+ protected Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeRemoveDataCommand(ctx, command);
+ return handleRemoveDataCommand(ctx, command);
}
- public Object executeRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
+ protected Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeEvictFqnCommand(ctx, command);
+ return handleEvictFqnCommand(ctx, command);
}
- public Object executeEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+ protected Object handleEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeInvalidateCommand(ctx, command);
+ return handleInvalidateCommand(ctx, command);
}
- public Object executeInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+ protected Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeRemoveKeyCommand(ctx, command);
+ return handleRemoveKeyCommand(ctx, command);
}
- public Object executeRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+ protected Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeGetDataMapCommand(ctx, command);
+ return handleGetDataMapCommand(ctx, command);
}
- public Object executeGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+ protected Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitExistsNodeCommand(InvocationContext ctx, RemoteExistsCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeExistsNodeCommand(ctx, command);
+ return handleExistsNodeCommand(ctx, command);
}
- public Object executeExistsNodeCommand(InvocationContext ctx, RemoteExistsCommand command) throws Throwable
+ protected Object handleExistsNodeCommand(InvocationContext ctx, RemoteExistsCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeGetKeyValueCommand(ctx, command);
+ return handleGetKeyValueCommand(ctx, command);
}
- public Object executeGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+ protected Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeGetNodeCommand(ctx, command);
+ return handleGetNodeCommand(ctx, command);
}
- public Object executeGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+ protected Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeGetKeysCommand(ctx, command);
+ return handleGetKeysCommand(ctx, command);
}
- public Object executeGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+ protected Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeGetChildrenNamesCommand(ctx, command);
+ return handleGetChildrenNamesCommand(ctx, command);
}
- public Object executeGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+ protected Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeMoveCommand(ctx, command);
+ return handleMoveCommand(ctx, command);
}
- public Object executeMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+ protected Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeGravitateDataCommand(ctx, command);
+ return handleGravitateDataCommand(ctx, command);
}
- public Object executeGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+ protected Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executePrepareCommand(ctx, command);
+ return handlePrepareCommand(ctx, command);
}
- public Object executePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+ protected Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeRollbackCommand(ctx, command);
+ return handleRollbackCommand(ctx, command);
}
- public Object executeRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+ protected Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeCommitCommand(ctx, command);
+ return handleCommitCommand(ctx, command);
}
- public Object executeCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+ protected Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeOptimisticPrepareCommand(ctx, command);
+ return handleOptimisticPrepareCommand(ctx, command);
}
- public Object executeOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+ protected Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
{
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
@Override
public final Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
{
- if (skipInterception(ctx))
+ if (skipInterception(ctx, command))
{
return invokeNextInterceptor(ctx, command);
}
- return executeAll(ctx, command);
+ return handleAll(ctx, command);
}
- public Object executeAll(InvocationContext ctx, VisitableCommand command) throws Throwable
+ /**
+ * Default implementation, which just passes the call up the interceptor chain
+ *
+ * @param ctx invocation context
+ * @param command command
+ * @return return value
+ * @throws Throwable in the event of problems
+ */
+ protected Object handleAll(InvocationContext ctx, VisitableCommand command) throws Throwable
{
return invokeNextInterceptor(ctx, command);
}
- public abstract boolean skipInterception(InvocationContext ctx);
+ /**
+ * Tests whether the command should be intercepted or not. This is invoked before any of the handleXXX() methods.
+ *
+ * @param ctx invocation context
+ * @param command command
+ * @return true if the invocation should skip the current interceptor and move on to the next in the chain, false otherwise.
+ */
+ protected abstract boolean skipInterception(InvocationContext ctx, VisitableCommand command);
}
16 years, 8 months