JBoss Cache SVN: r4499 - in cacheloader-migration/trunk: src/test/java/org/jboss/cache/loader and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2007-09-24 13:15:43 -0400 (Mon, 24 Sep 2007)
New Revision: 4499
Modified:
cacheloader-migration/trunk/
cacheloader-migration/trunk/pom.xml
cacheloader-migration/trunk/src/test/java/org/jboss/cache/loader/TransformingJDBCCacheLoaderTest.java
cacheloader-migration/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
Log:
Modified POM to download correct libraries. Correct MarshalledValue class in test case and removed System.out from TestingUtility to get around a bug in SunFire.
Property changes on: cacheloader-migration/trunk
___________________________________________________________________
Name: svn:ignore
+ *.iml
*.ipr
*.iws
jbossdb*
derby.log
target
Modified: cacheloader-migration/trunk/pom.xml
===================================================================
--- cacheloader-migration/trunk/pom.xml 2007-09-21 17:22:30 UTC (rev 4498)
+++ cacheloader-migration/trunk/pom.xml 2007-09-24 17:15:43 UTC (rev 4499)
@@ -28,9 +28,9 @@
</dependency>
<dependency>
- <groupId>org.jboss.aop</groupId>
- <artifactId>jboss-aop</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <groupId>jboss.jbossas.core-libs</groupId>
+ <artifactId>jboss-client</artifactId>
+ <version>4.0.3.SP1</version>
</dependency>
</dependencies>
Modified: cacheloader-migration/trunk/src/test/java/org/jboss/cache/loader/TransformingJDBCCacheLoaderTest.java
===================================================================
--- cacheloader-migration/trunk/src/test/java/org/jboss/cache/loader/TransformingJDBCCacheLoaderTest.java 2007-09-21 17:22:30 UTC (rev 4498)
+++ cacheloader-migration/trunk/src/test/java/org/jboss/cache/loader/TransformingJDBCCacheLoaderTest.java 2007-09-24 17:15:43 UTC (rev 4499)
@@ -6,7 +6,7 @@
*/
package org.jboss.cache.loader;
-import org.jboss.aop.util.MarshalledValue;
+import org.jboss.invocation.MarshalledValue;
import org.jboss.cache.CacheImpl;
import org.jboss.cache.Fqn;
import org.testng.annotations.AfterTest;
Modified: cacheloader-migration/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java
===================================================================
--- cacheloader-migration/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2007-09-21 17:22:30 UTC (rev 4498)
+++ cacheloader-migration/trunk/src/test/java/org/jboss/cache/misc/TestingUtil.java 2007-09-24 17:15:43 UTC (rev 4499)
@@ -364,7 +364,7 @@
File file = new File(directoryName);
if (file.exists())
{
- System.out.println("Deleting file " + file);
+ //System.out.println("Deleting file " + file);
recursivedelete(file);
}
}
16 years, 11 months
JBoss Cache SVN: r4498 - in core/branches/1.4.X: .settings and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2007-09-21 13:22:30 -0400 (Fri, 21 Sep 2007)
New Revision: 4498
Added:
core/branches/1.4.X/.classpath
core/branches/1.4.X/.project
core/branches/1.4.X/.settings/
core/branches/1.4.X/.settings/org.eclipse.jdt.core.prefs
Removed:
core/branches/1.4.X/.settings/org.eclipse.jdt.core.prefs
Log:
Reinstate eclipse settings (Partial revert of 4460)
Copied: core/branches/1.4.X/.classpath (from rev 4459, core/branches/1.4.X/.classpath)
===================================================================
--- core/branches/1.4.X/.classpath (rev 0)
+++ core/branches/1.4.X/.classpath 2007-09-21 17:22:30 UTC (rev 4498)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="tests/functional"/>
+ <classpathentry kind="src" path="tests/perf"/>
+ <classpathentry kind="src" path="tests/stress"/>
+ <classpathentry kind="src" path="tests/interop"/>
+ <classpathentry kind="lib" path="ant-dist/lib/ant.jar"/>
+ <classpathentry kind="lib" path="ant-dist/lib/ant-junit.jar"/>
+ <classpathentry kind="lib" path="ant-dist/lib/ant-launcher.jar"/>
+ <classpathentry kind="lib" path="ant-dist/lib/ant-nodeps.jar"/>
+ <classpathentry kind="lib" path="ant-dist/lib/ant-trax.jar"/>
+ <classpathentry kind="lib" path="ant-dist/lib/ant-xslp.jar"/>
+ <classpathentry kind="lib" path="ant-dist/lib/bsf.jar"/>
+ <classpathentry kind="lib" path="ant-dist/lib/junit.jar"/>
+ <classpathentry kind="lib" path="ant-dist/lib/pretty.jar"/>
+ <classpathentry kind="lib" path="ant-dist/lib/resolver.jar"/>
+ <classpathentry kind="lib" path="lib/bsh-2.0b4.jar"/>
+ <classpathentry kind="lib" path="lib/commons-logging.jar"/>
+ <classpathentry kind="lib" path="lib/concurrent.jar"/>
+ <classpathentry kind="lib" path="lib/derby.jar"/>
+ <classpathentry kind="lib" path="lib/javassist.jar"/>
+ <classpathentry kind="lib" path="lib/jboss-aop.jar"/>
+ <classpathentry kind="lib" path="lib/jboss-common.jar"/>
+ <classpathentry kind="lib" path="lib/jboss-j2ee.jar"/>
+ <classpathentry kind="lib" path="lib/jboss-jmx.jar"/>
+ <classpathentry kind="lib" path="lib/jboss-minimal.jar"/>
+ <classpathentry kind="lib" path="lib/jboss-system.jar"/>
+ <classpathentry kind="lib" path="lib/jdbm-1.0.jar"/>
+ <classpathentry kind="lib" path="lib/jgroups.jar"/>
+ <classpathentry kind="lib" path="lib/junit.jar"/>
+ <classpathentry kind="lib" path="lib/log4j.jar"/>
+ <classpathentry kind="lib" path="lib/qdox.jar"/>
+ <classpathentry kind="lib" path="lib/sleepycat/je.jar"/>
+ <classpathentry kind="lib" path="lib/trove.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="src" path="etc"/>
+ <classpathentry kind="lib" path="lib/jboss-serialization.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Copied: core/branches/1.4.X/.project (from rev 4459, core/branches/1.4.X/.project)
===================================================================
--- core/branches/1.4.X/.project (rev 0)
+++ core/branches/1.4.X/.project 2007-09-21 17:22:30 UTC (rev 4498)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>JBossCache</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Copied: core/branches/1.4.X/.settings (from rev 4459, core/branches/1.4.X/.settings)
Deleted: core/branches/1.4.X/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- core/branches/1.4.X/.settings/org.eclipse.jdt.core.prefs 2007-09-13 16:37:52 UTC (rev 4459)
+++ core/branches/1.4.X/.settings/org.eclipse.jdt.core.prefs 2007-09-21 17:22:30 UTC (rev 4498)
@@ -1,12 +0,0 @@
-#Thu Sep 08 15:02:04 PDT 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.source=1.3
Copied: core/branches/1.4.X/.settings/org.eclipse.jdt.core.prefs (from rev 4459, core/branches/1.4.X/.settings/org.eclipse.jdt.core.prefs)
===================================================================
--- core/branches/1.4.X/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ core/branches/1.4.X/.settings/org.eclipse.jdt.core.prefs 2007-09-21 17:22:30 UTC (rev 4498)
@@ -0,0 +1,12 @@
+#Thu Sep 08 15:02:04 PDT 2005
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
16 years, 11 months
JBoss Cache SVN: r4497 - in core/trunk/src: main/java/org/jboss/cache and 5 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-09-21 09:53:59 -0400 (Fri, 21 Sep 2007)
New Revision: 4497
Added:
core/trunk/src/main/java/org/jboss/cache/loader/ReadOnlyDelegatingCacheLoader.java
Modified:
core/trunk/src/main/docbook/userguide/en/modules/transactions.xml
core/trunk/src/main/java/org/jboss/cache/CacheImpl.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/interceptors/OptimisticValidatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java
Log:
JBCACHE-957 - lockParentForChildInsertRemove now configurable on a per-node basis
JBCACHE-751 - IgnoreModifications to be made available to all cache loaders, not just chained ones.
Modified: core/trunk/src/main/docbook/userguide/en/modules/transactions.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/transactions.xml 2007-09-21 03:15:01 UTC (rev 4496)
+++ core/trunk/src/main/docbook/userguide/en/modules/transactions.xml 2007-09-21 13:53:59 UTC (rev 4497)
@@ -160,6 +160,11 @@
<emphasis>write lock</emphasis>
on the parent node.
</para>
+ <para>
+ In addition to the above, in version 2.1.0 and above, JBoss Cache offers the ability to override this
+ configuration on a per-node basis. See <literal>Node.setLockForChildInsertRemove()</literal> and it's
+ corresponding javadocs for details.
+ </para>
</section>
</section>
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-09-21 03:15:01 UTC (rev 4496)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-09-21 13:53:59 UTC (rev 4497)
@@ -864,6 +864,7 @@
{
cacheStatus = CacheStatus.DESTROYING;
regionManager = null;
+ cacheLoaderManager = null;
notifier = null;
// The rest of these should have already been taken care of in stop,
Modified: core/trunk/src/main/java/org/jboss/cache/Node.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Node.java 2007-09-21 03:15:01 UTC (rev 4496)
+++ core/trunk/src/main/java/org/jboss/cache/Node.java 2007-09-21 13:53:59 UTC (rev 4497)
@@ -277,4 +277,25 @@
*/
boolean isValid();
+ /**
+ * Tests whether this node is configured to be exclusively locked when inserting or removing children.
+ * <p />
+ * The default
+ * value for this is what is configured in the <tt>LockParentForChildInsertRemove</tt> configuration property,
+ * programatically reachable by querying {@link org.jboss.cache.config.Configuration#isLockParentForChildInsertRemove()}
+ * <p />
+ * This can also be configured on a per-node basis using {@link #setLockForChildInsertRemove(boolean)}
+ * @return true if the node is configured to be exclusively locked for child insertions and removal, false otherwise.
+ * @since 2.1.0
+ */
+ boolean isLockForChildInsertRemove();
+
+ /**
+ * Configures the behaviour of how this node is locked when adding/removing children.
+ * @param lockForChildInsertRemove if true, exclusive locks will be obtained when children are added/removed. If
+ * false, a shared "read lock" will be obtained instead.
+ * @since 2.1.0
+ */
+ void setLockForChildInsertRemove(boolean lockForChildInsertRemove);
+
}
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2007-09-21 03:15:01 UTC (rev 4496)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2007-09-21 13:53:59 UTC (rev 4497)
@@ -68,6 +68,8 @@
*/
private final Map<K, V> data = new HashMap<K, V>();
+ private boolean lockForChildInsertRemove;
+
/**
* Constructs a new node with an FQN of Root.
*/
@@ -107,6 +109,7 @@
{
throw new IllegalArgumentException("Child " + child_name + " must be last part of " + fqn);
}
+ lockForChildInsertRemove = cache.getConfiguration().isLockParentForChildInsertRemove();
}
/**
@@ -742,4 +745,14 @@
// TODO; implement this property, to detect if it has been evicted, removed by another thread, etc. Method added for now as a dummy so it exists in the API
return true;
}
+
+ public boolean isLockForChildInsertRemove()
+ {
+ return lockForChildInsertRemove;
+ }
+
+ public void setLockForChildInsertRemove(boolean lockForChildInsertRemove)
+ {
+ this.lockForChildInsertRemove = lockForChildInsertRemove;
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2007-09-21 03:15:01 UTC (rev 4496)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2007-09-21 13:53:59 UTC (rev 4497)
@@ -199,7 +199,7 @@
underlyingNode.removeChildDirect(child.getLastElement());
}
- updateVersion = cache.getConfiguration().isLockParentForChildInsertRemove();
+ updateVersion = underlyingNode.isLockForChildInsertRemove();
// do we need to notify listeners of a modification?? If all we've done is added children then don't
// notify.
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2007-09-21 03:15:01 UTC (rev 4496)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2007-09-21 13:53:59 UTC (rev 4497)
@@ -320,7 +320,7 @@
}
else
{
- if (writeLockNeeded(ctx, lock_type, i, treeNodeSize, isEvictionOperation, isDeleteOperation, createIfNotExists, isRemoveDataOperation, fqn, child_node.getFqn()))
+ if (writeLockNeeded(ctx, lock_type, i, treeNodeSize, isEvictionOperation, isDeleteOperation, createIfNotExists, isRemoveDataOperation, fqn, child_node))
{
lockTypeRequired = NodeLock.LockType.WRITE;
@@ -373,21 +373,21 @@
n.markAsDeleted(false);
}
- private boolean writeLockNeeded(InvocationContext ctx, NodeLock.LockType lock_type, int currentNodeIndex, int treeNodeSize, boolean isEvictOperation, boolean isRemoveOperation, boolean isPutOperation, boolean isRemoveDataOperation, Fqn targetFqn, Fqn currentFqn)
+ private boolean writeLockNeeded(InvocationContext ctx, NodeLock.LockType lock_type, int currentNodeIndex, int treeNodeSize, boolean isEvictOperation, boolean isRemoveOperation, boolean isPutOperation, boolean isRemoveDataOperation, Fqn targetFqn, NodeSPI currentNode)
{
// write lock forced!!
boolean isTargetNode = isTargetNode(currentNodeIndex, treeNodeSize);
if (ctx.getOptionOverrides().isForceWriteLock() && isTargetNode) return true;
- if (cache.getConfiguration().isLockParentForChildInsertRemove())
+ if (currentNode.isLockForChildInsertRemove())
{
if (isRemoveOperation && currentNodeIndex == treeNodeSize - 2)
{
return true;// we're doing a remove and we've reached the PARENT node of the target to be removed.
}
- if (!isTargetNode && cache.peek(new Fqn(currentFqn, targetFqn.get(currentNodeIndex + 1)), false) == null)
+ if (!isTargetNode && cache.peek(new Fqn(currentNode.getFqn(), targetFqn.get(currentNodeIndex + 1)), false) == null)
{
return isPutOperation;// we're at a node in the tree, not yet at the target node, and we need to create the next node. So we need a WL here.
}
Modified: core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2007-09-21 03:15:01 UTC (rev 4496)
+++ core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2007-09-21 13:53:59 UTC (rev 4497)
@@ -176,6 +176,13 @@
tmpLoader = asyncDecorator;
}
+ if (cfg.isIgnoreModifications())
+ {
+ AbstractDelegatingCacheLoader readOnlyDecorator;
+ readOnlyDecorator = new ReadOnlyDelegatingCacheLoader(tmpLoader);
+ tmpLoader = readOnlyDecorator;
+ }
+
// singleton?
SingletonStoreConfig ssc = cfg.getSingletonStoreConfig();
if (ssc != null && ssc.isSingletonStoreEnabled())
Added: core/trunk/src/main/java/org/jboss/cache/loader/ReadOnlyDelegatingCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/ReadOnlyDelegatingCacheLoader.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/loader/ReadOnlyDelegatingCacheLoader.java 2007-09-21 13:53:59 UTC (rev 4497)
@@ -0,0 +1,85 @@
+package org.jboss.cache.loader;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Map;
+import java.util.List;
+import java.io.ObjectInputStream;
+
+/**
+ * Provides ignoreModifications features to all cache loaders.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.1.0
+ */
+public class ReadOnlyDelegatingCacheLoader extends AbstractDelegatingCacheLoader
+{
+ private static Log log = LogFactory.getLog(ReadOnlyDelegatingCacheLoader.class);
+
+ public ReadOnlyDelegatingCacheLoader(CacheLoader cl)
+ {
+ super(cl);
+ }
+
+ public Object put(Fqn name, Object key, Object value) throws Exception
+ {
+ log.trace("Not delegating write operation to underlying cache loader");
+ Map map = get(name);
+ return (map == null) ? null : map.get(key);
+ }
+
+ public void put(Fqn name, Map attributes) throws Exception
+ {
+ log.trace("Not delegating write operation to underlying cache loader");
+ }
+
+ public void put(List<Modification> modifications) throws Exception
+ {
+ log.trace("Not delegating write operation to underlying cache loader");
+ }
+
+ public Object remove(Fqn fqn, Object key) throws Exception
+ {
+ log.trace("Not delegating write operation to underlying cache loader");
+ Map map = get(fqn);
+ return (map == null) ? null : map.get(key);
+ }
+
+ public void remove(Fqn fqn) throws Exception
+ {
+ log.trace("Not delegating write operation to underlying cache loader");
+ }
+
+ public void removeData(Fqn fqn) throws Exception
+ {
+ log.trace("Not delegating write operation to underlying cache loader");
+ }
+
+ public void prepare(Object tx, List<Modification> modifications, boolean one_phase) throws Exception
+ {
+ log.trace("Not delegating write operation to underlying cache loader");
+ }
+
+ public void commit(Object tx) throws Exception
+ {
+ log.trace("Not delegating write operation to underlying cache loader");
+ }
+
+ public void rollback(Object tx)
+ {
+ log.trace("Not delegating write operation to underlying cache loader");
+ }
+
+ public void storeEntireState(ObjectInputStream is) throws Exception
+ {
+ log.trace("Not delegating write operation to underlying cache loader");
+ }
+
+ public void storeState(Fqn subtree, ObjectInputStream is) throws Exception
+ {
+ log.trace("Not delegating write operation to underlying cache loader");
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java 2007-09-21 03:15:01 UTC (rev 4496)
+++ core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java 2007-09-21 13:53:59 UTC (rev 4497)
@@ -329,6 +329,16 @@
throw new UnsupportedOperationException();
}
+ public boolean isLockForChildInsertRemove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setLockForChildInsertRemove(boolean lockForChildInsertRemove)
+ {
+ throw new UnsupportedOperationException();
+ }
+
public NodeSPI<K, V> getChild(Fqn f)
{
if (f.size() > 1)
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2007-09-21 03:15:01 UTC (rev 4496)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2007-09-21 13:53:59 UTC (rev 4497)
@@ -39,6 +39,7 @@
import org.jboss.util.stream.MarshalledValueOutputStream;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
/**
* Commons tests for all CacheLoaders
@@ -46,6 +47,7 @@
* @author Bela Ban
* @version $Id$
*/
+@Test(groups = {"functional"})
abstract public class CacheLoaderTestsBase extends AbstractCacheLoaderTestBase
{
@@ -2099,6 +2101,33 @@
}
+ public void testIgnoreModifications() throws Exception
+ {
+ Fqn fqn = Fqn.fromString("/a");
+ cache.put(fqn, "k", "v");
+ assert "v".equals(cache.get(fqn, "k"));
+ assert "v".equals(loader.get(fqn).get("k"));
+
+ // now stop the cache
+ cache.stop();
+ cache.destroy();
+ cache.getConfiguration().getCacheLoaderConfig().getIndividualCacheLoaderConfigs().get(0).setIgnoreModifications(true);
+ cache.start();
+ loader = cache.getCacheLoader();
+
+ // test that the cache loader is wrapped by a read-only delegate
+ assert loader instanceof ReadOnlyDelegatingCacheLoader;
+
+ // old state should be persisted.
+ assert "v".equals(cache.get(fqn, "k"));
+ assert "v".equals(loader.get(fqn).get("k"));
+
+ // the loader should now be read-only
+ cache.put(fqn, "k", "v2");
+ assert "v2".equals(cache.get(fqn, "k"));
+ assert "v".equals(loader.get(fqn).get("k"));
+ }
+
public void testCacheLoaderThreadSafety() throws Exception
{
threadSafetyTest(true);
Modified: core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java 2007-09-21 03:15:01 UTC (rev 4496)
+++ core/trunk/src/test/java/org/jboss/cache/loader/FileCacheLoaderTest.java 2007-09-21 13:53:59 UTC (rev 4497)
@@ -1,16 +1,12 @@
package org.jboss.cache.loader;
import static org.testng.AssertJUnit.assertEquals;
+import org.testng.annotations.Test;
import org.jboss.cache.Fqn;
import org.jboss.cache.misc.TestingUtil;
-/**
- * Created by IntelliJ IDEA.
- * User: bela
- * Date: Jun 9, 2004
- * Time: 9:05:19 AM
- */
+@Test(groups = {"functional"})
public class FileCacheLoaderTest extends CacheLoaderTestsBase
{
protected void configureCache() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java 2007-09-21 03:15:01 UTC (rev 4496)
+++ core/trunk/src/test/java/org/jboss/cache/lock/WriteLockOnParentTest.java 2007-09-21 13:53:59 UTC (rev 4497)
@@ -13,6 +13,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -175,4 +176,92 @@
assertNotNull("/a/c should exist", cache.peek(a_c, false));
}
+ public void testPerNodeConfigurationDefaultLock() throws Exception
+ {
+ testPerNodeConfiguration(true);
+ }
+
+ public void testPerNodeConfigurationDefaultNoLock() throws Exception
+ {
+ testPerNodeConfiguration(false);
+ }
+
+ private void testPerNodeConfiguration(boolean defaultLock) throws Exception
+ {
+ cache.getConfiguration().setLockParentForChildInsertRemove(defaultLock);
+
+ cache.put(a, Collections.emptyMap());
+ if (!defaultLock)
+ {
+ // set a per-node lock for a
+ cache.getRoot().getChild(a).setLockForChildInsertRemove(true);
+ }
+
+ cache.put(a_b, Collections.emptyMap());
+ cache.put(a_c, Collections.emptyMap());
+
+ assertNotNull("/a should exist", cache.peek(a, false));
+ assertNotNull("/a/b should exist", cache.peek(a_b, false));
+ assertNotNull("/a/c should exist", cache.peek(a_c, false));
+
+ // concurrent remove of /a/b and /a/c
+ tm.begin();
+ cache.removeNode(a_b);
+ Transaction t1 = tm.suspend();
+
+ tm.begin();
+ try
+ {
+ cache.removeNode(a_c);
+ fail("Should not get here.");
+ }
+ catch (TimeoutException e)
+ {
+ // expected
+ }
+ tm.commit();
+
+ tm.resume(t1);
+ tm.commit();
+
+ assertNotNull("/a should exist", cache.peek(a, false));
+ assertNull("/a/b should not exist", cache.peek(a_b, false));
+ assertNotNull("/a/c should exist", cache.peek(a_c, false));
+
+ Fqn b = Fqn.fromString("/b");
+ Fqn b_b = Fqn.fromString("/b/b");
+ Fqn b_c = Fqn.fromString("/b/c");
+ cache.put(b, Collections.emptyMap());
+
+ if (defaultLock)
+ {
+ // set a per-node locking config for node b
+ cache.getRoot().getChild(b).setLockForChildInsertRemove(false);
+ }
+
+
+ cache.put(b_b, Collections.emptyMap());
+ cache.put(b_c, Collections.emptyMap());
+
+ assertNotNull("/a should exist", cache.peek(b, false));
+ assertNotNull("/a/b should exist", cache.peek(b_b, false));
+ assertNotNull("/a/c should exist", cache.peek(b_c, false));
+
+ // concurrent remove of /a/b and /a/c
+ tm.begin();
+ cache.removeNode(b_b);
+ t1 = tm.suspend();
+
+ tm.begin();
+ cache.removeNode(b_c);
+ tm.commit();
+
+ tm.resume(t1);
+ tm.commit();
+
+ assertNotNull("/b should exist", cache.peek(b, false));
+ assertNull("/b/b should not exist", cache.peek(b_b, false));
+ assertNull("/b/c should not exist", cache.peek(b_c, false));
+ }
+
}
16 years, 11 months
JBoss Cache SVN: r4496 - in pojo/trunk/src: main/java/org/jboss/cache/pojo/impl and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2007-09-20 23:15:01 -0400 (Thu, 20 Sep 2007)
New Revision: 4496
Modified:
pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java
Log:
JBCACHE-1 Add low cost exists() to the API
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java 2007-09-21 00:20:00 UTC (rev 4495)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/PojoCache.java 2007-09-21 03:15:01 UTC (rev 4496)
@@ -113,6 +113,15 @@
String getPojoID(Object pojo);
/**
+ * Determines if an object is attached at a particular location. This is somewhat less expensive
+ * than find() because an object is not created, and internal reference links are not traversed.
+ *
+ * @param id the location in the cache to examine
+ * @return true if an attached object exists, false if not
+ */
+ boolean exists(Fqn<?> id);
+
+ /**
* Retrieve POJO from the cache system. Return null if object does not exist in the cache.
* Note that this operation is fast if there is already a POJO instance attached to the cache.
*
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java 2007-09-21 00:20:00 UTC (rev 4495)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheDelegate.java 2007-09-21 03:15:01 UTC (rev 4496)
@@ -476,4 +476,9 @@
}
}
}
+
+ public boolean exists(Fqn<?> id)
+ {
+ return internal_.getPojoReference(id, null) != null || internal_.getPojoInstance(id) != null;
+ }
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java 2007-09-21 00:20:00 UTC (rev 4495)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/PojoCacheImpl.java 2007-09-21 03:15:01 UTC (rev 4496)
@@ -174,6 +174,11 @@
throw new PojoCacheException("getPojoID not yet implemented");
}
+ public boolean exists(Fqn<?> id)
+ {
+ return delegate_.exists(id);
+ }
+
public Object find(String id) throws PojoCacheException
{
return find(Fqn.fromString(id));
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2007-09-21 00:20:00 UTC (rev 4495)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2007-09-21 03:15:01 UTC (rev 4496)
@@ -1,6 +1,7 @@
package org.jboss.cache.pojo;
import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail;
@@ -16,6 +17,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.aop.proxy.ClassProxy;
import org.jboss.cache.Fqn;
+import org.jboss.cache.pojo.impl.PojoReference;
import org.jboss.cache.pojo.test.Address;
import org.jboss.cache.pojo.test.Person;
import org.jboss.cache.pojo.test.Student;
@@ -366,9 +368,14 @@
cache_.detach("/person/joe");
}
+ public void testExists() throws Exception
+ {
+ Fqn<String> fqn = Fqn.fromString("/person/test1");
+ createPerson(fqn.toString(), "Joe Black", 32);
+ assertTrue(cache_.exists(fqn));
+ assertFalse(cache_.exists(Fqn.fromString("/blah")));
-
-
-
-}
-
+ PojoReference ref = (PojoReference) cache_.getCache().get(fqn, PojoReference.KEY);
+ assertTrue(cache_.exists(ref.getFqn()));
+ }
+}
\ No newline at end of file
16 years, 11 months
JBoss Cache SVN: r4495 - pojo/trunk/src/main/java/org/jboss/cache/pojo/impl.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2007-09-20 20:20:00 -0400 (Thu, 20 Sep 2007)
New Revision: 4495
Modified:
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java
Log:
Fix broken import
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java 2007-09-20 23:36:35 UTC (rev 4494)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java 2007-09-21 00:20:00 UTC (rev 4495)
@@ -17,7 +17,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.aop.Advised;
-import org.jboss.aop.Advisor;
import org.jboss.aop.ClassInstanceAdvisor;
import org.jboss.aop.InstanceAdvisor;
import org.jboss.cache.Cache;
@@ -27,7 +26,6 @@
import org.jboss.cache.pojo.memory.FieldPersistentReference;
import org.jboss.cache.pojo.util.AopUtil;
import org.jboss.cache.pojo.util.Instantiator;
-import org.objenesis.ObjenesisStd;
/**
* Handling the advised pojo operations. No consideration of object graph here.
16 years, 11 months
JBoss Cache SVN: r4494 - in pojo/trunk/src: main/java/org/jboss/cache/pojo/memory and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2007-09-20 19:36:35 -0400 (Thu, 20 Sep 2007)
New Revision: 4494
Added:
pojo/trunk/src/main/java/org/jboss/cache/pojo/util/Instantiator.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/util/PrivilegedCode.java
pojo/trunk/src/test/java/org/jboss/cache/pojo/NoZeroArgConstructorTest.java
Modified:
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CachedType.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/FieldPersistentReference.java
pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/MethodPersistentReference.java
Log:
PCACHE-3 Add support for objects with no-arg constructors
PCACHE-4 Use privileged actions
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java 2007-09-20 19:01:31 UTC (rev 4493)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/AdvisedPojoHandler.java 2007-09-20 23:36:35 UTC (rev 4494)
@@ -26,6 +26,8 @@
import org.jboss.cache.pojo.interceptors.dynamic.CacheFieldInterceptor;
import org.jboss.cache.pojo.memory.FieldPersistentReference;
import org.jboss.cache.pojo.util.AopUtil;
+import org.jboss.cache.pojo.util.Instantiator;
+import org.objenesis.ObjenesisStd;
/**
* Handling the advised pojo operations. No consideration of object graph here.
@@ -49,20 +51,13 @@
util_ = util;
}
- public Object get(Fqn fqn, Class clazz, PojoInstance pojoInstance)
+ public Object get(Fqn<?> fqn, Class<?> clazz, PojoInstance pojoInstance)
throws CacheException
{
CachedType type = pCache_.getCachedType(clazz);
- Object obj = null;
- try
- {
- obj = clazz.newInstance();
- // TODO Need to populate the object from the cache as well.
- }
- catch (Exception e)
- {
- throw new CacheException("failed creating instance of " + clazz.getName(), e);
- }
+ Object obj =Instantiator.newInstance(clazz);
+
+ // TODO Need to populate the object from the cache as well.
// Insert interceptor at runtime
InstanceAdvisor advisor = ((Advised) obj)._getInstanceAdvisor();
CacheFieldInterceptor interceptor = new CacheFieldInterceptor(pCache_, fqn, type);
@@ -71,7 +66,7 @@
return obj;
}
- void put(Fqn fqn, Fqn referencingFqn, Object obj) throws CacheException
+ void put(Fqn<?> fqn, Fqn<?> referencingFqn, Object obj) throws CacheException
{
CachedType type = pCache_.getCachedType(obj.getClass());
// We have a clean slate then.
@@ -155,7 +150,7 @@
}
}
- Object remove(Fqn fqn, Object result, Class clazz) throws CacheException
+ Object remove(Fqn<?> fqn, Object result, Class<?> clazz) throws CacheException
{
CachedType type = pCache_.getCachedType(clazz);
InstanceAdvisor advisor = ((Advised) result)._getInstanceAdvisor();
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CachedType.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CachedType.java 2007-09-20 19:01:31 UTC (rev 4493)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/impl/CachedType.java 2007-09-20 23:36:35 UTC (rev 4494)
@@ -18,6 +18,7 @@
import org.jboss.aop.joinpoint.FieldInvocation;
import org.jboss.cache.pojo.memory.FieldPersistentReference;
import org.jboss.cache.pojo.memory.PersistentReference;
+import org.jboss.cache.pojo.util.PrivilegedCode;
/**
* Represent a cached object type, e.g., whether it is <b>primitive</b> or not.
@@ -82,7 +83,7 @@
private static boolean isImmediate(Class clazz)
{
- // Treat enums as a simple type since they serialize to a simple string
+ // Treat enums as a simple type since they serialize to a simple string
return immediates.contains(clazz) || Enum.class.isAssignableFrom(clazz);
}
@@ -210,7 +211,7 @@
Field f = classFields[i];
if (isNonReplicatable(f)) continue;
- f.setAccessible(true);
+ PrivilegedCode.setAccessible(f);
FieldPersistentReference persistentRef = new FieldPersistentReference(f, PersistentReference.REFERENCE_SOFT);
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/FieldPersistentReference.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/FieldPersistentReference.java 2007-09-20 19:01:31 UTC (rev 4493)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/FieldPersistentReference.java 2007-09-20 23:36:35 UTC (rev 4494)
@@ -24,6 +24,8 @@
import java.lang.reflect.Field;
+import org.jboss.cache.pojo.util.PrivilegedCode;
+
/**
* Creates a persistentReference for Fields
*
@@ -48,7 +50,7 @@
if ((returnValue = internalGet()) != null) return returnValue;
Field field = getMappedClass().getDeclaredField(name);
- field.setAccessible(true);
+ PrivilegedCode.setAccessible(field);
buildReference(field);
return field;
}
Modified: pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/MethodPersistentReference.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/MethodPersistentReference.java 2007-09-20 19:01:31 UTC (rev 4493)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/memory/MethodPersistentReference.java 2007-09-20 23:36:35 UTC (rev 4494)
@@ -24,6 +24,8 @@
import java.lang.reflect.Method;
+import org.jboss.cache.pojo.util.PrivilegedCode;
+
/**
* A reference to a field.
* In case the reference is released, the reference will be reconstructed
@@ -50,7 +52,7 @@
if ((returnValue = internalGet()) != null) return returnValue;
Method aMethod = getMappedClass().getDeclaredMethod(name, getArguments());
- aMethod.setAccessible(true);
+ PrivilegedCode.setAccessible(aMethod);
buildReference(aMethod);
return aMethod;
}
Added: pojo/trunk/src/main/java/org/jboss/cache/pojo/util/Instantiator.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/util/Instantiator.java (rev 0)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/util/Instantiator.java 2007-09-20 23:36:35 UTC (rev 4494)
@@ -0,0 +1,94 @@
+package org.jboss.cache.pojo.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.jboss.cache.CacheException;
+
+public class Instantiator
+{
+ private static abstract class Allocator
+ {
+ public Object allocate(Class<?> c) throws Exception
+ {
+ Constructor<?> constructor = c.getDeclaredConstructor();
+ PrivilegedCode.setAccessible(constructor);
+ return constructor.newInstance();
+ }
+ }
+
+ private static final Allocator allocator;
+
+ static
+ {
+ // Currently only Sun and Mac JVMs are suported
+ Allocator a = createUnsafeAllocator();
+ allocator = a != null ? a : createDefaultAllocator();
+ }
+
+
+ public static Object newInstance(Class<?> c) throws CacheException
+ {
+ try
+ {
+ return allocator.allocate(c);
+ }
+ catch (Exception e)
+ {
+ throw new CacheException("failed creating instance of " + c.getName(), e);
+ }
+ }
+
+ private static Allocator createUnsafeAllocator()
+ {
+ Allocator allocator = null;
+ try
+ {
+ final Class<?> clazz = Class.forName("sun.misc.Unsafe");
+ final Field field = clazz.getDeclaredField("theUnsafe");
+ PrivilegedCode.setAccessible(field);
+ final Object object = field.get(null);
+ final Method method = clazz.getMethod("allocateInstance", Class.class);
+
+ allocator = new Allocator()
+ {
+ public Object allocate(Class<?> c) throws Exception
+ {
+ try
+ {
+ return super.allocate(c);
+ }
+ catch (Exception e)
+ {
+ }
+ return method.invoke(object, c);
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ }
+
+ return allocator;
+ }
+
+ private static Allocator createDefaultAllocator()
+ {
+ return new Allocator()
+ {
+
+ public Object allocate(Class<?> c) throws Exception
+ {
+ try
+ {
+ return super.allocate(c);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("A noarg constructor is required on this JVM", e);
+ }
+ }
+ };
+ }
+}
Added: pojo/trunk/src/main/java/org/jboss/cache/pojo/util/PrivilegedCode.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/pojo/util/PrivilegedCode.java (rev 0)
+++ pojo/trunk/src/main/java/org/jboss/cache/pojo/util/PrivilegedCode.java 2007-09-20 23:36:35 UTC (rev 4494)
@@ -0,0 +1,28 @@
+package org.jboss.cache.pojo.util;
+
+import java.lang.reflect.AccessibleObject;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Performs privileged actions
+ *
+ * @author Jason T. Greene
+ */
+public class PrivilegedCode
+{
+ public static void setAccessible(final AccessibleObject object)
+ {
+ if (object.isAccessible())
+ return;
+
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ object.setAccessible(true);
+ return null;
+ }
+ });
+ }
+}
Added: pojo/trunk/src/test/java/org/jboss/cache/pojo/NoZeroArgConstructorTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/NoZeroArgConstructorTest.java (rev 0)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/NoZeroArgConstructorTest.java 2007-09-20 23:36:35 UTC (rev 4494)
@@ -0,0 +1,100 @@
+package org.jboss.cache.pojo;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.pojo.annotation.Replicable;
+import org.testng.AssertJUnit;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/**
+ * Verifies that objects can be constructed without a public zero-arg constructor.
+ *
+ * @author Jason T. Greene
+ */
+@Test(groups = {"functional"})
+public class NoZeroArgConstructorTest
+{
+ Log log = LogFactory.getLog(NoZeroArgConstructorTest.class);
+ PojoCache cache, cache1;
+
+ @BeforeTest(alwaysRun = true)
+ protected void setUp() throws Exception
+ {
+ log.info("setUp() ....");
+ boolean toStart = false;
+ cache = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache.start();
+ cache1 = PojoCacheFactory.createCache(UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC), toStart);
+ cache1.start();
+ }
+
+ @AfterTest(alwaysRun = true)
+ protected void tearDown() throws Exception
+ {
+ cache.stop();
+ cache1.stop();
+ }
+
+ @Replicable
+ public static class PrivateConstructor
+ {
+ private int x;
+ private PrivateConstructor()
+ {
+ }
+
+ public void setX(int x)
+ {
+ this.x = x;
+ }
+
+ public int getX()
+ {
+ return x;
+ }
+ }
+
+ @Replicable
+ public static class TwoArgConstructor
+ {
+ private int x;
+ public TwoArgConstructor(double one, int two)
+ {
+ }
+
+ public void setX(int x)
+ {
+ this.x = x;
+ }
+
+ public int getX()
+ {
+ return x;
+ }
+ }
+
+ public void testPrivateConstructor()
+ {
+ PrivateConstructor priv = new PrivateConstructor();
+ priv.setX(5);
+ cache.attach("/foo/private", priv);
+ PrivateConstructor priv2 = (PrivateConstructor) cache1.find("/foo/private");
+ AssertJUnit.assertNotNull("Object not found", priv2);
+ AssertJUnit.assertEquals(priv.getX(), priv2.getX());
+ }
+
+ public void testTwoArgConstructor()
+ {
+ TwoArgConstructor cons = new TwoArgConstructor(1.0, 1);
+ cons.setX(5);
+ cache.attach("/foo/twoarg", cons);
+ TwoArgConstructor cons2 = (TwoArgConstructor) cache1.find("/foo/twoarg");
+ AssertJUnit.assertNotNull("Object not found", cons2);
+ AssertJUnit.assertEquals(cons.getX(), cons2.getX());
+ }
+
+}
\ No newline at end of file
16 years, 11 months
JBoss Cache SVN: r4493 - pojo/trunk/src/test/java/org/jboss/cache/pojo.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2007-09-20 15:01:31 -0400 (Thu, 20 Sep 2007)
New Revision: 4493
Modified:
pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java
Log:
Add Fqn usage
Modified: pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2007-09-20 17:10:12 UTC (rev 4492)
+++ pojo/trunk/src/test/java/org/jboss/cache/pojo/LocalTest.java 2007-09-20 19:01:31 UTC (rev 4493)
@@ -15,6 +15,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.aop.proxy.ClassProxy;
+import org.jboss.cache.Fqn;
import org.jboss.cache.pojo.test.Address;
import org.jboss.cache.pojo.test.Person;
import org.jboss.cache.pojo.test.Student;
@@ -29,7 +30,7 @@
*/
@Test(groups = {"functional"})
-public class LocalTest
+public class LocalTest
{
Log log = LogFactory.getLog(LocalTest.class);
PojoCache cache_;
@@ -96,6 +97,16 @@
assertEquals("String ", test, cache_.find("test"));
}
+ public void testSimpleTypeFqn() throws Exception
+ {
+ log.info("testSimpleType() ....");
+ String test = "This is a test";
+ cache_.attach(Fqn.fromString("/test"), test);
+
+ assertEquals("String ", test, cache_.find(Fqn.fromString("/test")));
+ }
+
+
public void testModification() throws Exception
{
Person joe = createPerson("/person/test2", "Joe", 32);
16 years, 11 months
JBoss Cache SVN: r4492 - core/trunk/src/test/java/org/jboss/cache/replicated.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-09-20 13:10:12 -0400 (Thu, 20 Sep 2007)
New Revision: 4492
Added:
core/trunk/src/test/java/org/jboss/cache/replicated/ExceptionTest.java
Log:
Added test for JBCACHE-1152
Added: core/trunk/src/test/java/org/jboss/cache/replicated/ExceptionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/ExceptionTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/ExceptionTest.java 2007-09-20 17:10:12 UTC (rev 4492)
@@ -0,0 +1,86 @@
+package org.jboss.cache.replicated;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.ReplicationException;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.lock.TimeoutException;
+import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+/**
+ * Tests the type of exceptions thrown for Lock Acquisition Timeouts versus Sync Repl Timeouts
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.1.0
+ */
+public class ExceptionTest
+{
+ private Cache cache1;
+ private Cache cache2;
+ private Fqn fqn = Fqn.fromString("/a");
+
+ @BeforeMethod
+ public void setUp()
+ {
+ cache1 = DefaultCacheFactory.getInstance().createCache(false);
+ cache2 = DefaultCacheFactory.getInstance().createCache(false);
+
+ cache1.getConfiguration().setSyncCommitPhase(true);
+ cache1.getConfiguration().setSyncRollbackPhase(true);
+ cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ cache1.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+
+ cache2.getConfiguration().setSyncCommitPhase(true);
+ cache2.getConfiguration().setSyncRollbackPhase(true);
+ cache2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ cache2.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ }
+
+ @AfterMethod
+ public void tearDown()
+ {
+ if (cache1 != null) cache1.stop();
+ if (cache2 != null) cache2.stop();
+ }
+
+ @Test (groups = {"functional"}, expectedExceptions = {ReplicationException.class})
+ public void testSyncReplTimeout()
+ {
+ cache1.getConfiguration().setSyncReplTimeout(1); // 1ms. this is *bound* to fail.
+ cache2.getConfiguration().setSyncReplTimeout(1);
+
+ cache1.start();
+ cache2.start();
+
+ TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);
+
+ cache1.put(fqn, "k", "v");
+ }
+
+ @Test (groups = {"functional"}, expectedExceptions = {TimeoutException.class})
+ public void testLockAcquisitionTimeout() throws Exception
+ {
+ cache2.getConfiguration().setLockAcquisitionTimeout(1);
+
+ cache1.start();
+ cache2.start();
+
+ TestingUtil.blockUntilViewsReceived(10000, cache1, cache2);
+
+ // get a lock on cache 2 and hold on to it.
+ TransactionManager tm = cache2.getConfiguration().getRuntimeConfig().getTransactionManager();
+ tm.begin();
+ cache2.put(fqn, "block", "block");
+ Transaction t = tm.suspend();
+
+ cache1.put(fqn, "k", "v");
+ }
+}
16 years, 11 months
JBoss Cache SVN: r4491 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-09-20 12:59:28 -0400 (Thu, 20 Sep 2007)
New Revision: 4491
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
Log:
Removed deprecated cfg elements in default jgroups cfg
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-09-20 15:46:04 UTC (rev 4490)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-09-20 16:59:28 UTC (rev 4491)
@@ -4219,10 +4219,10 @@
"MERGE2(min_interval=5000;max_interval=10000):" +
"FD_SOCK:" +
"VERIFY_SUSPECT(timeout=1500):" +
- "pbcast.NAKACK(gc_lag=50;max_xmit_size=8192;retransmit_timeout=600,1200,2400,4800):" +
+ "pbcast.NAKACK(gc_lag=50;retransmit_timeout=600,1200,2400,4800):" +
"UNICAST(timeout=600,1200,2400,4800):" +
"pbcast.STABLE(desired_avg_gossip=20000):" +
- "FRAG(frag_size=8192;down_thread=false;up_thread=false):" +
+ "FRAG(frag_size=8192):" +
"pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;" +
"shun=false;print_local_addr=true):" +
"pbcast.STATE_TRANSFER";
16 years, 11 months
JBoss Cache SVN: r4490 - core/trunk.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-09-20 11:46:04 -0400 (Thu, 20 Sep 2007)
New Revision: 4490
Modified:
core/trunk/pom.xml
Log:
JGroups 2.6.0.Beta1
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2007-09-20 04:28:36 UTC (rev 4489)
+++ core/trunk/pom.xml 2007-09-20 15:46:04 UTC (rev 4490)
@@ -21,7 +21,7 @@
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.5.0-GA</version>
+ <version>2.6.0.Beta1</version>
</dependency>
<dependency>
<groupId>jdbm</groupId>
16 years, 11 months