JBoss Cache SVN: r4519 - core/trunk/src/main/docbook/userguide/en/modules.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2007-09-28 13:59:43 -0400 (Fri, 28 Sep 2007)
New Revision: 4519
Modified:
core/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml
Log:
JBCACHE-1099
Modified: core/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml 2007-09-28 15:10:46 UTC (rev 4518)
+++ core/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml 2007-09-28 17:59:43 UTC (rev 4519)
@@ -649,7 +649,9 @@
<listitem>
<emphasis>cache.jdbc.table.name</emphasis>
- the name
- of the table. The default value is 'jbosscache'.
+ of the table. Can be prepended with schema name for the given table:
+ <schema_name>.<table_name>.
+ The default value is 'jbosscache'.
</listitem>
<listitem>
17 years, 3 months
JBoss Cache SVN: r4518 - core/trunk/src/test/resources.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2007-09-28 11:10:46 -0400 (Fri, 28 Sep 2007)
New Revision: 4518
Modified:
core/trunk/src/test/resources/log4j.xml
Log:
rollback to prev version
Modified: core/trunk/src/test/resources/log4j.xml
===================================================================
--- core/trunk/src/test/resources/log4j.xml 2007-09-28 15:07:03 UTC (rev 4517)
+++ core/trunk/src/test/resources/log4j.xml 2007-09-28 15:10:46 UTC (rev 4518)
@@ -69,15 +69,15 @@
-->
<category name="org.jboss.cache">
- <priority value="DEBUG"/>
+ <priority value="INFO"/>
</category>
<category name="org.jboss.tm">
- <priority value="DEBUG"/>
+ <priority value="ERROR"/>
</category>
<category name="org.jgroups">
- <priority value="DEBUG"/>
+ <priority value="ERROR"/>
</category>
<!-- ======================= -->
@@ -85,8 +85,9 @@
<!-- ======================= -->
<root>
- <priority value="DEBUG"/>
+ <priority value="ERROR"/>
<appender-ref ref="CONSOLE"/>
+ <!--<appender-ref ref="FILE"/>-->
</root>
</log4j:configuration>
17 years, 3 months
JBoss Cache SVN: r4517 - in core/trunk/src: test/java/org/jboss/cache/loader and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2007-09-28 11:07:03 -0400 (Fri, 28 Sep 2007)
New Revision: 4517
Modified:
core/trunk/src/main/resources/cache-jdbc.properties
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
Log:
http://jira.jboss.com/jira/browse/JBCACHE-1099
Modified: core/trunk/src/main/resources/cache-jdbc.properties
===================================================================
--- core/trunk/src/main/resources/cache-jdbc.properties 2007-09-27 15:56:20 UTC (rev 4516)
+++ core/trunk/src/main/resources/cache-jdbc.properties 2007-09-28 15:07:03 UTC (rev 4517)
@@ -1,5 +1,9 @@
##
# Standard JBC table properties
+# The table name can also be prepended with schema name for the given table.
+# Even though there is an Sql92 standard syntax for this: <schema_name>.<table name>
+#schema has different meanings accross various DBMS: Oracle - user name; PointBase - database name
+# Microsoft SQL Server & DB2 - schema name corresponds to the catalog owner
cache.jdbc.table.name=jbosscache
cache.jdbc.table.create=true
cache.jdbc.table.drop=false
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2007-09-27 15:56:20 UTC (rev 4516)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2007-09-28 15:07:03 UTC (rev 4517)
@@ -10,6 +10,7 @@
import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail;
+import org.testng.annotations.Test;
import java.util.Properties;
@@ -29,6 +30,7 @@
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
* @version <tt>$Revision$</tt>
*/
+@Test(groups = {"functional"})
public class JDBCCacheLoaderTest extends CacheLoaderTestsBase
{
protected void configureCache() throws Exception
@@ -40,7 +42,8 @@
"cache.jdbc.user=" + prop.getProperty("cache.jdbc.user") + "\n" +
"cache.jdbc.password=" + prop.getProperty("cache.jdbc.password") + "\n" +
"cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
- "cache.jdbc.sql-concat=" + prop.getProperty("cache.jdbc.sql-concat");
+ "cache.jdbc.sql-concat=" + prop.getProperty("cache.jdbc.sql-concat") + "\n" +
+ "cache.jdbc.table.name=" + prop.getProperty("cache.jdbc.table.name");
cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
"org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false));
17 years, 3 months
JBoss Cache SVN: r4516 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2007-09-27 11:56:20 -0400 (Thu, 27 Sep 2007)
New Revision: 4516
Modified:
core/trunk/src/main/java/org/jboss/cache/Region.java
Log:
Modified: core/trunk/src/main/java/org/jboss/cache/Region.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Region.java 2007-09-27 05:34:14 UTC (rev 4515)
+++ core/trunk/src/main/java/org/jboss/cache/Region.java 2007-09-27 15:56:20 UTC (rev 4516)
@@ -168,8 +168,6 @@
*
* @param fqn Fqn of the node.
* @see #unmarkNodeCurrentlyInUse(Fqn)
- * @deprecated you are now able to specify Node.setResident which has (almost -> i.e. you cannot specify a timeout)
- * the same behavior. That metod also replicates the change clusterwise
*/
void markNodeCurrentlyInUse(Fqn fqn, long timeout);
@@ -178,8 +176,6 @@
*
* @param fqn Fqn of the node.
* @see #markNodeCurrentlyInUse(Fqn,long)
- * @deprecated you are now able to specify Node.isResident which has (almost) the same behavior. That metod also
- * replicates the change clusterwise
*/
void unmarkNodeCurrentlyInUse(Fqn fqn);
17 years, 3 months
JBoss Cache SVN: r4515 - in core/trunk/src: main/java/org/jboss/cache/marshall and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2007-09-27 01:34:14 -0400 (Thu, 27 Sep 2007)
New Revision: 4515
Modified:
core/trunk/src/main/java/org/jboss/cache/AbstractNode.java
core/trunk/src/main/java/org/jboss/cache/Node.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java
core/trunk/src/main/resources/META-INF/local-lru-eviction-service.xml
core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
core/trunk/src/test/resources/log4j.xml
Log:
JBCACHE-1154
Modified: core/trunk/src/main/java/org/jboss/cache/AbstractNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/AbstractNode.java 2007-09-27 02:48:37 UTC (rev 4514)
+++ core/trunk/src/main/java/org/jboss/cache/AbstractNode.java 2007-09-27 05:34:14 UTC (rev 4515)
@@ -20,7 +20,7 @@
/**
* Under this key the {@link #resident} attribute will be keept within the data map.
*/
- protected static final String INTERNAL_IS_RESIDENT = "_jbosscache.internal.resident";
+ public static final String JBOSSCACHE_INTERNAL_RESIDENT = "_jbosscache.internal.resident";
public boolean isDeleted()
{
@@ -51,10 +51,10 @@
{
if (!resident)
{
- remove((K)INTERNAL_IS_RESIDENT);
+ remove((K)JBOSSCACHE_INTERNAL_RESIDENT);
} else
{
- put((K)INTERNAL_IS_RESIDENT, (V)"True");
+ put((K)JBOSSCACHE_INTERNAL_RESIDENT, (V)Boolean.TRUE);
}
}
@@ -62,7 +62,7 @@
public boolean isResident()
{
//hack - see setResident internals for details
- return "True".equals(get((K)INTERNAL_IS_RESIDENT));
+ return Boolean.TRUE.equals(get((K)JBOSSCACHE_INTERNAL_RESIDENT));
}
Modified: core/trunk/src/main/java/org/jboss/cache/Node.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Node.java 2007-09-27 02:48:37 UTC (rev 4514)
+++ core/trunk/src/main/java/org/jboss/cache/Node.java 2007-09-27 05:34:14 UTC (rev 4515)
@@ -282,7 +282,8 @@
* "keep LRU 10 nodes" - the resident nodes won't be counted within those 10 nodes,
* and also won't be evicted when the threshold is reached.
* N.B. calling this method won't have any effect on node's eviction, e.g. we won't consider this node as being
- * 'used' in a LRU scenario
+ * 'used' in a LRU scenario. If the cache is used in a replicated environment then the resident property is also
+ * replicated across the cluster(just like attribute map)
*/
boolean isResident();
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2007-09-27 02:48:37 UTC (rev 4514)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2007-09-27 05:34:14 UTC (rev 4515)
@@ -34,11 +34,6 @@
private static final int INDENT = 4;
/**
- * Metadata-entry needed for refering the node's metadata.
- */
- public static final String JBOSSCACHE_INTERNAL_RESIDENT = "_jbosscache.internal.resident";
-
- /**
* Debug log.
*/
private static Log log = LogFactory.getLog(UnversionedNode.class);
@@ -717,7 +712,7 @@
public boolean isResidentDirect()
{
- return getDataDirect().containsKey(AbstractNode.INTERNAL_IS_RESIDENT);
+ return getDataDirect().containsKey(JBOSSCACHE_INTERNAL_RESIDENT);
}
public Set<NodeSPI<K, V>> getChildrenDirect(boolean includeMarkedForRemoval)
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java 2007-09-27 02:48:37 UTC (rev 4514)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java 2007-09-27 05:34:14 UTC (rev 4515)
@@ -92,16 +92,4 @@
return ret.toString();
}
-
-
- public Object invoke(Object object) throws Throwable
- {
- return super.invoke(object); //To change body of overridden methods use File | Settings | File Templates.
- }
-
-
- public Object invoke(Object object, Object[] objects) throws Throwable
- {
- return super.invoke(object, objects); //To change body of overridden methods use File | Settings | File Templates.
- }
}
Modified: core/trunk/src/main/resources/META-INF/local-lru-eviction-service.xml
===================================================================
--- core/trunk/src/main/resources/META-INF/local-lru-eviction-service.xml 2007-09-27 02:48:37 UTC (rev 4514)
+++ core/trunk/src/main/resources/META-INF/local-lru-eviction-service.xml 2007-09-27 05:34:14 UTC (rev 4515)
@@ -106,11 +106,6 @@
<attribute name="timeToLiveSeconds">8</attribute>
<attribute name="maxAgeSeconds">10</attribute>
</region>
- <region name="/residentNodesTest">
- <attribute name="maxNodes">3</attribute>
- <attribute name="timeToLiveSeconds">800000</attribute>
- <attribute name="maxAgeSeconds">100000</attribute>
- </region>
</config>
</attribute>
</mbean>
Modified: core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2007-09-27 02:48:37 UTC (rev 4514)
+++ core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2007-09-27 05:34:14 UTC (rev 4515)
@@ -6,15 +6,19 @@
import static org.testng.Assert.*;
import static org.testng.Assert.assertNotNull;
import org.jboss.cache.*;
+import org.jboss.cache.eviction.LRUConfiguration;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.loader.DummyCacheLoader;
import org.jboss.cache.lock.IsolationLevel;
+import javax.transaction.TransactionManager;
import java.util.List;
import java.util.ArrayList;
@@ -31,27 +35,45 @@
private CacheImpl<Object, Object> cache;
private final String TEST_NODES_ROOT = "residentNodesTest";
+ private Configuration cacheConfig;
+ private Cache[] caches = {};
@BeforeMethod(alwaysRun = true)
public void setUp()
{
- cache = (CacheImpl<Object, Object>) DefaultCacheFactory.getInstance().createCache("META-INF/local-lru-eviction-service.xml", false);
+ cacheConfig = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
+ cache = (CacheImpl<Object, Object>) DefaultCacheFactory.getInstance().createCache(cacheConfig, false);
cache.getConfiguration().getEvictionConfig().setWakeupIntervalSeconds(1);
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- CacheLoaderConfig.IndividualCacheLoaderConfig indCLConfig = new CacheLoaderConfig.IndividualCacheLoaderConfig();
- indCLConfig.setClassName(DummyInMemoryCacheLoader.class.getName());
- List<CacheLoaderConfig.IndividualCacheLoaderConfig> indCLConfigs = new ArrayList<CacheLoaderConfig.IndividualCacheLoaderConfig>();
- indCLConfigs.add(indCLConfig);
- CacheLoaderConfig cacheLoaderConfig = new CacheLoaderConfig();
- cacheLoaderConfig.setIndividualCacheLoaderConfigs(indCLConfigs);
- cache.getConfiguration().setCacheLoaderConfig(cacheLoaderConfig);
+ createNewRegion();
cache.start();
}
+ /**
+ * Setting up a new region for our purposes.
+ */
+ private void createNewRegion()
+ {
+ EvictionConfig evConfig = cache.getConfiguration().getEvictionConfig();
+ EvictionRegionConfig evRegConfig = new EvictionRegionConfig();
+ evRegConfig.setRegionFqn(Fqn.fromString("/"+TEST_NODES_ROOT));
+ evRegConfig.setEventQueueSize(3);
+ LRUConfiguration lruConfig = new LRUConfiguration();
+ lruConfig.setMaxAgeSeconds(100000);
+ lruConfig.setTimeToLiveSeconds(100000);
+ lruConfig.setMaxNodes(3);
+ evRegConfig.setEvictionPolicyConfig(lruConfig);
+ evConfig.getEvictionRegionConfigs().add(evRegConfig);
+ //end setting up region stuff
+ }
+
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
cache.stop();
+ for (Cache c : caches)
+ {
+ if (c!= null) c.stop();
+ }
}
/**
@@ -168,7 +190,7 @@
{
Cache first = DefaultCacheFactory.getInstance().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC));
Cache second = DefaultCacheFactory.getInstance().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC));
- Cache[] caches = {first, second};
+ caches = new Cache[]{first, second};
TestingUtil.blockUntilViewsReceived(caches, 5000);
System.out.println("Caches started!");
@@ -182,17 +204,13 @@
second.getRoot().getChild(fqn).setResident(false);
assertFalse(first.getRoot().getChild(fqn).isResident());
-
- for (Cache c : caches)
- {
- c.stop();
- }
}
/**
* If a node is marked as resident, and a get is made on that given node then an VISITED event would normally be
* added to the eviction queue. In a LRU scenario, this will cause another node to be evicted given that the size of
* the eviction queue is bounded. This test makes sure that this scenario will not hapen.
+ * //todo - check why it does not work fine in suite, but works individually
*/
public void testNoEvictionEventsForResidentNodes() throws InterruptedException
{
@@ -215,7 +233,7 @@
cache.get(getSubFqn("/a"));
cache.get(getSubFqn("/b"));
- Thread.sleep(3000);//so that eviction is activated
+ TestingUtil.sleepThread(3000);//so that eviction is activated
//a and b should exist as those were marked resident. Also they shouldn't be caunted as nodes in the eviction
// queue
@@ -243,7 +261,8 @@
public void testNoStringCache()
{
CacheFactory<Integer, Float> cacheFactory = DefaultCacheFactory.getInstance();
- Cache<Integer, Float> cache = cacheFactory.createCache("META-INF/local-lru-eviction-service.xml", true);
+ Configuration cc = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
+ Cache<Integer, Float> cache = cacheFactory.createCache(cc, true);
cache.put(getSubFqn("/a"), 1, 5.3f);
cache.put(getSubFqn("/b"), 1, 2.3f);
cache.put(getSubFqn("/c"), 1, 7.3f);
@@ -258,14 +277,18 @@
/**
* When using optimistic locking , check to see that at commit time the cache is successfully updated.
+ * //todo - this test fails only if setup is called prio it. Should be something with nesting tx context- take a look
*/
public void testResidencyAndOptimisticLocking() throws Exception
{
- javax.transaction.TransactionManager txManager = new DummyTransactionManagerLookup().getTransactionManager();
- CacheImpl cache = (CacheImpl<Object, Object>) DefaultCacheFactory.getInstance().createCache("META-INF/optimistic-eviction.xml");
+ Configuration config = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
+ config.setNodeLockingOptimistic(true);
+ CacheImpl cache = (CacheImpl<Object, Object>) DefaultCacheFactory.getInstance().createCache(config, true);
+// CacheImpl cache = (CacheImpl<Object, Object>) DefaultCacheFactory.getInstance().createCache("META-INF/optimistic-eviction.xml");
+
cache.put(Fqn.fromString("/a/b"), "key", "value");
-
+ TransactionManager txManager = cache.getTransactionManager();
txManager.begin();
cache.getRoot().getChild(Fqn.fromString("/a/b")).setResident(true);
txManager.rollback();
Modified: core/trunk/src/test/resources/log4j.xml
===================================================================
--- core/trunk/src/test/resources/log4j.xml 2007-09-27 02:48:37 UTC (rev 4514)
+++ core/trunk/src/test/resources/log4j.xml 2007-09-27 05:34:14 UTC (rev 4515)
@@ -69,15 +69,15 @@
-->
<category name="org.jboss.cache">
- <priority value="INFO"/>
+ <priority value="DEBUG"/>
</category>
<category name="org.jboss.tm">
- <priority value="ERROR"/>
+ <priority value="DEBUG"/>
</category>
<category name="org.jgroups">
- <priority value="ERROR"/>
+ <priority value="DEBUG"/>
</category>
<!-- ======================= -->
@@ -85,9 +85,8 @@
<!-- ======================= -->
<root>
- <priority value="ERROR"/>
- <appender-ref ref="CONSOLE"/>
- <!--<appender-ref ref="FILE"/>-->
+ <priority value="DEBUG"/>
+ <appender-ref ref="CONSOLE"/>
</root>
</log4j:configuration>
17 years, 3 months
JBoss Cache SVN: r4514 - core/trunk/src/test/java/org/jboss/cache/api.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2007-09-26 22:48:37 -0400 (Wed, 26 Sep 2007)
New Revision: 4514
Modified:
core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
Log:
JBCACHE-1154 added unit test for optimistic locking
Modified: core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2007-09-26 23:42:55 UTC (rev 4513)
+++ core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2007-09-27 02:48:37 UTC (rev 4514)
@@ -6,6 +6,7 @@
import static org.testng.Assert.*;
import static org.testng.Assert.assertNotNull;
import org.jboss.cache.*;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.config.CacheLoaderConfig;
@@ -137,7 +138,7 @@
{
Fqn theNode = Fqn.fromString("/a_a");
cache.put(theNode, "key", "value");
-
+
assertEquals(cache.getRoot().getChild(theNode).getKeys().size(), 1);
cache.getRoot().getChild(theNode).setResident(true);
@@ -255,6 +256,38 @@
cache.stop();
}
+ /**
+ * When using optimistic locking , check to see that at commit time the cache is successfully updated.
+ */
+ public void testResidencyAndOptimisticLocking() throws Exception
+ {
+ javax.transaction.TransactionManager txManager = new DummyTransactionManagerLookup().getTransactionManager();
+ CacheImpl cache = (CacheImpl<Object, Object>) DefaultCacheFactory.getInstance().createCache("META-INF/optimistic-eviction.xml");
+
+ cache.put(Fqn.fromString("/a/b"), "key", "value");
+
+ txManager.begin();
+ cache.getRoot().getChild(Fqn.fromString("/a/b")).setResident(true);
+ txManager.rollback();
+ assertFalse(cache.getRoot().getChild(Fqn.fromString("/a/b")).isResident());
+
+ txManager.begin();
+ cache.getRoot().getChild(Fqn.fromString("/a/b")).setResident(true);
+ txManager.commit();
+ assertTrue(cache.getRoot().getChild(Fqn.fromString("/a/b")).isResident());
+
+ try
+ {
+ if (cache.getTransactionManager().getTransaction() != null)
+ {
+ cache.getTransactionManager().rollback();
+ }
+ } finally
+ {
+ cache.stop();
+ }
+ }
+
private Fqn getSubFqn(String str)
{
return Fqn.fromString("/" + TEST_NODES_ROOT + str);
17 years, 3 months
JBoss Cache SVN: r4513 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2007-09-26 19:42:55 -0400 (Wed, 26 Sep 2007)
New Revision: 4513
Removed:
core/trunk/src/main/java/org/jboss/cache/MetadataNodeWrapper.java
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
Log:
JBCACHE-1154 - this would fix some tests roken indirectly. Also added some unit tests.
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-09-26 19:56:51 UTC (rev 4512)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-09-26 23:42:55 UTC (rev 4513)
@@ -281,7 +281,7 @@
*/
public NodeSPI<K, V> getRoot()
{
- return MetadataNodeWrapper.wrapNodeData(root);
+ return root;
}
/**
Deleted: core/trunk/src/main/java/org/jboss/cache/MetadataNodeWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/MetadataNodeWrapper.java 2007-09-26 19:56:51 UTC (rev 4512)
+++ core/trunk/src/main/java/org/jboss/cache/MetadataNodeWrapper.java 2007-09-26 23:42:55 UTC (rev 4513)
@@ -1,420 +0,0 @@
-package org.jboss.cache;
-
-import org.jboss.cache.Node;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.lock.NodeLock;
-import org.jboss.cache.transaction.GlobalTransaction;
-
-import java.util.*;
-
-/**
- * Metadata information from class <tt>Node</tt> (metadata = all configuration information except attribute map,
- * e.g. Node.isResident) is internally also held in the internal attribute map. The role of this class is not the
- * expose those internal map information to the end user - so it wraps such a node and expose it to the the user
- * removing wrapped info.
- *
- * @author <a href="mailto:mircea.markus@jboss.com">Mircea Markus</a>
- * @since 2.1.0
- */
-public class MetadataNodeWrapper implements NodeSPI
-{
-
- public static final String JBOSSCACHE_INTERNAL_RESIDENT = "_jbosscache.internal.resident";
-
- private Node wrappedNode;
-
- public MetadataNodeWrapper(Node wrappedNode)
- {
- this.wrappedNode = wrappedNode;
- }
-
- public NodeSPI getParent()
- {
- return wrapNodeData(wrappedNode);
- }
-
- public Set getChildren()
- {
- Iterator it = wrappedNode.getChildren().iterator();
- Set result = new HashSet();
- while (it.hasNext())
- {
- result.add(wrapNodeData((Node) it.next()));
- }
- return Collections.unmodifiableSet(result);
- }
-
- public Set getChildrenNames()
- {
- return wrappedNode.getChildrenNames();
- }
-
- public Map getData()
- {
- Map realData = wrappedNode.getData();
- if (!realData.containsKey(JBOSSCACHE_INTERNAL_RESIDENT))
- {
- return realData;
- } else
- {
- Map clearedData = new HashMap(realData);
- clearedData.remove(JBOSSCACHE_INTERNAL_RESIDENT);
- return Collections.unmodifiableMap(clearedData);
- }
- }
-
- public Set getKeys()
- {
- Set realSet = wrappedNode.getKeys();
- if (!realSet.contains(JBOSSCACHE_INTERNAL_RESIDENT))
- {
- return realSet;
- } else
- {
- Set clearedData = new HashSet(realSet);
- clearedData.remove(JBOSSCACHE_INTERNAL_RESIDENT);
- return Collections.unmodifiableSet(clearedData);
- }
- }
-
- public Fqn getFqn()
- {
- return wrappedNode.getFqn();
- }
-
- public Node addChild(Fqn f)
- {
- return wrapNodeData(wrappedNode.addChild(f));
- }
-
- public boolean removeChild(Fqn f)
- {
- return wrappedNode.removeChild(f);
- }
-
- public boolean removeChild(Object childName)
- {
- return wrappedNode.removeChild(childName);
- }
-
- public Node getChild(Fqn f)
- {
- return wrapNodeData(wrappedNode.getChild(f));
- }
-
- public Node getChild(Object name)
- {
- return wrapNodeData(wrappedNode.getChild(name));
- }
-
- public Object put(Object key, Object value)
- {
- return wrappedNode.put(key, value);
- }
-
- public Object putIfAbsent(Object key, Object value)
- {
- return wrappedNode.putIfAbsent(key, value);
- }
-
- public Object replace(Object key, Object value)
- {
- return wrappedNode.replace(key, value);
- }
-
- public boolean replace(Object key, Object oldValue, Object newValue)
- {
- return wrappedNode.replace(key, oldValue, newValue);
- }
-
- public void putAll(Map map)
- {
- wrappedNode.putAll(map);
- }
-
- public void replaceAll(Map map)
- {
- wrappedNode.replaceAll(map);
- }
-
- public Object get(Object key)
- {
- return wrappedNode.get(key);
- }
-
- public Object remove(Object key)
- {
- if (JBOSSCACHE_INTERNAL_RESIDENT.equals(key))
- {
- throw new IllegalArgumentException("The '" + JBOSSCACHE_INTERNAL_RESIDENT + "' is an reserved key, please " +
- "refrain using it!");
- }
- return wrappedNode.remove(key);
- }
-
- public void clearData()
- {
- if (wrappedNode.get(JBOSSCACHE_INTERNAL_RESIDENT) == null)
- {
- wrappedNode.clearData();
- } else
- {
- Iterator it = wrappedNode.getKeys().iterator();
- while (it.hasNext())
- {
- Object key = it.next();
- if (!JBOSSCACHE_INTERNAL_RESIDENT.equals(key))
- {
- wrappedNode.remove(key);
- }
- }
- }
- }
-
- public int dataSize()
- {
- if (wrappedNode.getKeys().contains(JBOSSCACHE_INTERNAL_RESIDENT))
- {
- return wrappedNode.dataSize() - 1;
- }
- return wrappedNode.dataSize();
- }
-
- public boolean hasChild(Fqn f)
- {
- return wrappedNode.hasChild(f);
- }
-
- public boolean hasChild(Object o)
- {
- return wrappedNode.hasChild(o);
- }
-
- public boolean isValid()
- {
- return wrappedNode.isValid();
- }
-
- public boolean isResident()
- {
- return wrappedNode.isResident();
- }
-
- public void setResident(boolean resident)
- {
- wrappedNode.setResident(resident);
- }
-
- public static MetadataNodeWrapper wrapNodeData(Node node)
- {
- if (node == null)
- {
- return null;
- }
- if (node instanceof MetadataNodeWrapper)
- {
- return (MetadataNodeWrapper) node;
- } else
- {
- return new MetadataNodeWrapper(node);
- }
- }
-
-
- public boolean isChildrenLoaded()
- {
- return ((NodeSPI) wrappedNode).isChildrenLoaded();
- }
-
- public void setChildrenLoaded(boolean loaded)
- {
- ((NodeSPI) wrappedNode).setChildrenLoaded(loaded);
- }
-
- public boolean isDataLoaded()
- {
- return ((NodeSPI) wrappedNode).isDataLoaded();
- }
-
- public void setDataLoaded(boolean dataLoaded)
- {
- ((NodeSPI) wrappedNode).setDataLoaded(dataLoaded);
- }
-
- public Map getChildrenMapDirect()
- {
- return ((NodeSPI) wrappedNode).getChildrenMapDirect();
- }
-
- public void setChildrenMapDirect(Map children)
- {
- ((NodeSPI) wrappedNode).setChildrenMapDirect(children);
- }
-
- public NodeSPI getOrCreateChild(Object name, GlobalTransaction tx)
- {
- return ((NodeSPI) wrappedNode).getOrCreateChild(name, tx);
- }
-
- public NodeLock getLock()
- {
- return ((NodeSPI) wrappedNode).getLock();
- }
-
- public void setFqn(Fqn f)
- {
- ((NodeSPI) wrappedNode).setFqn(f);
- }
-
- public boolean isDeleted()
- {
- return ((NodeSPI) wrappedNode).isDeleted();
- }
-
- public void markAsDeleted(boolean marker)
- {
- ((NodeSPI) wrappedNode).markAsDeleted(marker);
- }
-
- public void markAsDeleted(boolean marker, boolean recursive)
- {
- ((NodeSPI) wrappedNode).markAsDeleted(marker, recursive);
- }
-
- public void addChild(Object nodeName, Node nodeToAdd)
- {
- ((NodeSPI) wrappedNode).addChild(nodeName, nodeToAdd);
- }
-
- public void printDetails(StringBuffer sb, int indent)
- {
- ((NodeSPI) wrappedNode).printDetails(sb, indent);
- }
-
- public void print(StringBuffer sb, int indent)
- {
- ((NodeSPI) wrappedNode).print(sb, indent);
- }
-
- public void setVersion(DataVersion version)
- {
- ((NodeSPI) wrappedNode).setVersion(version);
- }
-
- public DataVersion getVersion()
- {
- return ((NodeSPI) wrappedNode).getVersion();
- }
-
- public Set getChildrenDirect()
- {
- return ((NodeSPI) wrappedNode).getChildrenDirect();
- }
-
- public void removeChildrenDirect()
- {
- ((NodeSPI) wrappedNode).removeChildrenDirect();
- }
-
- public Set getChildrenDirect(boolean includeMarkedAsDeleted)
- {
- return ((NodeSPI) wrappedNode).getChildrenDirect(includeMarkedAsDeleted);
- }
-
- public NodeSPI getChildDirect(Object childName)
- {
- return ((NodeSPI) wrappedNode).getChildDirect(childName);
- }
-
- public NodeSPI addChildDirect(Fqn childName)
- {
- return ((NodeSPI) wrappedNode).addChildDirect(childName);
- }
-
- public void addChildDirect(NodeSPI child)
- {
- ((NodeSPI) wrappedNode).addChildDirect(child);
- }
-
- public NodeSPI getChildDirect(Fqn childName)
- {
- return ((NodeSPI) wrappedNode).getChildDirect(childName);
- }
-
- public boolean removeChildDirect(Fqn fqn)
- {
- return ((NodeSPI) wrappedNode).removeChildDirect(fqn);
- }
-
- public boolean removeChildDirect(Object childName)
- {
- return ((NodeSPI) wrappedNode).removeChildDirect(childName);
- }
-
- public Object removeDirect(Object key)
- {
- return ((NodeSPI) wrappedNode).removeDirect(key);
- }
-
- public Object putDirect(Object key, Object value)
- {
- return ((NodeSPI) wrappedNode).putDirect(key, value);
- }
-
- public void putAllDirect(Map data)
- {
- ((NodeSPI) wrappedNode).putAllDirect(data);
- }
-
- public Map getDataDirect()
- {
- return ((NodeSPI) wrappedNode).getDataDirect();
- }
-
- public Object getDirect(Object key)
- {
- return ((NodeSPI) wrappedNode).getDirect(key);
- }
-
- public void clearDataDirect()
- {
- ((NodeSPI) wrappedNode).clearDataDirect();
- }
-
- public Set getKeysDirect()
- {
- return ((NodeSPI) wrappedNode).getKeysDirect();
- }
-
- public Set getChildrenNamesDirect()
- {
- return ((NodeSPI) wrappedNode).getChildrenNamesDirect();
- }
-
- public CacheSPI getCache()
- {
- return ((NodeSPI) wrappedNode).getCache();
- }
-
- public boolean hasChildrenDirect()
- {
- return ((NodeSPI) wrappedNode).hasChildrenDirect();
- }
-
- public boolean isResidentDirect()
- {
- return ((NodeSPI) wrappedNode).isResidentDirect();
- }
-
-
- public boolean isLockForChildInsertRemove()
- {
- return wrappedNode.isLockForChildInsertRemove();
- }
-
- public void setLockForChildInsertRemove(boolean lockForChildInsertRemove)
- {
- wrappedNode.setLockForChildInsertRemove(lockForChildInsertRemove);
- }
-}
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2007-09-26 19:56:51 UTC (rev 4512)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2007-09-26 23:42:55 UTC (rev 4513)
@@ -15,11 +15,7 @@
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -38,6 +34,11 @@
private static final int INDENT = 4;
/**
+ * Metadata-entry needed for refering the node's metadata.
+ */
+ public static final String JBOSSCACHE_INTERNAL_RESIDENT = "_jbosscache.internal.resident";
+
+ /**
* Debug log.
*/
private static Log log = LogFactory.getLog(UnversionedNode.class);
@@ -69,6 +70,7 @@
private final Map<K, V> data = new HashMap<K, V>();
private boolean lockForChildInsertRemove;
+ private int realSize;
/**
* Constructs a new node with an FQN of Root.
@@ -194,8 +196,17 @@
public Map<K, V> getData()
{
if (cache == null) return Collections.emptyMap();
- return cache.getData(getFqn());
-
+ Map<K, V> realData = cache.getData(getFqn());
+ if (!realData.containsKey(JBOSSCACHE_INTERNAL_RESIDENT))
+ {
+ return realData;
+ }
+ else
+ {
+ Map clearedData = new HashMap(realData);
+ clearedData.remove(JBOSSCACHE_INTERNAL_RESIDENT);
+ return Collections.unmodifiableMap(clearedData);
+ }
/*
Map<K, V> dMap = new HashMap<K, V>();
for (K k : cache.getKeys(getFqn()))
@@ -378,7 +389,13 @@
public void clearData()
{
+ Map realData = getDataDirect();
+ boolean isResident = isResidentDirect();
cache.removeData(getFqn());
+ if (isResident)
+ {
+ setResident(true);
+ }
}
public void clearDataDirect()
@@ -423,8 +440,21 @@
public Set<K> getKeys()
{
- Set<K> keys = cache.getKeys(getFqn());
- return keys == null ? Collections.<K>emptySet() : Collections.<K>unmodifiableSet(keys);
+ Set<K> realSet = cache.getKeys(getFqn());
+ if (realSet == null)
+ {
+ Collections.<K>emptySet();
+ }
+ if (!realSet.contains(JBOSSCACHE_INTERNAL_RESIDENT))
+ {
+ return realSet;
+ }
+ else
+ {
+ Set clearedData = new HashSet(realSet);
+ clearedData.remove(JBOSSCACHE_INTERNAL_RESIDENT);
+ return Collections.unmodifiableSet(clearedData);
+ }
}
public Set<K> getKeysDirect()
@@ -494,7 +524,11 @@
public int dataSize()
{
- return cache.getKeys(getFqn()).size();
+ realSize = cache.getKeys(getFqn()).size();
+ if (getDataDirect().containsKey(JBOSSCACHE_INTERNAL_RESIDENT)) {
+ realSize--;
+ }
+ return realSize;
}
public boolean removeChild(Object childName)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2007-09-26 19:56:51 UTC (rev 4512)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2007-09-26 23:42:55 UTC (rev 4513)
@@ -199,7 +199,7 @@
Fqn fqn = (Fqn) args[0];
Object key = args[1];
/*see hack comment inside PutKeyEvictionMethodHandler.extractEvictedEventNode */
- if (MetadataNodeWrapper.JBOSSCACHE_INTERNAL_RESIDENT.equals(key)) {
+ if (UnversionedNode.JBOSSCACHE_INTERNAL_RESIDENT.equals(key)) {
return null;
}
if (fqn != null && key != null
@@ -341,7 +341,7 @@
//by the eviction code, which would result in events being produced -> that when consumed would produce
// other events (due to call to Node.isResident). The isResidentDirect call cannot be used here
//the resident information is stored in the node attributes map directly
- if (MetadataNodeWrapper.JBOSSCACHE_INTERNAL_RESIDENT.equals(key))
+ if (UnversionedNode.JBOSSCACHE_INTERNAL_RESIDENT.equals(key))
{
return null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2007-09-26 19:56:51 UTC (rev 4512)
+++ core/trunk/src/test/java/org/jboss/cache/api/ResidentNodesTest.java 2007-09-26 23:42:55 UTC (rev 4513)
@@ -88,12 +88,12 @@
}
/**
- * The 'resident' attribute of the node is kept within node's attribute map.
+ * The 'resident' attribute of the Node.getData() is not exposed to the user.
* This information won't be visible to the ouside clients if they are not using the
* resident attribute. This would ensure a 100% backward comatibility. New clients would need to be aware of this
* extra attribute, though.
*/
- public void testInternalStateNotVisibleOutside()
+ public void testInternalStateNotVisibleOutsideOnGet()
{
cache.put(getSubFqn("/a"), "k_a", "v_a");
cache.get(getSubFqn("/a")).setResident(true);
@@ -116,7 +116,50 @@
assertTrue(cache.getRoot().getChild(TEST_NODES_ROOT).getChild("a").isResident());
}
+
/**
+ * When Node.clearData is called the node does not lose its residency metadata.
+ */
+ public void testInternalStateNotVisibleOutsideOnClearData()
+ {
+ Fqn theNode = Fqn.fromString("/a_a");
+ cache.put(theNode, "key", "value");
+ cache.getRoot().getChild(theNode).setResident(true);
+ cache.getRoot().getChild(theNode).clearData();
+ assertFalse(cache.getRoot().getChild(theNode).getKeys().contains("key"));
+ assertTrue(cache.getRoot().getChild(theNode).isResident());
+ }
+
+ /**
+ * When Node.getKeys is called, the given key set does not contain the 'resident' metadata.
+ */
+ public void testInternalStateNotVisibleOutsideOnGetKeys()
+ {
+ Fqn theNode = Fqn.fromString("/a_a");
+ cache.put(theNode, "key", "value");
+
+ assertEquals(cache.getRoot().getChild(theNode).getKeys().size(), 1);
+
+ cache.getRoot().getChild(theNode).setResident(true);
+ assertEquals(cache.getRoot().getChild(theNode).getKeys().size(), 1);
+ }
+
+ /**
+ * When Node.dataSize is called the returned value does not reflect metadata information.
+ */
+ public void testInternalStateNotVisibleOutsideOnDataSize()
+ {
+ Fqn theNode = Fqn.fromString("/a_a");
+ cache.put(theNode, "key", "value");
+
+ assertEquals(cache.getRoot().getChild(theNode).dataSize(), 1);
+
+ cache.getRoot().getChild(theNode).setResident(true);
+ assertEquals(cache.getRoot().getChild(theNode).dataSize(), 1);
+ }
+
+
+ /**
* When replication is on, we want to make sure that the operation will subscribe to the global
* replication strategy.
*/
17 years, 3 months
JBoss Cache SVN: r4512 - core/trunk/src/test/java/org/jboss/cache/lock/pessimistic.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-09-26 15:56:51 -0400 (Wed, 26 Sep 2007)
New Revision: 4512
Modified:
core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java
Log:
Disabled test
Modified: core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java 2007-09-26 18:54:18 UTC (rev 4511)
+++ core/trunk/src/test/java/org/jboss/cache/lock/pessimistic/ConcurrentPutRemoveTest.java 2007-09-26 19:56:51 UTC (rev 4512)
@@ -15,7 +15,7 @@
import javax.transaction.TransactionManager;
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, enabled = false)
public class ConcurrentPutRemoveTest
{
private TransactionManager tm;
17 years, 3 months
JBoss Cache SVN: r4511 - core/tags.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-09-26 14:54:18 -0400 (Wed, 26 Sep 2007)
New Revision: 4511
Added:
core/tags/1.4.1.SP5/
Log:
Tagging 1.4.1.SP5
Copied: core/tags/1.4.1.SP5 (from rev 4510, core/branches/1.4.X)
17 years, 3 months
JBoss Cache SVN: r4510 - in core/branches/1.4.X: docs and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-09-26 14:45:19 -0400 (Wed, 26 Sep 2007)
New Revision: 4510
Modified:
core/branches/1.4.X/build.xml
core/branches/1.4.X/docs/Changelog.txt
core/branches/1.4.X/src/org/jboss/cache/Version.java
Log:
Preparing to tag 1.4.1.SP5
Modified: core/branches/1.4.X/build.xml
===================================================================
--- core/branches/1.4.X/build.xml 2007-09-26 18:41:27 UTC (rev 4509)
+++ core/branches/1.4.X/build.xml 2007-09-26 18:45:19 UTC (rev 4510)
@@ -6,7 +6,7 @@
<property name="module.name" value="JBossCache"/>
<!--We now requires version to have no white space since Ant+JBossAop will sometime choke. -->
- <property name="module.version" value="1.4.1.SP4"/>
+ <property name="module.version" value="1.4.1.SP5"/>
<property name="implementation.url" value="http://www.jboss.com/products/jbosscache"/>
<property file="build.properties"/>
<property name="root.dir" value="${basedir}"/>
Modified: core/branches/1.4.X/docs/Changelog.txt
===================================================================
--- core/branches/1.4.X/docs/Changelog.txt 2007-09-26 18:41:27 UTC (rev 4509)
+++ core/branches/1.4.X/docs/Changelog.txt 2007-09-26 18:45:19 UTC (rev 4510)
@@ -1,5 +1,17 @@
$Id$
+
+Release 1.4.1.SP5 (September 26, 2007)
+======================================
+Patch release on 1.4.1.GA
+
+** Bug
+ * [ JBCACHE-1157 ] Pessimistic Lock Interceptor does not acquite a write lock for remove(Fqn, key)
+ * [ JBCACHE-1167 ] Heuristic outcome (STATUS_UNKNOWN) of transaction not handled properly
+
+** Task
+ * [ JBCACHE-725 ] Reduce the amount of INFO logging
+
Release 1.4.1.SP4 (July 19, 2007)
==================================
Patch release on 1.4.1.GA
Modified: core/branches/1.4.X/src/org/jboss/cache/Version.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/Version.java 2007-09-26 18:41:27 UTC (rev 4509)
+++ core/branches/1.4.X/src/org/jboss/cache/Version.java 2007-09-26 18:45:19 UTC (rev 4510)
@@ -10,9 +10,9 @@
*/
public class Version
{
- public static final String version = "1.4.1.SP4";
+ public static final String version = "1.4.1.SP5";
public static final String codename = "Cayenne";
- public static byte[] version_id = {'0', '1', '4', '1', 'S', 'P', '4'};
+ public static byte[] version_id = {'0', '1', '4', '1', 'S', 'P', '5'};
public static final String cvs = "$Id$";
private static final int MAJOR_SHIFT = 11;
17 years, 3 months