JBoss Cache SVN: r6882 - core/branches/flat/src/main/resources/config-samples.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-08 12:22:44 -0400 (Wed, 08 Oct 2008)
New Revision: 6882
Modified:
core/branches/flat/src/main/resources/config-samples/cacheloader-enabled.xml
core/branches/flat/src/main/resources/config-samples/eviction-enabled.xml
Log:
Moved stuff
Modified: core/branches/flat/src/main/resources/config-samples/cacheloader-enabled.xml
===================================================================
--- core/branches/flat/src/main/resources/config-samples/cacheloader-enabled.xml 2008-10-08 16:22:40 UTC (rev 6881)
+++ core/branches/flat/src/main/resources/config-samples/cacheloader-enabled.xml 2008-10-08 16:22:44 UTC (rev 6882)
@@ -21,7 +21,7 @@
<!-- Specific eviction policy configurations -->
<eviction wakeUpInterval="5000">
<!-- Cache wide default -->
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">3000</attribute>
</default>
Modified: core/branches/flat/src/main/resources/config-samples/eviction-enabled.xml
===================================================================
--- core/branches/flat/src/main/resources/config-samples/eviction-enabled.xml 2008-10-08 16:22:40 UTC (rev 6881)
+++ core/branches/flat/src/main/resources/config-samples/eviction-enabled.xml 2008-10-08 16:22:44 UTC (rev 6882)
@@ -25,12 +25,12 @@
-->
<eviction wakeUpInterval="5000">
<!-- Cache wide default -->
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000000</attribute>
</default>
- <!-- configurations for various regions-->
+ <!-- configurations for various regions-->
<region name="/org/jboss/data">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000000</attribute>
17 years, 2 months
JBoss Cache SVN: r6881 - in core/branches/flat/src/test/resources: configs and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-08 12:22:40 -0400 (Wed, 08 Oct 2008)
New Revision: 6881
Modified:
core/branches/flat/src/test/resources/configs/clonable-config.xml
core/branches/flat/src/test/resources/configs/local-lru-eviction.xml
core/branches/flat/src/test/resources/configs/local-passivation.xml
core/branches/flat/src/test/resources/configs/local-tx.xml
core/branches/flat/src/test/resources/configs/mixedPolicy-eviction.xml
core/branches/flat/src/test/resources/configs/parser-test-async.xml
core/branches/flat/src/test/resources/configs/parser-test.xml
core/branches/flat/src/test/resources/configs/policyPerRegion-eviction.xml
core/branches/flat/src/test/resources/configs/string-property-replaced.xml
core/branches/flat/src/test/resources/jbc2-registry-configs.xml
core/branches/flat/src/test/resources/jbc3-registry-configs.xml
core/branches/flat/src/test/resources/unit-test-cache-service.xml
Log:
Moved stuff
Modified: core/branches/flat/src/test/resources/configs/clonable-config.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/clonable-config.xml 2008-10-08 16:16:40 UTC (rev 6880)
+++ core/branches/flat/src/test/resources/configs/clonable-config.xml 2008-10-08 16:22:40 UTC (rev 6881)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="SERIALIZABLE" lockAcquisitionTimeout="1" nodeLockingScheme="optimistic"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<stateRetrieval fetchInMemoryState="false" timeout="3"/>
@@ -45,18 +45,18 @@
</buddy>
</replication>
<eviction wakeUpInterval="45000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="4">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="4">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000000</attribute>
<attribute name="maxAge">15000</attribute>
</default>
- <region name="/fifo" algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm">
+ <region name="/fifo" algorithmClass="org.jboss.starobrno.eviction.FIFOAlgorithm">
<attribute name="maxNodes">5000</attribute>
</region>
- <region name="/mru" algorithmClass="org.jboss.cache.eviction.MRUAlgorithm">
+ <region name="/mru" algorithmClass="org.jboss.starobrno.eviction.MRUAlgorithm">
<attribute name="maxNodes">10000</attribute>
</region>
- <region name="/lfu" algorithmClass="org.jboss.cache.eviction.LFUAlgorithm">
+ <region name="/lfu" algorithmClass="org.jboss.starobrno.eviction.LFUAlgorithm">
<attribute name="maxNodes">5000</attribute>
<attribute name="minNodes">4000</attribute>
</region>
Modified: core/branches/flat/src/test/resources/configs/local-lru-eviction.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/local-lru-eviction.xml 2008-10-08 16:16:40 UTC (rev 6880)
+++ core/branches/flat/src/test/resources/configs/local-lru-eviction.xml 2008-10-08 16:22:40 UTC (rev 6881)
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<stateRetrieval timeout="20000"/>
<transport clusterName="JBossCache-Cluster"/>
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000000</attribute>
</default>
Modified: core/branches/flat/src/test/resources/configs/local-passivation.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/local-passivation.xml 2008-10-08 16:16:40 UTC (rev 6880)
+++ core/branches/flat/src/test/resources/configs/local-passivation.xml 2008-10-08 16:22:40 UTC (rev 6881)
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<stateRetrieval timeout="20000"/>
<transport clusterName="JBossCache-Cluster"/>
<eviction wakeUpInterval="1000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000</attribute>
</default>
Modified: core/branches/flat/src/test/resources/configs/local-tx.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/local-tx.xml 2008-10-08 16:16:40 UTC (rev 6880)
+++ core/branches/flat/src/test/resources/configs/local-tx.xml 2008-10-08 16:22:40 UTC (rev 6881)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
@@ -8,7 +8,7 @@
<stateRetrieval timeout="20000"/>
<transport clusterName="JBossCache-Cluster"/>
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000000</attribute>
</default>
Modified: core/branches/flat/src/test/resources/configs/mixedPolicy-eviction.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/mixedPolicy-eviction.xml 2008-10-08 16:16:40 UTC (rev 6880)
+++ core/branches/flat/src/test/resources/configs/mixedPolicy-eviction.xml 2008-10-08 16:22:40 UTC (rev 6881)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
@@ -35,14 +35,14 @@
</jgroupsConfig>
</transport>
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000000</attribute>
</default>
- <region name="/org/jboss/data" algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm">
+ <region name="/org/jboss/data" algorithmClass="org.jboss.starobrno.eviction.FIFOAlgorithm">
<attribute name="maxNodes">5000</attribute>
</region>
- <region name="/test/" algorithmClass="org.jboss.cache.eviction.MRUAlgorithm">
+ <region name="/test/" algorithmClass="org.jboss.starobrno.eviction.MRUAlgorithm">
<attribute name="maxNodes">10000</attribute>
</region>
<region name="/maxAgeTest/">
Modified: core/branches/flat/src/test/resources/configs/parser-test-async.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/parser-test-async.xml 2008-10-08 16:16:40 UTC (rev 6880)
+++ core/branches/flat/src/test/resources/configs/parser-test-async.xml 2008-10-08 16:22:40 UTC (rev 6881)
@@ -59,14 +59,14 @@
<jmxStatistics enabled="false"/>
<eviction wakeUpInterval="5">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000</attribute>
</default>
<region name="/org/jboss/data">
<attribute name="timeToLive">1002</attribute>
</region>
- <region name="/org/jboss/xyz" algorithmClass="org.jboss.cache.eviction.MRUAlgorithm" eventQueueSize="21">
+ <region name="/org/jboss/xyz" algorithmClass="org.jboss.starobrno.eviction.MRUAlgorithm" eventQueueSize="21">
<attribute name="maxNodes">2103</attribute>
<attribute name="minTimeToLive">22</attribute>
</region>
Modified: core/branches/flat/src/test/resources/configs/parser-test.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/parser-test.xml 2008-10-08 16:16:40 UTC (rev 6880)
+++ core/branches/flat/src/test/resources/configs/parser-test.xml 2008-10-08 16:22:40 UTC (rev 6881)
@@ -59,14 +59,14 @@
<jmxStatistics enabled="false"/>
<eviction wakeUpInterval="5">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm" eventQueueSize="200000">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000</attribute>
</default>
<region name="/org/jboss/data">
<attribute name="timeToLive">1002</attribute>
</region>
- <region name="/org/jboss/xyz" algorithmClass="org.jboss.cache.eviction.MRUAlgorithm" eventQueueSize="21">
+ <region name="/org/jboss/xyz" algorithmClass="org.jboss.starobrno.eviction.MRUAlgorithm" eventQueueSize="21">
<attribute name="maxNodes">2103</attribute>
<attribute name="minTimeToLive">22</attribute>
</region>
Modified: core/branches/flat/src/test/resources/configs/policyPerRegion-eviction.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/policyPerRegion-eviction.xml 2008-10-08 16:16:40 UTC (rev 6880)
+++ core/branches/flat/src/test/resources/configs/policyPerRegion-eviction.xml 2008-10-08 16:22:40 UTC (rev 6881)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:jboss:jbosscache-core:config:3.0">
+<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:jboss:jbosscache-core:config:3.0">
<locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
<stateRetrieval timeout="20000"/>
@@ -33,23 +33,23 @@
<pbcast.FLUSH timeout="0"/>
</jgroupsConfig>
</transport>
-
+
<eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000000</attribute>
</default>
- <region name="/org/jboss/data" algorithmClass="org.jboss.cache.eviction.LFUAlgorithm">
+ <region name="/org/jboss/data" algorithmClass="org.jboss.starobrno.eviction.LFUAlgorithm">
<attribute name="maxNodes">5000</attribute>
<attribute name="minNodes">1000</attribute>
</region>
- <region name="/org/jboss/test/data" algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm">
+ <region name="/org/jboss/test/data" algorithmClass="org.jboss.starobrno.eviction.FIFOAlgorithm">
<attribute name="maxNodes">5</attribute>
</region>
- <region name="/test/" algorithmClass="org.jboss.cache.eviction.MRUAlgorithm">
+ <region name="/test/" algorithmClass="org.jboss.starobrno.eviction.MRUAlgorithm">
<attribute name="maxNodes">10000</attribute>
</region>
- <region name="/maxAgeTest/" algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <region name="/maxAgeTest/" algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
<attribute name="maxNodes">10000</attribute>
<attribute name="timeToLive">8000</attribute>
<attribute name="maxAge">10000</attribute>
Modified: core/branches/flat/src/test/resources/configs/string-property-replaced.xml
===================================================================
--- core/branches/flat/src/test/resources/configs/string-property-replaced.xml 2008-10-08 16:16:40 UTC (rev 6880)
+++ core/branches/flat/src/test/resources/configs/string-property-replaced.xml 2008-10-08 16:22:40 UTC (rev 6881)
@@ -24,7 +24,8 @@
</buddy>
</replication>
<eviction wakeUpInterval="5000">
- <default algorithmClass="${test.property.EvictionPolicyConfig.policyClass:org.jboss.cache.eviction.LRUAlgorithm}">
+ <default
+ algorithmClass="${test.property.EvictionPolicyConfig.policyClass:org.jboss.starobrno.eviction.LRUAlgorithm}">
<attribute name="maxNodes">${test.property.EvictionPolicyConfig.maxNodes:5000}</attribute>
<attribute name="timeToLive">1000000</attribute>
</default>
Modified: core/branches/flat/src/test/resources/jbc2-registry-configs.xml
===================================================================
(Binary files differ)
Modified: core/branches/flat/src/test/resources/jbc3-registry-configs.xml
===================================================================
--- core/branches/flat/src/test/resources/jbc3-registry-configs.xml 2008-10-08 16:16:40 UTC (rev 6880)
+++ core/branches/flat/src/test/resources/jbc3-registry-configs.xml 2008-10-08 16:22:40 UTC (rev 6881)
@@ -1,185 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
-<registry:cache-configs xmlns="urn:jboss:jbosscache-core:config:3.0" xmlns:registry="urn:jboss:jbosscache-core:cache-repo:3.0">
+<registry:cache-configs xmlns="urn:jboss:jbosscache-core:config:3.0"
+ xmlns:registry="urn:jboss:jbosscache-core:cache-repo:3.0">
- <!--
- Various JBoss Cache configurations, suitable for different caching
- uses (e.g. entities vs. queries).
+ <!--
+ Various JBoss Cache configurations, suitable for different caching
+ uses (e.g. entities vs. queries).
- In all cases, TransactionManager configuration not required.
- Hibernate will plug in its own transaction manager integration.
- -->
+ In all cases, TransactionManager configuration not required.
+ Hibernate will plug in its own transaction manager integration.
+ -->
- <!-- A config appropriate for entity/collection caching. -->
- <registry:cache-config name="optimistic-entity">
- <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
- <transaction syncCommitPhase="true" syncRollbackPhase="true"
- transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
- <serialization useRegionBasedMarshalling="true"/>
- <startup regionsInactiveOnStartup="true"/>
- <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
- <transport clusterName="optimistic-entity" multiplexerStack="udp-sync"/>
- <invalidation>
- <sync replTimeout="20000"/>
- </invalidation>
- <eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
- <attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLive">1000</attribute>
- </default>
- <region name="/TS">
- <attribute name="maxNodes">0</attribute>
- <attribute name="timeToLive">0</attribute>
- </region>
- </eviction>
- </registry:cache-config>
+ <!-- A config appropriate for entity/collection caching. -->
+ <registry:cache-config name="optimistic-entity">
+ <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+ <transaction syncCommitPhase="true" syncRollbackPhase="true"
+ transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
+ <transport clusterName="optimistic-entity" multiplexerStack="udp-sync"/>
+ <invalidation>
+ <sync replTimeout="20000"/>
+ </invalidation>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
- <!-- A config appropriate for entity/collection caching that
- uses pessimistic locking -->
- <registry:cache-config name="pessimistic-entity">
- <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
- <serialization useRegionBasedMarshalling="true"/>
- <startup regionsInactiveOnStartup="true"/>
- <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
- <transport clusterName="pessimistic-entity" multiplexerStack="udp-sync"/>
- <invalidation>
- <sync replTimeout="20000"/>
- </invalidation>
- <eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
- <attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLive">1000</attribute>
- </default>
- <region name="/TS">
- <attribute name="maxNodes">0</attribute>
- <attribute name="timeToLive">0</attribute>
- </region>
- </eviction>
- </registry:cache-config>
+ <!-- A config appropriate for entity/collection caching that
+uses pessimistic locking -->
+ <registry:cache-config name="pessimistic-entity">
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
+ <transport clusterName="pessimistic-entity" multiplexerStack="udp-sync"/>
+ <invalidation>
+ <sync replTimeout="20000"/>
+ </invalidation>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
- <!-- A config appropriate for query caching. Does not replicate
- queries. DO NOT STORE TIMESTAMPS IN THIS CACHE.
- -->
- <registry:cache-config name="local-query">
- <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
- <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
- <eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
- <attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLive">1000</attribute>
- </default>
- <region name="/TS">
- <attribute name="maxNodes">0</attribute>
- <attribute name="timeToLive">0</attribute>
- </region>
- </eviction>
- </registry:cache-config>
+ <!-- A config appropriate for query caching. Does not replicate
+ queries. DO NOT STORE TIMESTAMPS IN THIS CACHE.
+ -->
+ <registry:cache-config name="local-query">
+ <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
- <!-- A query cache that replicates queries. Replication is asynchronous.
- DO NOT STORE TIMESTAMPS IN THIS CACHE.
- -->
- <registry:cache-config name="replicated-query">
- <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
- <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
- <serialization useRegionBasedMarshalling="false"/>
- <startup regionsInactiveOnStartup="false"/>
- <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
- <transport clusterName="replicated-query" multiplexerStack="udp"/>
- <replication>
- <async/>
- </replication>
- <eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
- <attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLive">1000</attribute>
- </default>
- <region name="/TS" >
- <attribute name="maxNodes">0</attribute>
- <attribute name="timeToLive">0</attribute>
- </region>
- </eviction>
- </registry:cache-config>
+ <!-- A query cache that replicates queries. Replication is asynchronous.
+ DO NOT STORE TIMESTAMPS IN THIS CACHE.
+ -->
+ <registry:cache-config name="replicated-query">
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <serialization useRegionBasedMarshalling="false"/>
+ <startup regionsInactiveOnStartup="false"/>
+ <stateRetrieval fetchInMemoryState="false" timeout="20000"/>
+ <transport clusterName="replicated-query" multiplexerStack="udp"/>
+ <replication>
+ <async/>
+ </replication>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
- <!-- Optimized for timestamp caching. A clustered timestamp cache
- is required if query caching is used, even if the query cache
- itself is configured with CacheMode=LOCAL.
- -->
- <registry:cache-config name="timestamps-cache">
- <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
- <serialization useRegionBasedMarshalling="true"/>
- <startup regionsInactiveOnStartup="true"/>
- <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
- <transport clusterName="timestamps-cache" multiplexerStack="udp"/>
- <replication>
- <async/>
- </replication>
- <eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
- <attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLive">1000</attribute>
- </default>
- <region name="/TS">
- <attribute name="maxNodes">0</attribute>
- <attribute name="timeToLive">0</attribute>
- </region>
- </eviction>
- </registry:cache-config>
+ <!-- Optimized for timestamp caching. A clustered timestamp cache
+ is required if query caching is used, even if the query cache
+ itself is configured with CacheMode=LOCAL.
+ -->
+ <registry:cache-config name="timestamps-cache">
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
+ <transport clusterName="timestamps-cache" multiplexerStack="udp"/>
+ <replication>
+ <async/>
+ </replication>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
- <!-- A config appropriate for a cache that's shared for
- entity, collection, query and timestamp caching. Not an advised
- configuration, since it requires cache mode REPL_SYNC, which is the
- least efficient mode. Also requires a full state transfer at startup,
- which can be expensive. Uses optimistic locking. -->
- <registry:cache-config name="optimistic-shared">
- <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
- <transaction syncCommitPhase="true" syncRollbackPhase="true"
- transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
- <serialization useRegionBasedMarshalling="true"/>
- <startup regionsInactiveOnStartup="true"/>
- <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
- <transport clusterName="optimistic-shared" multiplexerStack="udp"/>
- <replication>
- <sync replTimeout="20000"/>
- </replication>
- <eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
- <attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLive">1000</attribute>
- </default>
- <region name="/TS">
- <attribute name="maxNodes">0</attribute>
- <attribute name="timeToLive">0</attribute>
- </region>
- </eviction>
- </registry:cache-config>
+ <!-- A config appropriate for a cache that's shared for
+entity, collection, query and timestamp caching. Not an advised
+configuration, since it requires cache mode REPL_SYNC, which is the
+least efficient mode. Also requires a full state transfer at startup,
+which can be expensive. Uses optimistic locking. -->
+ <registry:cache-config name="optimistic-shared">
+ <locking lockAcquisitionTimeout="15000" nodeLockingScheme="optimistic"/>
+ <transaction syncCommitPhase="true" syncRollbackPhase="true"
+ transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
+ <transport clusterName="optimistic-shared" multiplexerStack="udp"/>
+ <replication>
+ <sync replTimeout="20000"/>
+ </replication>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
+ <!-- A config appropriate for a cache that's shared for
+ entity, collection, query and timestamp caching. Not an advised
+ configuration, since it requires cache mode REPL_SYNC, which is the
+ least efficient mode. Also requires a full state transfer at startup,
+ which can be expensive. Uses pessmistic locking.
+ -->
+ <registry:cache-config name="pessimistic-shared">
- <!-- A config appropriate for a cache that's shared for
- entity, collection, query and timestamp caching. Not an advised
- configuration, since it requires cache mode REPL_SYNC, which is the
- least efficient mode. Also requires a full state transfer at startup,
- which can be expensive. Uses pessmistic locking.
- -->
- <registry:cache-config name="pessimistic-shared">
-
- <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
- <serialization useRegionBasedMarshalling="true"/>
- <startup regionsInactiveOnStartup="true"/>
- <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
- <transport clusterName="pessimistic-shared" multiplexerStack="udp"/>
- <replication>
- <sync replTimeout="20000"/>
- </replication>
- <eviction wakeUpInterval="5000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
- <attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLive">1000</attribute>
- </default>
- <region name="/TS">
- <attribute name="maxNodes">0</attribute>
- <attribute name="timeToLive">0</attribute>
- </region>
- </eviction>
- </registry:cache-config>
+ <locking isolationLevel="REPEATABLE_READ" lockAcquisitionTimeout="15000" nodeLockingScheme="pessimistic"/>
+ <serialization useRegionBasedMarshalling="true"/>
+ <startup regionsInactiveOnStartup="true"/>
+ <stateRetrieval fetchInMemoryState="true" timeout="20000"/>
+ <transport clusterName="pessimistic-shared" multiplexerStack="udp"/>
+ <replication>
+ <sync replTimeout="20000"/>
+ </replication>
+ <eviction wakeUpInterval="5000">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLive">1000</attribute>
+ </default>
+ <region name="/TS">
+ <attribute name="maxNodes">0</attribute>
+ <attribute name="timeToLive">0</attribute>
+ </region>
+ </eviction>
+ </registry:cache-config>
</registry:cache-configs>
Modified: core/branches/flat/src/test/resources/unit-test-cache-service.xml
===================================================================
--- core/branches/flat/src/test/resources/unit-test-cache-service.xml 2008-10-08 16:16:40 UTC (rev 6880)
+++ core/branches/flat/src/test/resources/unit-test-cache-service.xml 2008-10-08 16:22:40 UTC (rev 6881)
@@ -10,7 +10,7 @@
<sync replTimeout="15000"/>
</replication>
<eviction wakeUpInterval="2000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm">
+ <default algorithmClass="org.jboss.starobrno.eviction.LRUAlgorithm">
<attribute name="maxNodes">5000</attribute>
<attribute name="timeToLive">1000</attribute>
</default>
17 years, 2 months
JBoss Cache SVN: r6879 - in core/branches/flat/src/main/java/org/jboss/starobrno: interceptors and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-08 12:05:24 -0400 (Wed, 08 Oct 2008)
New Revision: 6879
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/RPCManager.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/BaseTransactionalContextInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java
Log:
added
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/RPCManager.java (from rev 6858, core/branches/flat/src/main/java/org/jboss/cache/RPCManager.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/RPCManager.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/RPCManager.java 2008-10-08 16:05:24 UTC (rev 6879)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno;
+
+import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.Fqn;
+import org.jgroups.Address;
+import org.jgroups.Channel;
+import org.jgroups.blocks.RspFilter;
+
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * Provides a mechanism for communicating with other caches in the cluster. For now this is based on JGroups as an underlying
+ * transport, and in future more transport options may become available.
+ * <p/>
+ * Implementations have a simple lifecycle:
+ * <ul>
+ * <li>start() - starts the underlying channel based on configuration options injected, and connects the channel</li>
+ * <li>disconnect() - disconnects the channel</li>
+ * <li>stop() - stops the dispatcher and releases resources</li>
+ * </ul>
+ *
+ * @author Manik Surtani
+ * @since 2.1.0
+ */
+public interface RPCManager
+{
+ /**
+ * Disconnects and closes the underlying JGroups channel.
+ */
+ void disconnect();
+
+ /**
+ * Stops the RPCDispatcher and frees resources. Closes and disconnects the underlying JGroups channel if this is
+ * still open/connected.
+ */
+ void stop();
+
+ /**
+ * Starts the RPCManager by connecting the underlying JGroups channel (if configured for replication). Connecting
+ * the channel may also involve state transfer (if configured) so the interceptor chain should be started and
+ * available before this method is called.
+ */
+ void start();
+
+ /**
+ * Invokes an RPC call on other caches in the cluster.
+ *
+ * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
+ * @param cacheCommand the cache command to invoke
+ * @param mode the group request mode to use. See {@link org.jgroups.blocks.GroupRequest}.
+ * @param timeout a timeout after which to throw a replication exception.
+ * @param responseFilter a response filter with which to filter out failed/unwanted/invalid responses.
+ * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
+ * @return a list of responses from each member contacted.
+ * @throws Exception in the event of problems.
+ */
+ List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, int mode, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception;
+
+ /**
+ * Invokes an RPC call on other caches in the cluster.
+ *
+ * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
+ * @param cacheCommand the cache command to invoke
+ * @param mode the group request mode to use. See {@link org.jgroups.blocks.GroupRequest}.
+ * @param timeout a timeout after which to throw a replication exception.
+ * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
+ * @return a list of responses from each member contacted.
+ * @throws Exception in the event of problems.
+ */
+ List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, int mode, long timeout, boolean useOutOfBandMessage) throws Exception;
+
+ /**
+ * Invokes an RPC call on other caches in the cluster.
+ *
+ * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
+ * @param cacheCommand the cache command to invoke
+ * @param synchronous if true, sets group request mode to {@link org.jgroups.blocks.GroupRequest#GET_ALL}, and if false sets it to {@link org.jgroups.blocks.GroupRequest#GET_NONE}.
+ * @param timeout a timeout after which to throw a replication exception.
+ * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
+ * @return a list of responses from each member contacted.
+ * @throws Exception in the event of problems.
+ */
+ List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, boolean synchronous, long timeout, boolean useOutOfBandMessage) throws Exception;
+
+ /**
+ * @return true if the current Channel is the coordinator of the cluster.
+ */
+ boolean isCoordinator();
+
+ /**
+ * @return the Address of the current coordinator.
+ */
+ Address getCoordinator();
+
+ /**
+ * Retrieves the local JGroups channel's address
+ *
+ * @return an Address
+ */
+ Address getLocalAddress();
+
+ /**
+ * Returns a defensively copied list of members in the current cluster view.
+ */
+ List<Address> getMembers();
+
+ /**
+ * Retrieves partial state from remote instances.
+ *
+ * @param sources sources to consider for a state transfer
+ * @param sourceTarget Fqn on source to retrieve state for
+ * @param integrationTarget integration point on local cache to apply state
+ * @throws Exception in the event of problems
+ */
+ void fetchPartialState(List<Address> sources, Fqn sourceTarget, Fqn integrationTarget) throws Exception;
+
+ /**
+ * Retrieves partial state from remote instances.
+ *
+ * @param sources sources to consider for a state transfer
+ * @param subtree Fqn subtree to retrieve. Will be integrated at the same point.
+ * @throws Exception in the event of problems
+ */
+ void fetchPartialState(List<Address> sources, Fqn subtree) throws Exception;
+
+ /**
+ * Retrieves the Channel
+ *
+ * @return a channel
+ */
+ Channel getChannel();
+}
\ No newline at end of file
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/BaseTransactionalContextInterceptor.java (from rev 6858, core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/BaseTransactionalContextInterceptor.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/BaseTransactionalContextInterceptor.java 2008-10-08 16:05:24 UTC (rev 6879)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.interceptors;
+
+import org.jboss.cache.config.Option;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.context.TransactionContext;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.interceptors.base.CommandInterceptor;
+import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.transaction.TransactionTable;
+
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+/**
+ * Class providing some base functionality around manipulating transactions and global transactions withing invocation contexts.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ */
+public abstract class BaseTransactionalContextInterceptor extends CommandInterceptor
+{
+ protected TransactionTable txTable;
+ protected TransactionManager txManager;
+
+ @Inject
+ public void injectDependencies(TransactionTable txTable, TransactionManager txManager)
+ {
+ this.txManager = txManager;
+ this.txTable = txTable;
+ }
+
+ protected void copyInvocationScopeOptionsToTxScope(InvocationContext ctx)
+ {
+ // notify the transaction tCtx that this override is in place.
+ TransactionContext tCtx = txTable.get(ctx.getGlobalTransaction());
+ if (tCtx != null)
+ {
+ Option txScopeOption = new Option();
+ txScopeOption.setCacheModeLocal(ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isCacheModeLocal());
+ txScopeOption.setSkipCacheStatusCheck(ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isSkipCacheStatusCheck());
+ tCtx.setOption(txScopeOption);
+ }
+ }
+
+ protected void setTransactionalContext(Transaction tx, GlobalTransaction gtx, TransactionContext tCtx, InvocationContext ctx)
+ {
+ if (trace)
+ {
+ log.trace("Setting up transactional context.");
+ log.trace("Setting tx as " + tx + " and gtx as " + gtx);
+ }
+ ctx.setTransaction(tx);
+ ctx.setGlobalTransaction(gtx);
+ if (tCtx == null)
+ {
+ if (gtx != null)
+ {
+ ctx.setTransactionContext(txTable.get(gtx));
+ }
+ else if (tx == null)
+ {
+ // then nullify the transaction tCtx as well
+ ctx.setTransactionContext(null);
+ }
+ }
+ else
+ {
+ ctx.setTransactionContext(tCtx);
+ }
+ }
+
+ /**
+ * Returns true if transaction is rolling back, false otherwise
+ */
+ protected boolean isRollingBack(Transaction tx)
+ {
+ if (tx == null) return false;
+ int status;
+ try
+ {
+ status = tx.getStatus();
+ return status == Status.STATUS_ROLLING_BACK || status == Status.STATUS_ROLLEDBACK;
+ }
+ catch (SystemException e)
+ {
+ log.error("failed getting transaction status", e);
+ return false;
+ }
+ }
+}
\ No newline at end of file
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java (from rev 6858, core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java 2008-10-08 16:05:24 UTC (rev 6879)
@@ -0,0 +1,236 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.interceptors;
+
+
+import org.jboss.cache.config.Option;
+import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.commands.tx.CommitCommand;
+import org.jboss.starobrno.commands.tx.PrepareCommand;
+import org.jboss.starobrno.commands.tx.RollbackCommand;
+import org.jboss.starobrno.commands.write.ClearCommand;
+import org.jboss.starobrno.commands.write.PutKeyValueCommand;
+import org.jboss.starobrno.commands.write.PutMapCommand;
+import org.jboss.starobrno.commands.write.RemoveCommand;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.RPCManager;
+
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
+public class InvocationContextInterceptor extends BaseTransactionalContextInterceptor
+{
+ private RPCManager rpcManager;
+
+ @Inject
+ public void setDependencies(RPCManager rpcManager)
+ {
+ this.rpcManager = rpcManager;
+ }
+
+ @Override
+ public Object visitPutMapCommand(InvocationContext ctx, PutMapCommand command) throws Throwable
+ {
+ return handleAll(ctx, command, ctx.getGlobalTransaction(), false);
+ }
+
+ @Override
+ public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ {
+ return handleAll(ctx, command, ctx.getGlobalTransaction(), false);
+ }
+
+ @Override
+ public Object visitClearCommand(InvocationContext ctx, ClearCommand command) throws Throwable
+ {
+ return handleAll(ctx, command, ctx.getGlobalTransaction(), false);
+ }
+
+ @Override
+ public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) throws Throwable
+ {
+ return handleAll(ctx, command, ctx.getGlobalTransaction(), false);
+ }
+
+ @Override
+ public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+ {
+ return handleAll(ctx, command, command.getGlobalTransaction(), true);
+ }
+
+ @Override
+ public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+ {
+ return handleAll(ctx, command, command.getGlobalTransaction(), true);
+ }
+
+ @Override
+ public Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+ {
+ return handleAll(ctx, command, command.getGlobalTransaction(), true);
+ }
+
+ @Override
+ public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
+ {
+ return handleAll(ctx, command, null, false);
+ }
+
+ @SuppressWarnings("deprecation")
+ private Object handleAll(InvocationContext ctx, VisitableCommand command, GlobalTransaction gtx, boolean scrubContextOnCompletion) throws Throwable
+ {
+ Option optionOverride = ctx.getOptionOverrides();
+ boolean suppressExceptions = false;
+ Transaction suspendedTransaction = null;
+ boolean resumeSuspended = false;
+
+ if (trace) log.trace("Invoked with command " + command + " and InvocationContext [" + ctx + "]");
+
+ try
+ {
+ if (txManager != null)
+ {
+ Transaction tx = getTransaction();
+ GlobalTransaction realGtx = getGlobalTransaction(tx, gtx);
+ if (tx == null && realGtx != null && realGtx.isRemote()) tx = txTable.getLocalTransaction(gtx);
+ setTransactionalContext(tx, realGtx, null, ctx);
+ }
+ else
+ {
+ setTransactionalContext(null, null, null, ctx);
+ }
+
+ if (optionOverride != null)
+ {
+ if (optionOverride.isFailSilently())
+ {
+ log.debug("FAIL_SILENTLY Option is present - suspending any ongoing transaction.");
+ suppressExceptions = true;
+ if (ctx.getTransaction() != null)
+ {
+ suspendedTransaction = txManager.suspend();
+ setTransactionalContext(null, null, null, ctx);
+ if (trace) log.trace("Suspending transaction " + suspendedTransaction);
+ resumeSuspended = true;
+ }
+ else
+ {
+ if (trace) log.trace("No ongoing transaction to suspend");
+ }
+ }
+ }
+
+ Object retval;
+ try
+ {
+ return invokeNextInterceptor(ctx, command);
+ }
+ catch (Throwable th)
+ {
+ retval = th;
+ // if fail silently return a null
+ if (suppressExceptions) return null;
+ Throwable t = (Throwable) retval;
+ if (t instanceof RuntimeException && t.getCause() != null)
+ {
+ throw t.getCause();
+ }
+ else
+ {
+ throw t;
+ }
+ }
+ // assume we're the first interceptor in the chain. Handle the exception-throwing.
+ }
+ finally
+ {
+ // TODO: scope upgrading should happen transparently
+ /*
+ * we should scrub txs after every call to prevent race conditions
+ * basically any other call coming in on the same thread and hijacking any running tx's
+ * was highlighted in JBCACHE-606
+ */
+ if (scrubContextOnCompletion) setTransactionalContext(null, null, null, ctx);
+
+ // clean up any invocation-scope options set up
+ if (trace) log.trace("Resetting invocation-scope options");
+ ctx.getOptionOverrides().reset();
+
+ // if this is a prepare, opt prepare or
+
+ if (resumeSuspended)
+ {
+ txManager.resume(suspendedTransaction);
+ }
+ else
+ {
+ if (ctx.getTransaction() != null && (TransactionTable.isValid(ctx.getTransaction())))
+ {
+ copyInvocationScopeOptionsToTxScope(ctx);
+ }
+ }
+
+ // reset the context to prevent leakage of internals
+ ctx.setCommand(null);
+
+ // TODO: Calling ctx.reset() here breaks stuff. Check whether this is just becuse UTs expect stuff in the ctx or whether this really breaks functionality.
+// ctx.reset();
+ // instead, for now, just wipe contents of the looked up node map
+ ctx.clearLookedUpEntries();
+ }
+ }
+
+ private GlobalTransaction getGlobalTransaction(Transaction tx, GlobalTransaction gtx)
+ {
+ if (gtx == null) gtx = txTable.getCurrentTransaction(tx, false);
+ if (gtx != null) gtx.setRemote(isRemoteGlobalTx(gtx));
+ return gtx;
+ }
+
+ private Transaction getTransaction() throws SystemException
+ {
+ // this creates a context if one did not exist.
+ if (txManager == null)
+ {
+ if (trace) log.trace("no transaction manager configured, setting tx as null.");
+ return null;
+ }
+ else
+ {
+ return txManager.getTransaction();
+ }
+ }
+
+ /**
+ * Tests if a global transaction originated from a different cache in the cluster
+ *
+ * @param gtx
+ * @return true if the gtx is remote, false if it originated locally.
+ */
+ private boolean isRemoteGlobalTx(GlobalTransaction gtx)
+ {
+ return gtx != null && (gtx.getAddress() != null) && (!gtx.getAddress().equals(rpcManager.getLocalAddress()));
+ }
+}
\ No newline at end of file
17 years, 2 months
JBoss Cache SVN: r6878 - core/branches/flat/src/main/java/org/jboss/starobrno/interceptors.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-08 11:35:09 -0400 (Wed, 08 Oct 2008)
New Revision: 6878
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/CallInterceptor.java
Log:
added
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/CallInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/CallInterceptor.java 2008-10-08 14:59:03 UTC (rev 6877)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/CallInterceptor.java 2008-10-08 15:35:09 UTC (rev 6878)
@@ -86,8 +86,7 @@
return invokeCommand(ctx, command);
}
- private Object invokeCommand(InvocationContext ctx, ReplicableCommand command)
- throws Throwable
+ private Object invokeCommand(InvocationContext ctx, ReplicableCommand command) throws Throwable
{
Object retval;
try
@@ -124,6 +123,8 @@
return handleAlterCacheMethod(ctx, command);
}
+
+
/**
* only add the modification to the modification list if we are using pessimistic locking.
* Optimistic locking calls *should* not make it this far down the interceptor chain, but just
17 years, 2 months
JBoss Cache SVN: r6877 - core/branches/flat/src/main/java/org/jboss/starobrno.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2008-10-08 10:59:03 -0400 (Wed, 08 Oct 2008)
New Revision: 6877
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java
Log:
Add stuffs
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java 2008-10-08 14:58:36 UTC (rev 6876)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java 2008-10-08 14:59:03 UTC (rev 6877)
@@ -46,4 +46,8 @@
InvocationContext getInvocationContext();
void setInvocationContext(InvocationContext ctx);
+
+ AtomicGroup putAtomicGroup(K key, AtomicGroup group);
+
+ AtomicGroup getAtomicGroup(K key);
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java 2008-10-08 14:58:36 UTC (rev 6876)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java 2008-10-08 14:59:03 UTC (rev 6877)
@@ -187,4 +187,16 @@
{
//TODO: Autogenerated. Implement me properly
}
+
+ public AtomicGroup getAtomicGroup(Object key)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public AtomicGroup putAtomicGroup(Object key, AtomicGroup group)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
17 years, 2 months
JBoss Cache SVN: r6876 - in core/branches/flat/src/main/java/org/jboss/starobrno: commands/tx and 4 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-08 10:58:36 -0400 (Wed, 08 Oct 2008)
New Revision: 6876
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/CallInterceptor.java
Removed:
core/branches/flat/src/main/java/org/jboss/starobrno/commands/WriteCommand.java
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/PrepareCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java
Log:
dropped WriteCommand
Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/commands/WriteCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/WriteCommand.java 2008-10-08 14:34:05 UTC (rev 6875)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/WriteCommand.java 2008-10-08 14:58:36 UTC (rev 6876)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.starobrno.commands;
-
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.commands.*;
-import org.jboss.cache.commands.DataCommand;
-
-/**
- * A write command that has a reference to a {@link org.jboss.cache.transaction.GlobalTransaction}.
- *
- * @author Mircea.Markus(a)jboss.com
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 2.2.0
- */
-public interface WriteCommand extends DataCommand
-{
- /**
- * @return a GlobalTransaction associated with this command.
- */
- GlobalTransaction getGlobalTransaction();
-
- /**
- * Sets a GlobalTransaction on this command.
- *
- * @param gtx global transaction to set
- */
- void setGlobalTransaction(GlobalTransaction gtx);
-}
\ No newline at end of file
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/PrepareCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/PrepareCommand.java 2008-10-08 14:34:05 UTC (rev 6875)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/tx/PrepareCommand.java 2008-10-08 14:58:36 UTC (rev 6876)
@@ -21,9 +21,9 @@
*/
package org.jboss.starobrno.commands.tx;
+import org.jboss.starobrno.commands.DataCommand;
import org.jboss.starobrno.commands.ReplicableCommand;
import org.jboss.starobrno.commands.Visitor;
-import org.jboss.starobrno.commands.WriteCommand;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jgroups.Address;
@@ -42,11 +42,11 @@
{
public static final int METHOD_ID = 10;
- protected List<WriteCommand> modifications;
+ protected List<DataCommand> modifications;
protected Address localAddress;
protected boolean onePhaseCommit;
- public PrepareCommand(GlobalTransaction gtx, List<WriteCommand> modifications, Address localAddress, boolean onePhaseCommit)
+ public PrepareCommand(GlobalTransaction gtx, List<DataCommand> modifications, Address localAddress, boolean onePhaseCommit)
{
this.gtx = gtx;
this.modifications = modifications;
@@ -54,7 +54,7 @@
this.onePhaseCommit = onePhaseCommit;
}
- public void removeModifications(Collection<WriteCommand> modificationsToRemove)
+ public void removeModifications(Collection<DataCommand> modificationsToRemove)
{
if (modifications != null) modifications.removeAll(modificationsToRemove);
}
@@ -68,7 +68,7 @@
return visitor.visitPrepareCommand(ctx, this);
}
- public List<WriteCommand> getModifications()
+ public List<DataCommand> getModifications()
{
return modifications;
}
@@ -109,7 +109,7 @@
public void setParameters(int commandId, Object[] args)
{
gtx = (GlobalTransaction) args[0];
- modifications = (List<WriteCommand>) args[1];
+ modifications = (List<DataCommand>) args[1];
localAddress = (Address) args[2];
onePhaseCommit = (Boolean) args[3];
}
@@ -145,7 +145,7 @@
PrepareCommand copy = new PrepareCommand();
copy.gtx = gtx;
copy.localAddress = localAddress;
- copy.modifications = modifications == null ? null : new ArrayList<WriteCommand>(modifications);
+ copy.modifications = modifications == null ? null : new ArrayList<DataCommand>(modifications);
copy.onePhaseCommit = onePhaseCommit;
return copy;
}
@@ -163,7 +163,7 @@
public boolean containsModificationType(Class<? extends ReplicableCommand> replicableCommandClass)
{
- for (WriteCommand mod : getModifications())
+ for (DataCommand mod : getModifications())
{
if (mod.getClass().equals(replicableCommandClass))
{
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java 2008-10-08 14:34:05 UTC (rev 6875)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java 2008-10-08 14:58:36 UTC (rev 6876)
@@ -30,7 +30,7 @@
/**
* @author Mircea.Markus(a)jboss.com
*/
-public class RemoveCommand extends AbstractDataCommand
+public class RemoveCommand extends AbstractDataCommand
{
public static final int METHOD_ID = 6;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java 2008-10-08 14:34:05 UTC (rev 6875)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java 2008-10-08 14:58:36 UTC (rev 6876)
@@ -23,7 +23,7 @@
import org.jboss.cache.config.Option;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
-import org.jboss.starobrno.commands.WriteCommand;
+import org.jboss.starobrno.commands.VisitableCommand;
import javax.transaction.Transaction;
import java.util.List;
@@ -44,14 +44,14 @@
*
* @param command modification
*/
- void addModification(WriteCommand command);
+ void addModification(VisitableCommand command);
/**
* Returns all modifications. If there are no modifications in this transaction this method will return an empty list.
*
* @return list of modifications.
*/
- List<WriteCommand> getModifications();
+ List<VisitableCommand> getModifications();
/**
* Adds a modification to the local modification list.
@@ -59,14 +59,14 @@
* @param command command to add to list. Should not be null.
* @throws NullPointerException if the command to be added is null.
*/
- void addLocalModification(WriteCommand command);
+ void addLocalModification(VisitableCommand command);
/**
* Returns all modifications that have been invoked with the LOCAL cache mode option. These will also be in the standard modification list.
*
* @return list of LOCAL modifications, or an empty list.
*/
- List<WriteCommand> getLocalModifications();
+ List<VisitableCommand> getLocalModifications();
/**
* Adds the node that has been removed in the scope of the current transaction.
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-10-08 14:34:05 UTC (rev 6875)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-10-08 14:58:36 UTC (rev 6876)
@@ -24,20 +24,13 @@
import org.jboss.cache.config.Option;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.cache.util.Immutables;
-import org.jboss.starobrno.commands.WriteCommand;
+import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.mvcc.MVCCEntry;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* A transaction context specially geared to dealing with MVCC.
@@ -60,11 +53,11 @@
/**
* List<ReversibleCommand> of modifications ({@link org.jboss.cache.commands.WriteCommand}). They will be replicated on TX commit
*/
- private List<WriteCommand> modificationList;
+ private List<VisitableCommand> modificationList;
/**
* A list of modifications that have been encountered with a LOCAL mode option. These will be removed from the modification list during replication.
*/
- private List<WriteCommand> localModifications;
+ private List<VisitableCommand> localModifications;
/**
* LinkedHashSet of locks acquired by the transaction. We use a LinkedHashSet because we need efficient Set semantics
@@ -167,27 +160,27 @@
for (MVCCEntry e : entries) lookedUpEntries.put(e.getKey(), e);
}
- public void addModification(WriteCommand command)
+ public void addModification(VisitableCommand command)
{
if (command == null) return;
- if (modificationList == null) modificationList = new LinkedList<WriteCommand>();
+ if (modificationList == null) modificationList = new LinkedList<VisitableCommand>();
modificationList.add(command);
}
- public List<WriteCommand> getModifications()
+ public List<VisitableCommand> getModifications()
{
if (modificationList == null) return Collections.emptyList();
return modificationList;
}
- public void addLocalModification(WriteCommand command)
+ public void addLocalModification(VisitableCommand command)
{
if (command == null) throw new NullPointerException("Command is null!");
- if (localModifications == null) localModifications = new LinkedList<WriteCommand>();
+ if (localModifications == null) localModifications = new LinkedList<VisitableCommand>();
localModifications.add(command);
}
- public List<WriteCommand> getLocalModifications()
+ public List<VisitableCommand> getLocalModifications()
{
if (localModifications == null) return Collections.emptyList();
return localModifications;
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/CallInterceptor.java (from rev 6858, core/branches/flat/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/CallInterceptor.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/CallInterceptor.java 2008-10-08 14:58:36 UTC (rev 6876)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.interceptors;
+
+
+import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.commands.tx.CommitCommand;
+import org.jboss.starobrno.commands.tx.PrepareCommand;
+import org.jboss.starobrno.commands.tx.RollbackCommand;
+import org.jboss.starobrno.commands.write.ClearCommand;
+import org.jboss.starobrno.commands.write.PutKeyValueCommand;
+import org.jboss.starobrno.commands.write.RemoveCommand;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.interceptors.base.CommandInterceptor;
+import org.jboss.starobrno.transaction.GlobalTransaction;
+
+import javax.transaction.Transaction;
+
+/**
+ * Always at the end of the chain, directly in front of the cache. Simply calls into the cache using reflection.
+ * If the call resulted in a modification, add the Modification to the end of the modification list
+ * keyed by the current transaction.
+ * <p/>
+ * Although always added to the end of an optimistically locked chain as well, calls should not make it down to
+ * this interceptor unless it is a call the OptimisticNodeInterceptor knows nothing about.
+ *
+ * @author Bela Ban
+ * @version $Id$
+ */
+public class CallInterceptor extends CommandInterceptor
+{
+ private boolean notOptimisticLocking;
+
+ @Start
+ protected void start()
+ {
+ notOptimisticLocking = false;
+ }
+
+ @Override
+ public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+ {
+ if (trace) log.trace("Suppressing invocation of method handlePrepareCommand.");
+ return null;
+ }
+
+ @Override
+ public Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+ {
+ if (trace) log.trace("Suppressing invocation of method handleCommitCommand.");
+ return null;
+ }
+
+ @Override
+ public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+ {
+ if (trace) log.trace("Suppressing invocation of method handleRollbackCommand.");
+ return null;
+ }
+
+ @Override
+ public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
+ {
+ if (trace) log.trace("Executing command: " + command + ".");
+ return invokeCommand(ctx, command);
+ }
+
+ private Object invokeCommand(InvocationContext ctx, ReplicableCommand command)
+ throws Throwable
+ {
+ Object retval;
+ try
+ {
+ retval = command.perform(ctx);
+ }
+ catch (Throwable t)
+ {
+ Transaction tx = ctx.getTransaction();
+ if (ctx.isValidTransaction())
+ {
+ tx.setRollbackOnly();
+ }
+ throw t;
+ }
+ return retval;
+ }
+
+ @Override
+ public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ {
+ return handleAlterCacheMethod(ctx, command);
+ }
+
+ @Override
+ public Object visitClearCommand(InvocationContext ctx, ClearCommand command) throws Throwable
+ {
+ return handleAlterCacheMethod(ctx, command);
+ }
+
+ @Override
+ public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) throws Throwable
+ {
+ return handleAlterCacheMethod(ctx, command);
+ }
+
+ /**
+ * only add the modification to the modification list if we are using pessimistic locking.
+ * Optimistic locking calls *should* not make it this far down the interceptor chain, but just
+ * in case a method has been invoked that the OptimisticNodeInterceptor knows nothing about, it will
+ * filter down here.
+ */
+ private Object handleAlterCacheMethod(InvocationContext ctx, VisitableCommand command)
+ throws Throwable
+ {
+ Object result = invokeCommand(ctx, command);
+ if (notOptimisticLocking && ctx.isValidTransaction())
+ {
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+ if (gtx == null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("didn't find GlobalTransaction for " + ctx.getTransaction() + "; won't add modification to transaction list");
+ }
+ }
+ else
+ {
+ ctx.getTransactionContext().addModification(command);
+ }
+ }
+ return result;
+ }
+}
\ No newline at end of file
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java 2008-10-08 14:34:05 UTC (rev 6875)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java 2008-10-08 14:58:36 UTC (rev 6876)
@@ -26,8 +26,8 @@
import org.jboss.starobrno.commands.AbstractVisitor;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.factories.annotations.Inject;
-import org.jboss.starobrno.context.InvocationContext;
/**
* This is the base class for all interceptors to extend, and implements the {@link org.jboss.cache.commands.Visitor} interface
17 years, 2 months
JBoss Cache SVN: r6875 - in core/branches/flat/src/main/java/org/jboss/starobrno: loader and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2008-10-08 10:34:05 -0400 (Wed, 08 Oct 2008)
New Revision: 6875
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java
core/branches/flat/src/main/java/org/jboss/starobrno/loader/
core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
Log:
Initial work on cache loader
Added: core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java 2008-10-08 14:34:05 UTC (rev 6875)
@@ -0,0 +1,239 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno;
+
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.buddyreplication.GravitateResult;
+import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.loader.CacheLoader;
+import org.jboss.cache.loader.CacheLoaderManager;
+import org.jboss.cache.marshall.Marshaller;
+import org.jboss.cache.notifications.Notifier;
+import org.jboss.cache.statetransfer.StateTransferManager;
+import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.context.InvocationContext;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A more detailed interface to {@link Cache}, which is used when writing plugins for or extending JBoss Cache. A reference
+ * to this interface should only be obtained when it is passed in to your code, for example when you write an
+ * {@link org.jboss.cache.interceptors.base.CommandInterceptor} or {@link CacheLoader}.
+ * <p/>
+ * <B><I>You should NEVER attempt to directly cast a {@link Cache} instance to this interface. In future, the implementation may not allow it.</I></B>
+ * <p/>
+ * This interface contains overridden method signatures of some methods from {@link Cache}, overridden to ensure return
+ * types of {@link Node} are replaced with {@link NodeSPI}.
+ * <p/>
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @see NodeSPI
+ * @see Cache
+ * @see org.jboss.cache.loader.CacheLoader
+ * @since 2.0.0
+ */
+@ThreadSafe
+public interface CacheSPI<K, V> extends Cache<K, V>
+{
+ /**
+ * Retrieves a reference to a running {@link javax.transaction.TransactionManager}, if one is configured.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return a TransactionManager
+ */
+ TransactionManager getTransactionManager();
+
+ /**
+ * Retrieves the current Interceptor chain.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return an immutable {@link List} of {@link org.jboss.cache.interceptors.base.CommandInterceptor}s configured for this cache, or
+ * <code>null</code> if {@link Cache#create() create()} has not been invoked
+ * and the interceptors thus do not exist.
+ */
+ List<CommandInterceptor> getInterceptorChain();
+
+ /**
+ * Retrieves an instance of a {@link Marshaller}, which is capable of
+ * converting Java objects to bytestreams and back in an efficient manner, which is
+ * also interoperable with bytestreams produced/consumed by other versions of JBoss
+ * Cache.
+ * <p/>
+ * The use of this marshaller is the <b>recommended</b> way of creating efficient,
+ * compatible, byte streams from objects.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return an instance of {@link Marshaller}
+ */
+ Marshaller getMarshaller();
+
+ /**
+ * Adds a custom interceptor to the interceptor chain, at specified position, where the first interceptor in the chain
+ * is at position 0 and the last one at getInterceptorChain().size() - 1.
+ *
+ * @param i the interceptor to add
+ * @param position the position to add the interceptor
+ */
+ void addInterceptor(CommandInterceptor i, int position);
+
+ /**
+ * Adds a custom interceptor to the interceptor chain, after an instance of the specified interceptor type. Throws a
+ * cache exception if it cannot find an interceptor of the specified type.
+ *
+ * @param i interceptor to add
+ * @param afterInterceptor interceptor type after which to place custom interceptor
+ */
+ void addInterceptor(CommandInterceptor i, Class<? extends CommandInterceptor> afterInterceptor);
+
+ /**
+ * Removes the interceptor at a specified position, where the first interceptor in the chain
+ * is at position 0 and the last one at getInterceptorChain().size() - 1.
+ *
+ * @param position the position at which to remove an interceptor
+ */
+ void removeInterceptor(int position);
+
+ /**
+ * Removes the interceptor of specified type.
+ *
+ * @param interceptorType type of interceptor to remove
+ */
+ void removeInterceptor(Class<? extends CommandInterceptor> interceptorType);
+
+ /**
+ * Retrieves the current CacheCacheLoaderManager instance associated with the current Cache instance.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return Retrieves a reference to the currently configured {@link org.jboss.cache.loader.CacheLoaderManager} if one or more cache loaders are configured, null otherwise.
+ */
+ CacheLoaderManager getCacheLoaderManager();
+
+ /**
+ * Retrieves the current BuddyManager instance associated with the current Cache instance.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return an instance of {@link BuddyManager} if buddy replication is enabled, null otherwise.
+ */
+ BuddyManager getBuddyManager();
+
+ /**
+ * Retrieves the current TransactionTable instance associated with the current Cache instance.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return the current {@link TransactionTable}
+ */
+ TransactionTable getTransactionTable();
+
+ /**
+ * Gets a handle of the RPC manager.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return the {@link org.jboss.cache.RPCManager} configured.
+ */
+ Object getRPCManager();
+
+ /**
+ * Retrieves the current StateTransferManager instance associated with the current Cache instance.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return the current {@link org.jboss.cache.statetransfer.StateTransferManager}
+ */
+ StateTransferManager getStateTransferManager();
+
+ /**
+ * Retrieves the current Notifier instance associated with the current Cache instance.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return the notifier attached with this instance of the cache. See {@link org.jboss.cache.notifications.Notifier}, a class
+ * that is responsible for emitting notifications to registered CacheListeners.
+ */
+ Notifier getNotifier();
+
+ /**
+ * @return the name of the cluster. Null if running in local mode.
+ */
+ String getClusterName();
+
+ /**
+ * Returns the global transaction for this local transaction.
+ * Optionally creates a new global transaction if it does not exist.
+ *
+ * @param tx the current transaction
+ * @param createIfNotExists if true creates a new transaction if none exists
+ * @return a GlobalTransaction
+ */
+ GlobalTransaction getCurrentTransaction(Transaction tx, boolean createIfNotExists);
+
+ /**
+ * 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
+ */
+ GlobalTransaction getCurrentTransaction();
+
+ /**
+ * Used with buddy replication's data gravitation interceptor. If marshalling is necessary, ensure that the cache is
+ * configured to use {@link org.jboss.cache.config.Configuration#useRegionBasedMarshalling} and the {@link org.jboss.cache.Region}
+ * pertaining to the Fqn passed in is activated, and has an appropriate ClassLoader.
+ *
+ * @param fqn the fqn to gravitate
+ * @param searchBuddyBackupSubtrees if true, buddy backup subtrees are searched and if false, they are not.
+ * @param ctx
+ * @return a GravitateResult which contains the data for the gravitation
+ */
+ GravitateResult gravitateData(K key, boolean searchBuddyBackupSubtrees, InvocationContext ctx);
+
+ /**
+ * Returns the component registry associated with this cache instance.
+ *
+ * @see org.jboss.cache.factories.ComponentRegistry
+ */
+ ComponentRegistry getComponentRegistry();
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java 2008-10-08 14:34:05 UTC (rev 6875)
@@ -0,0 +1,241 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.loader;
+
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.List;
+import java.util.Map;
+
+import net.jcip.annotations.ThreadSafe;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.loader.AbstractCacheLoader;
+
+/**
+ * A {@link org.jboss.cache.loader.CacheLoader} implementation persists and load keys to and from
+ * secondary storage, such as a database or filesystem. Typically,
+ * implementations store a series of keys and values (an entire {@link Map})
+ * under a single {@link Fqn}. Loading and saving properties of an entire
+ * {@link Map} should be atomic.
+ * <p/>
+ * Lifecycle: First an instance of the loader is created, then the
+ * configuration ({@link #setConfig(org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig)}) and cache ({@link
+ * #setCache(CacheSPI)}) are set. After this, {@link #create()} is called.
+ * Then {@link #start()} is called. When re-deployed, {@link #stop()} will be
+ * called, followed by another {@link #start()}. Finally, when shut down,
+ * {@link #destroy()} is called, after which the loader is unusable.
+ * <p/>
+ * An {@link org.jboss.cache.loader.AbstractCacheLoader} is provided as a convenient starting place
+ * when implementing your own {@link org.jboss.cache.loader.CacheLoader}.
+ * <p/>
+ * It is important to note that all implementations are thread safe, as concurrent reads and writes, potentially even to
+ * the same {@link Fqn}, are possible.
+ * <p/>
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @see CacheSPI
+ * @see org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig
+ * @see org.jboss.cache.loader.AbstractCacheLoader
+ * @since 2.0.0
+ */
+@ThreadSafe
+public interface CacheLoader<K, V>
+{
+ /**
+ * Sets the configuration. This is called before {@link #create()} and {@link #start()}.
+ *
+ * @param config May be an instance of the {@link org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig} base
+ * class, in which case the cache loader should use the
+ * {@link org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig#getProperties()}
+ * method to find configuration information. Alternatively,
+ * may be a type-specific subclass of {@link org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig},
+ * if there is one.
+ */
+ void setConfig(IndividualCacheLoaderConfig config);
+
+ /**
+ * Gets the configuration.
+ *
+ * @return the configuration, represented by a {@link org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig} object.
+ */
+ IndividualCacheLoaderConfig getConfig();
+
+ /**
+ * Sets the {@link CacheSPI} that is maintaining this CacheLoader.
+ * This method allows this CacheLoader to set a reference to the {@link CacheSPI}.
+ * This method is called be called after the CacheLoader instance has been constructed.
+ *
+ * @param c The cache on which this loader works
+ */
+ void setCache(CacheSPI<K,V> c);
+
+ /**
+ * Returns all keys and values from the persistent store, given a {@link org.jboss.cache.Fqn}
+ *
+ * @param name the {@link Fqn} to search for.
+ * @return Map<Object,Object> keys and values for the given node. Returns
+ * null if the node is not found. If the node is found but has no
+ * attributes, this method returns an empty Map.
+ */
+ V get(Object key) throws Exception;
+
+
+ /**
+ * Returns true if the CacheLoader has a node with a {@link Fqn}.
+ *
+ * @return true if node exists, false otherwise
+ */
+ boolean exists(Object key) throws Exception;
+
+ /**
+ * Puts a key and value into the attribute map of a given node. If the
+ * node does not exist, all parent nodes from the root down are created
+ * automatically. Returns the old value.
+ */
+ V put(Object key, V value) throws Exception;
+
+ /**
+ * Removes the given key and value from the attributes of the given node.
+ * Does nothing if the node doesn't exist
+ * Returns the removed value.
+ */
+ V remove(Object key, V value) throws Exception;
+
+ /**
+ * Removes the given node and all its subnodes, does nothing if the node does not exist.
+ *
+ * @param fqn the {@link Fqn} of the node
+ */
+ void remove(Object key) throws Exception;
+
+
+ /**
+ * Prepares a list of modifications. For example, for a DB-based CacheLoader:
+ * <ol>
+ * <li>Create a local (JDBC) transaction
+ * <li>Associate the local transaction with <code>tx</code> (tx is the key)
+ * <li>Execute the corresponding SQL statements against the DB (statements derived from modifications)
+ * </ol>
+ * For non-transactional CacheLoader (e.g. file-based), the implementation could attempt to implement its own transactional
+ * logic, attempting to write data to a temp location (or memory) and writing it to the proper location upon commit.
+ *
+ * @param tx The transaction, indended to be used by implementations as an identifier of the transaction (and not necessarily a JTA {@link javax.transaction.Transaction} object)
+ * @param modifications A {@link List} containing {@link org.jboss.cache.Modification}s, for the given transaction
+ * @param one_phase Persist immediately and (for example) commit the local JDBC transaction as well. When true,
+ * we won't get a {@link #commit(Object)} or {@link #rollback(Object)} method call later
+ * @throws Exception
+ */
+ void prepare(Object tx, List<Modification> modifications, boolean one_phase) throws Exception;
+
+ /**
+ * Commits the transaction. A DB-based CacheLoader would look up the local
+ * JDBC transaction asociated with <code>tx</code> and commit that
+ * transaction. Non-transactional CacheLoaders could simply write the data
+ * that was previously saved transiently under the given <code>tx</code>
+ * key, to (for example) a file system.
+ * <p/>
+ * <b>Note</b> this only holds if the previous prepare() did not define <pre>one_phase=true</pre>
+ *
+ * @param tx transaction to commit
+ */
+ void commit(Object tx) throws Exception;
+
+ /**
+ * Rolls the transaction back. A DB-based CacheLoader would look up the
+ * local JDBC transaction asociated with <code>tx</code> and roll back that
+ * transaction.
+ *
+ * @param tx transaction to roll back
+ */
+ void rollback(Object tx);
+
+ /**
+ * Fetches the entire state for this cache from secondary storage (disk, database)
+ * and writes it to a provided ObjectOutputStream. State written to the provided
+ * ObjectOutputStream parameter is used for initialization of a new CacheImpl instance.
+ * When the state gets transferred to the new cache instance its cacheloader calls
+ * {@link #storeEntireState(ObjectInputStream)}
+ * <p/>
+ * Implementations of this method should not catch any exception or close the
+ * given ObjectOutputStream parameter. In order to ensure cacheloader interoperability
+ * contents of the cache are written to the ObjectOutputStream as a sequence of
+ * NodeData objects.
+ * <p/>
+ * Default implementation is provided by {@link AbstractCacheLoader} and ensures cacheloader
+ * interoperability. Implementors are encouraged to consider extending AbstractCacheLoader
+ * prior to implementing completely custom cacheloader.
+ *
+ * @param os ObjectOutputStream to write state
+ * @see AbstractCacheLoader#loadEntireState(ObjectOutputStream)
+ * @see org.jboss.cache.marshall.NodeData
+ */
+ void loadEntireState(ObjectOutputStream os) throws Exception;
+
+ /**
+ * Stores the entire state for this cache by reading it from a provided ObjectInputStream.
+ * The state was provided to this cache by calling {@link #loadEntireState(ObjectOutputStream)}}
+ * on some other cache instance. State currently in storage gets overwritten.
+ * <p/>
+ * Implementations of this method should not catch any exception or close the
+ * given ObjectInputStream parameter. In order to ensure cacheloader interoperability
+ * contents of the cache are read from the ObjectInputStream as a sequence of
+ * NodeData objects.
+ * <p/>
+ * Default implementation is provided by {@link AbstractCacheLoader} and ensures cacheloader
+ * interoperability. Implementors are encouraged to consider extending AbstractCacheLoader
+ * prior to implementing completely custom cacheloader.
+ *
+ * @param is ObjectInputStream to read state
+ * @see AbstractCacheLoader#storeEntireState(ObjectInputStream)
+ * @see org.jboss.cache.marshall.NodeData
+ */
+ void storeEntireState(ObjectInputStream is) throws Exception;
+
+ /**
+ * Lifecycle method, called when the cache loader is created.
+ *
+ * @throws java.lang.Exception
+ */
+ void create() throws java.lang.Exception;
+
+ /**
+ * Lifecycle method, called when the cache loader is started.
+ *
+ * @throws java.lang.Exception
+ */
+ void start() throws java.lang.Exception;
+
+ /**
+ * Lifecycle method, called when the cache loader is stopped.
+ */
+ void stop();
+
+ /**
+ * Lifecycle method, called when the cache loader is destroyed.
+ */
+ void destroy();
+
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
___________________________________________________________________
Name: svn:executable
+ *
17 years, 2 months
JBoss Cache SVN: r6874 - in core/branches/flat/src/main/java/org/jboss/starobrno: notifier and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-08 10:00:29 -0400 (Wed, 08 Oct 2008)
New Revision: 6874
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/notifier/
core/branches/flat/src/main/java/org/jboss/starobrno/notifier/Notifier.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifier/event/
core/branches/flat/src/main/java/org/jboss/starobrno/notifier/event/NodeModifiedEvent.java
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
Log:
_____ ____ ____
\/__/\ \ \ \L\ \\ \ \/\_\
_\ \ \ \ _ <'\ \ \/_/_
/\ \_\ \ \ \L\ \\ \ \L\ \
\ \____/\ \____/ \ \____/
\/___/ \/___/ \/___/
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-10-08 13:59:44 UTC (rev 6873)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-10-08 14:00:29 UTC (rev 6874)
@@ -21,9 +21,16 @@
*/
package org.jboss.starobrno;
-import org.jboss.cache.config.Configuration;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.invocation.InvocationContextContainer;
+import org.jboss.starobrno.commands.CommandsFactory;
+import org.jboss.starobrno.commands.read.SizeCommand;
+import org.jboss.starobrno.commands.read.GetKeyValueCommand;
+import org.jboss.starobrno.commands.write.*;
+import org.jboss.starobrno.interceptors.InterceptorChain;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.notifier.Notifier;
+import org.jboss.util.NotImplementedException;
import java.util.Collection;
import java.util.Map;
@@ -35,49 +42,53 @@
public class CacheDelegate implements Cache
{
protected InvocationContextContainer invocationContextContainer;
+ protected CommandsFactory commandsFactory;
+ protected InterceptorChain invoker;
+ protected Configuration config;
+ protected Notifier notifier;
public Object putIfAbsent(Object key, Object value)
{
- // PutKeyValueCommand
- InvocationContext ctx = invocationContextContainer.get();
-
- return null;
+ PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(key, value);
+ command.setPutIfAbsent(true);
+ return invoker.invoke(buildCtx(), command);
}
public boolean remove(Object key, Object value)
{
- // RemoveCommand
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ RemoveCommand command = commandsFactory.buildRemoveCommand(key, value);
+ return (Boolean)invoker.invoke(buildCtx(), command);
}
public boolean replace(Object key, Object oldValue, Object newValue)
{
- // ReplaceCommand
- return false;
+ ReplaceCommand command = commandsFactory.buildReplaceCommand(key, oldValue, newValue);
+ return (Boolean)invoker.invoke(buildCtx(), command);
}
public Object replace(Object key, Object value)
{
- // ReplaceCommand
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ ReplaceCommand command = commandsFactory.buildReplaceCommand(key, value, null);
+ return invoker.invoke(buildCtx(), command);
}
public int size()
{
- // SizeCommand
- return 0; //To change body of implemented methods use File | Settings | File Templates.
+ SizeCommand command = commandsFactory.buildSizeCommand();
+ return (Integer) invoker.invoke(buildCtx(), command);
}
public boolean isEmpty()
{
- // SizeCommand
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ SizeCommand command = commandsFactory.buildSizeCommand();
+ int size = (Integer) invoker.invoke(buildCtx(), command);
+ return size == 0;
}
public boolean containsKey(Object key)
{
- // GetKeyValueCommand
- return false; //To change body of implemented methods use File | Settings | File Templates.
+ GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key);
+ return (Boolean) invoker.invoke(buildCtx(), command);
}
public boolean containsValue(Object value)
@@ -87,32 +98,32 @@
public Object get(Object key)
{
- // GetKeyValueCommand
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key);
+ return invoker.invoke(buildCtx(), command);
}
public Object put(Object key, Object value)
{
- // PutKeyValueCommand
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(key, value);
+ return invoker.invoke(buildCtx(), command);
}
public Object remove(Object key)
{
- // RemoveCommand
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ RemoveCommand command = commandsFactory.buildRemoveCommand(key, null);
+ return invoker.invoke(buildCtx(), command);
}
public void putAll(Map t)
{
- // PutMapCommand
- //To change body of implemented methods use File | Settings | File Templates.
+ PutMapCommand command = commandsFactory.buildPutMapCommand(t);
+ invoker.invoke(buildCtx(), command);
}
public void clear()
{
- // ClearCommand
- //To change body of implemented methods use File | Settings | File Templates.
+ ClearCommand command = commandsFactory.buildClearCommand();
+ invoker.invoke(buildCtx(), command);
}
public Set keySet()
@@ -130,44 +141,41 @@
throw new UnsupportedOperationException("Go away");
}
- protected void cacheStatusCheck(org.jboss.cache.InvocationContext ctx)
- {
- if (invocationContextContainer == null) throw new IllegalStateException("The cache has been destroyed!");
- }
-
public void evict(Object key)
{
- // EvictCommand
+ EvictCommand command = commandsFactory.buildEvictCommand(key);
+ invoker.invoke(buildCtx(), command);
}
public Configuration getConfiguration()
{
- return null; //TODO: Autogenerated. Implement me properly
+ return config;
}
public void addCacheListener(Object listener)
{
- //TODO: Autogenerated. Implement me properly
+ notifier.addCacheListener(listener);
}
public void removeCacheListener(Object listener)
{
- //TODO: Autogenerated. Implement me properly
+ notifier.removeCacheListener(listener);
}
public Set getCacheListeners()
{
- return null; //TODO: Autogenerated. Implement me properly
+ return notifier.getCacheListeners();
}
- public org.jboss.cache.InvocationContext getInvocationContext()
+ public InvocationContext getInvocationContext()
{
- return null; //TODO: Autogenerated. Implement me properly
+ return invocationContextContainer.get();
}
- public void setInvocationContext(org.jboss.cache.InvocationContext ctx)
+ public void setInvocationContext(InvocationContext ctx)
{
- //TODO: Autogenerated. Implement me properly
+ if (ctx == null) invocationContextContainer.remove();
+ else invocationContextContainer.set(ctx);
}
public void start()
@@ -179,4 +187,9 @@
{
//TODO: Autogenerated. Implement me properly
}
+
+ private InvocationContext buildCtx()
+ {
+ return invocationContextContainer.get();
+ }
}
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/notifier/Notifier.java (from rev 6858, core/branches/flat/src/main/java/org/jboss/cache/notifications/Notifier.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifier/Notifier.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifier/Notifier.java 2008-10-08 14:00:29 UTC (rev 6874)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.notifier;
+
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.notifier.event.NodeModifiedEvent;
+import org.jboss.cache.buddyreplication.BuddyGroup;
+import org.jgroups.View;
+
+import javax.transaction.Transaction;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Public interface with all allowed notifications.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 2.2
+ */
+public interface Notifier
+{
+ /**
+ * Notifies all registered listeners of a nodeCreated event.
+ */
+ void notifyNodeCreated(Object key, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a nodeModified event.
+ */
+ void notifyNodeModified(Object key, boolean pre, NodeModifiedEvent.ModificationType modificationType, Map data, InvocationContext ctx);
+
+ /**
+ * When notifying about node modifications, in many scenarios there is a need of building a new Map object. If no
+ * listeners are registered for notification then it is pointless building this object - so guard the notification
+ * with this call.
+ */
+ public boolean shouldNotifyOnNodeModified();
+
+ /**
+ * Notifies all registered listeners of a nodeRemoved event.
+ */
+ void notifyNodeRemoved(Object key, boolean pre, Map data, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a nodeVisited event.
+ */
+ void notifyNodeVisited(Object key, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a nodeEvicted event.
+ */
+ void notifyNodeEvicted(Object key, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a nodeInvalidated event.
+ */
+ void notifyNodeInvalidated(Object key, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a nodeLoaded event.
+ */
+ void notifyNodeLoaded(Object key, boolean pre, Map data, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a nodeActivated event.
+ */
+ void notifyNodeActivated(Object key, boolean pre, Map data, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a nodePassivated event.
+ */
+ void notifyNodePassivated(Object key, boolean pre, Map data, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a viewChange event. Note that viewChange notifications are ALWAYS sent
+ * immediately.
+ */
+ void notifyViewChange(View view, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a buddy group change event. Note that buddy group change notifications are ALWAYS sent
+ * immediately.
+ *
+ * @param buddyGroup buddy group to set
+ * @param pre if true, this has occured before the buddy group message is broadcast to the cluster
+ */
+ void notifyBuddyGroupChange(BuddyGroup buddyGroup, boolean pre);
+
+ /**
+ * Notifies all registered listeners of a transaction completion event.
+ *
+ * @param transaction the transaction that has just completed
+ * @param successful if true, the transaction committed. If false, this is a rollback event
+ */
+ void notifyTransactionCompleted(Transaction transaction, boolean successful, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a transaction registration event.
+ *
+ * @param transaction the transaction that has just completed
+ */
+ void notifyTransactionRegistered(Transaction transaction, InvocationContext ctx);
+
+ void notifyCacheBlocked(boolean pre);
+
+ void notifyCacheUnblocked(boolean pre);
+
+ /**
+ * Adds a cache listener to the list of cache listeners registered.
+ *
+ * @param listener
+ */
+ void addCacheListener(Object listener);
+
+ /**
+ * Removes a cache listener from the list of cache listeners registered.
+ *
+ * @param listener
+ */
+ void removeCacheListener(Object listener);
+
+ /**
+ * @return Retrieves an (unmodifiable) set of cache listeners registered.
+ */
+ Set<Object> getCacheListeners();
+}
\ No newline at end of file
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/notifier/event/NodeModifiedEvent.java (from rev 6858, core/branches/flat/src/main/java/org/jboss/cache/notifications/event/NodeModifiedEvent.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifier/event/NodeModifiedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifier/event/NodeModifiedEvent.java 2008-10-08 14:00:29 UTC (rev 6874)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.notifier.event;
+
+import org.jboss.cache.notifications.event.NodeEvent;
+
+import java.util.Map;
+
+/**
+ * This event is passed in to any method annotated with {@link org.jboss.cache.notifications.annotation.NodeModified}
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public interface NodeModifiedEvent extends NodeEvent
+{
+ /**
+ * Different cache modification types.
+ */
+ static enum ModificationType
+ {
+ PUT_DATA, REMOVE_DATA, PUT_MAP
+ }
+
+ /**
+ * @return an instance of the {@link org.jboss.cache.notifications.event.NodeModifiedEvent.ModificationType} enumeration.
+ */
+ ModificationType getModificationType();
+
+ /**
+ * When called with <tt>isPre() == true</tt>, this is the initial state of the {@link org.jboss.cache.Node}
+ * before modification.
+ * <p/>
+ * When called with <tt>isPre() == false</tt>, this depends on the value of <tt>getModificationType()</tt>:
+ * <ul>
+ * <li><b>{@link ModificationType#PUT_DATA}</b>: Map contains the single key/value pair that was added or modified.</li>
+ * <li><b>{@link ModificationType#REMOVE_DATA}</b>: Map contains the key/value pairs that were removed.</li>
+ * <li><b>{@link ModificationType#PUT_MAP}</b>: Map contains the new state of the {@link org.jboss.cache.Node} following modification. This map includes modified key/value
+ * pairs as well as any that were not affected.</li>
+ * </ul>
+ * <p/>
+ * Implementations interested in seeing the difference in the node data in the {@link ModificationType#PUT_MAP} case
+ * can cache the value of <tt>getData()</tt> map passed when <tt>isPre() == true</tt>, and then when the
+ * <tt>isPre() == false</tt> callback is received, pass the cached map and the new result of <tt>getData()</tt> to
+ * {@link org.jboss.cache.util.Util#diffNodeData(java.util.Map,java.util.Map)}
+ *
+ * @return Unmodifiable {@link java.util.Map}; will not be <code>null</code>. See description above.
+ */
+ Map getData();
+}
\ No newline at end of file
17 years, 2 months
JBoss Cache SVN: r6873 - in core/branches/flat/src/main/java/org/jboss/starobrno/commands: read and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-08 09:59:44 -0400 (Wed, 08 Oct 2008)
New Revision: 6873
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java
Log:
_____ ____ ____
\/__/\ \ \ \L\ \\ \ \/\_\
_\ \ \ \ _ <'\ \ \/_/_
/\ \_\ \ \ \L\ \\ \ \L\ \
\ \____/\ \____/ \ \____/
\/___/ \/___/ \/___/
Added: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java 2008-10-08 13:59:44 UTC (rev 6873)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.commands;
+
+import org.jboss.starobrno.commands.write.*;
+import org.jboss.starobrno.commands.read.SizeCommand;
+import org.jboss.starobrno.commands.read.GetKeyValueCommand;
+
+import java.util.Map;
+
+/**
+ * @author Mircea.Markus(a)jboss.com
+ */
+public interface CommandsFactory
+{
+ PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value);
+
+ RemoveCommand buildRemoveCommand(Object key, Object value);
+
+ ReplaceCommand buildReplaceCommand(Object key, Object oldValue, Object newValue);
+
+ SizeCommand buildSizeCommand();
+
+ GetKeyValueCommand buildGetKeyValueCommand(Object key);
+
+ PutMapCommand buildPutMapCommand(Map t);
+
+ ClearCommand buildClearCommand();
+
+ EvictCommand buildEvictCommand(Object key);
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-08 13:59:44 UTC (rev 6873)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.commands;
+
+import org.jboss.starobrno.commands.write.*;
+import org.jboss.starobrno.commands.read.SizeCommand;
+import org.jboss.starobrno.commands.read.GetKeyValueCommand;
+import org.jboss.starobrno.DataContainer;
+import org.jboss.starobrno.notifier.Notifier;
+
+import java.util.Map;
+
+/**
+ * @author Mircea.Markus(a)jboss.com
+ */
+public class CommandsFactoryImpl implements CommandsFactory
+{
+ private DataContainer dataContainer;
+ private Notifier notifier;
+
+ public PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value)
+ {
+ return new PutKeyValueCommand(key, value, false);
+ }
+
+ public RemoveCommand buildRemoveCommand(Object key, Object value)
+ {
+ return new RemoveCommand(key, value);
+ }
+
+ public ReplaceCommand buildReplaceCommand(Object key, Object oldValue, Object newValue)
+ {
+ return new ReplaceCommand(key, oldValue, newValue);
+ }
+
+ public SizeCommand buildSizeCommand()
+ {
+ return new SizeCommand(dataContainer);
+ }
+
+ public GetKeyValueCommand buildGetKeyValueCommand(Object key)
+ {
+ return new GetKeyValueCommand(key, notifier);
+ }
+
+ public PutMapCommand buildPutMapCommand(Map map)
+ {
+ return new PutMapCommand(map);
+ }
+
+ public ClearCommand buildClearCommand()
+ {
+ return new ClearCommand();
+ }
+
+ public EvictCommand buildEvictCommand(Object key)
+ {
+ return new EvictCommand();
+ }
+}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java 2008-10-08 13:26:45 UTC (rev 6872)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java 2008-10-08 13:59:44 UTC (rev 6873)
@@ -23,10 +23,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.starobrno.commands.Visitor;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.mvcc.MVCCEntry;
+import org.jboss.starobrno.notifier.Notifier;
/**
* // TODO: MANIK: Document this
@@ -70,7 +70,7 @@
Object result = entry.getValue();
if (trace) log.trace("Found value " + result);
// if (sendNodeEvent) notifier.notifyNodeVisited(fqn, false, ctx);
- return result;
+ return result;
}
public int getCommandId()
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java 2008-10-08 13:26:45 UTC (rev 6872)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java 2008-10-08 13:59:44 UTC (rev 6873)
@@ -46,7 +46,7 @@
return visitor.visitSizeCommand(ctx, this);
}
- public Object perform(InvocationContext ctx) throws Throwable
+ public Integer perform(InvocationContext ctx) throws Throwable
{
return container.size();
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java 2008-10-08 13:26:45 UTC (rev 6872)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java 2008-10-08 13:59:44 UTC (rev 6873)
@@ -37,7 +37,15 @@
public static final int METHOD_ID = 3;
protected Object value;
+ protected boolean putIfAbsent;
+ public PutKeyValueCommand(Object key, Object value, boolean putIfAbsent)
+ {
+ super(key);
+ this.value = value;
+ this.putIfAbsent = putIfAbsent;
+ }
+
public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
{
return visitor.visitPutKeyValueCommand(ctx, this);
@@ -65,4 +73,14 @@
key = parameters[0];
value = parameters[1];
}
+
+ public boolean isPutIfAbsent()
+ {
+ return putIfAbsent;
+ }
+
+ public void setPutIfAbsent(boolean putIfAbsent)
+ {
+ this.putIfAbsent = putIfAbsent;
+ }
}
\ No newline at end of file
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java 2008-10-08 13:26:45 UTC (rev 6872)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/RemoveCommand.java 2008-10-08 13:59:44 UTC (rev 6873)
@@ -34,12 +34,20 @@
{
public static final int METHOD_ID = 6;
+ protected Object value;
+
+ public RemoveCommand(Object key, Object value)
+ {
+ super(key);
+ this.value = value;
+ }
+
public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
{
return visitor.visitRemoveCommand(ctx, this);
}
- public Object perform(InvocationContext ctx) throws Throwable
+ public Boolean perform(InvocationContext ctx) throws Throwable
{
MVCCEntry e = ctx.lookupEntry(key);
if (e == null || e.isNullEntry()) return false;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java 2008-10-08 13:26:45 UTC (rev 6872)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/ReplaceCommand.java 2008-10-08 13:59:44 UTC (rev 6873)
@@ -53,7 +53,7 @@
return visitor.visitReplaceCommand(ctx, this);
}
- public Object perform(InvocationContext ctx) throws Throwable
+ public Boolean perform(InvocationContext ctx) throws Throwable
{
MVCCEntry e = ctx.lookupEntry(key);
if (e == null || e.isNullEntry()) return false;
17 years, 2 months