JBoss Cache SVN: r4616 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-10-12 20:52:26 -0400 (Fri, 12 Oct 2007)
New Revision: 4616
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
Log:
JBCACHE-1192 - cannot gravitate data only stored in a cache loader
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-10-12 23:39:28 UTC (rev 4615)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-10-13 00:52:26 UTC (rev 4616)
@@ -2915,6 +2915,7 @@
ctx.setOriginLocal(false);
// use a get() call into the cache to make sure cache loading takes place.
+ // no need to cache the original skipDataGravitation setting here - it will always be false of we got here!!
ctx.getOptionOverrides().setSkipDataGravitation(true);
Node<K, V> actualNode = get(fqn);
ctx.getOptionOverrides().setSkipDataGravitation(false);
@@ -2941,19 +2942,14 @@
actualNode = get(backupNodeFqn);
ctx.getOptionOverrides().setSkipDataGravitation(false);
- if (actualNode != null) break;
+ if (actualNode != null)
+ {
+ // make sure we LOAD data for this node!!
+ getData(backupNodeFqn);
+ break;
+ }
}
}
- /*Map children = backupSubtree.getChildrenMapDirect();
- if (children != null)
- {
- Iterator childNames = children.keySet().iterator();
- while (childNames.hasNext() && actualNode == null)
- {
- backupNodeFqn = BuddyManager.getBackupFqn(childNames.next().toString(), fqn);
- actualNode = findNode(backupNodeFqn);
- }
- }*/
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2007-10-12 23:39:28 UTC (rev 4615)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2007-10-13 00:52:26 UTC (rev 4616)
@@ -89,16 +89,11 @@
{
if (cache.peek(fqn, false) == null)
{
- BackupData data;
+ log.trace("Gravitating from local backup tree");
+ BackupData data = localBackupGet(fqn, ctx);
- // perform a data gravitation
- if (localBackupExists(fqn))
+ if (data == null)
{
- log.trace("Gravitating from local backup tree");
- data = localBackupGet(fqn, ctx);
- }
- else
- {
log.trace("Gravitating from remote backup tree");
// gravitate remotely.
data = remoteBackupGet(fqn);
@@ -121,6 +116,10 @@
cleanBackupData(data, ctx.getGlobalTransaction(), ctx);
}
}
+ else
+ {
+ log.trace("No need to gravitate; have this already.");
+ }
}
}
else
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2007-10-12 23:39:28 UTC (rev 4615)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2007-10-13 00:52:26 UTC (rev 4616)
@@ -235,13 +235,13 @@
*
* @throws Exception
*/
- public void testGravitationOfEvictedNodes() throws Exception
+ public void testLocalGravitationOfEvictedNodes() throws Exception
{
- CacheImpl<Object,Object> cache0 = createCacheWithCacheLoader(true, true, passivation, true, false);
- Configuration cfg0 = cache0.getConfiguration();
- configureEviction(cfg0);
- Configuration cfg1 = cfg0.clone();
- CacheImpl<Object,Object> cache1 = (CacheImpl<Object,Object>) DefaultCacheFactory.getInstance().createCache(cfg1, false);
+ CacheImpl<Object,Object> cache1 = createCacheWithCacheLoader(true, true, passivation, true, false);
+ Configuration cfg1 = cache1.getConfiguration();
+ configureEviction(cfg1);
+ Configuration cfg0 = cfg1.clone();
+ CacheImpl<Object,Object> cache0 = (CacheImpl<Object,Object>) DefaultCacheFactory.getInstance().createCache(cfg0, false);
// Store them for the teardown method
if (caches == null)
@@ -252,18 +252,89 @@
cache0.start();
cache1.start();
- TestingUtil.blockUntilViewsReceived((Cache[]) caches.toArray(new Cache[2]), VIEW_BLOCK_TIMEOUT);
+ TestingUtil.blockUntilViewsReceived(caches.toArray(new Cache[caches.size()]), VIEW_BLOCK_TIMEOUT * caches.size());
TestingUtil.sleepThread(getSleepTimeout());
-
+
+
Fqn foo = Fqn.fromString("/foo");
+ Fqn backupFoo = BuddyManager.getBackupFqn(cache0.getLocalAddress(), foo);
cache0.put(foo, "key", "value");
+ assert cache0.exists(foo) : "Data should exist in data owner";
+ assert cache1.exists(backupFoo) : "Buddy should have data";
+
// Sleep long enough for eviction to run twice plus a bit
- TestingUtil.sleepThread(2050);
-
+ TestingUtil.sleepThread(3050);
+
+ // test that the data we're looking for has been evicted in both the data owner and the buddy.
+ assert !cache0.exists(foo) : "Data should have evicted in data owner";
+ assert !cache1.exists(backupFoo) : "Buddy should have data evicted";
+
+ // now test that this exists in both loaders.
+ assert cache0.getCacheLoader().get(foo) != null : "Should exist in data owner's cache loader";
+ assert cache1.getCacheLoader().get(backupFoo) != null : "Should exist in buddy's loader";
+
+
+ // a local gravitation should occur since cache1 has foo in it's backup tree.
assertEquals("Passivated value available from buddy", "value", cache1.get(foo, "key"));
}
+ /**
+ * Tests whether nodes that have been evicted can successfully be
+ * gravitated.
+ *
+ * @throws Exception
+ */
+ public void testRemoteGravitationOfEvictedNodes() throws Exception
+ {
+ CacheImpl<Object,Object> cache0 = createCacheWithCacheLoader(true, true, passivation, true, false);
+ Configuration cfg0 = cache0.getConfiguration();
+ configureEviction(cfg0);
+ Configuration cfg1 = cfg0.clone();
+ CacheImpl<Object,Object> cache1 = (CacheImpl<Object,Object>) DefaultCacheFactory.getInstance().createCache(cfg1, false);
+ Configuration cfg2 = cfg0.clone();
+ CacheImpl<Object,Object> cache2 = (CacheImpl<Object,Object>) DefaultCacheFactory.getInstance().createCache(cfg2, false);
+
+ // Store them for the teardown method
+ if (caches == null)
+ caches = new ArrayList<CacheImpl<Object,Object>>();
+ caches.add(cache0);
+ caches.add(cache1);
+ caches.add(cache2);
+
+ cache0.start();
+ cache1.start();
+ cache2.start();
+
+ TestingUtil.blockUntilViewsReceived(caches.toArray(new Cache[caches.size()]), 600000);
+ TestingUtil.sleepThread(getSleepTimeout());
+
+
+ assert (cache0.getBuddyManager().getBuddyAddresses().contains(cache1.getLocalAddress())) : "Cache1 should be cache0's buddy!";
+
+ Fqn foo = Fqn.fromString("/foo");
+ Fqn backupFoo = BuddyManager.getBackupFqn(cache0.getLocalAddress(), foo);
+ cache0.put(foo, "key", "value");
+
+ // test that the data exists in both the data owner and the buddy
+ assert cache0.exists(foo) : "Data should exist in data owner";
+ assert cache1.exists(backupFoo) : "Buddy should have data";
+
+ // Sleep long enough for eviction to run twice plus a bit
+ TestingUtil.sleepThread(3050);
+
+ // test that the data we're looking for has been evicted in both the data owner and the buddy.
+ assert !cache0.exists(foo) : "Data should have evicted in data owner";
+ assert !cache1.exists(backupFoo) : "Buddy should have data evicted";
+
+ // now test that this exists in both loaders.
+ assert cache0.getCacheLoader().get(foo) != null : "Should exist in data owner's loader";
+ assert cache1.getCacheLoader().get(backupFoo) != null : "Should exist in buddy's loader";
+
+ // doing a get on cache2 will guarantee a remote data gravitation.
+ assertEquals("Passivated value available from buddy", "value", cache2.get(foo, "key"));
+ }
+
private void configureEviction(Configuration cfg)
{
EvictionConfig ec = new EvictionConfig();
17 years
JBoss Cache SVN: r4615 - pojo/trunk.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2007-10-12 19:39:28 -0400 (Fri, 12 Oct 2007)
New Revision: 4615
Modified:
pojo/trunk/pom.xml
Log:
workaround broken deps
Modified: pojo/trunk/pom.xml
===================================================================
--- pojo/trunk/pom.xml 2007-10-12 23:11:52 UTC (rev 4614)
+++ pojo/trunk/pom.xml 2007-10-12 23:39:28 UTC (rev 4615)
@@ -36,6 +36,13 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
+ <!-- Hack AOP has broken deps -->
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-container</artifactId>
+ <version>2.0.0.Beta4</version>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -94,7 +101,7 @@
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jbossaop-plugin</artifactId>
<version>2.0.0.beta1</version>
- <!-- HACK: AOP project has broken deps -->
+ <!-- HACK: AOP project and plugin has broken deps -->
<dependencies>
<dependency>
<groupId>org.jboss.microcontainer</groupId>
17 years
JBoss Cache SVN: r4614 - in pojo/trunk: src/main/java/org/jboss/cache/pojo and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2007-10-12 19:11:52 -0400 (Fri, 12 Oct 2007)
New Revision: 4614
Added:
pojo/trunk/src/test/java/org/jboss/cache/pojo/demo/
Removed:
pojo/trunk/src/main/java/org/jboss/cache/pojo/demo/
Modified:
pojo/trunk/pom.xml
Log:
Fix build
Modified: pojo/trunk/pom.xml
===================================================================
--- pojo/trunk/pom.xml 2007-10-12 22:35:07 UTC (rev 4613)
+++ pojo/trunk/pom.xml 2007-10-12 23:11:52 UTC (rev 4614)
@@ -101,6 +101,16 @@
<artifactId>jboss-container</artifactId>
<version>2.0.0.Beta4</version>
</dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-core</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
<executions>
<execution>
Copied: pojo/trunk/src/test/java/org/jboss/cache/pojo/demo (from rev 4582, pojo/trunk/src/main/java/org/jboss/cache/pojo/demo)
17 years
JBoss Cache SVN: r4613 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2007-10-12 18:35:07 -0400 (Fri, 12 Oct 2007)
New Revision: 4613
Modified:
core/trunk/src/main/java/org/jboss/cache/Version.java
Log:
Fix version
Modified: core/trunk/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Version.java 2007-10-12 22:34:08 UTC (rev 4612)
+++ core/trunk/src/main/java/org/jboss/cache/Version.java 2007-10-12 22:35:07 UTC (rev 4613)
@@ -11,7 +11,7 @@
@Immutable
public class Version
{
- public static final String version = "2.1.0.CR1";
+ public static final String version = "2.1.0-SNAPSHOT";
public static final String codename = "Alegrias";
public static final String cvs = "$Id: Version.java 4592 2007-10-10 16:44:36Z manik.surtani(a)jboss.com $";
static final byte[] version_id = {'0', '2', '1', '0', 'B'};
17 years
JBoss Cache SVN: r4612 - core/trunk.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2007-10-12 18:34:08 -0400 (Fri, 12 Oct 2007)
New Revision: 4612
Modified:
core/trunk/pom.xml
Log:
Fix version number
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2007-10-12 17:46:47 UTC (rev 4611)
+++ core/trunk/pom.xml 2007-10-12 22:34:08 UTC (rev 4612)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-core-version>2.1.0.CR1</jbosscache-core-version>
+ <jbosscache-core-version>2.1.0-SNAPSHOT</jbosscache-core-version>
</properties>
<parent>
<groupId>org.jboss.cache</groupId>
17 years
JBoss Cache SVN: r4611 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2007-10-12 13:46:47 -0400 (Fri, 12 Oct 2007)
New Revision: 4611
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
Log:
JBCACHE-1192 - cannot gravitate data only stored in a cache loader
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-10-12 17:22:14 UTC (rev 4610)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2007-10-12 17:46:47 UTC (rev 4611)
@@ -2914,10 +2914,15 @@
{
ctx.setOriginLocal(false);
- NodeSPI<K, V> actualNode = findNode(fqn);
+ // use a get() call into the cache to make sure cache loading takes place.
+ ctx.getOptionOverrides().setSkipDataGravitation(true);
+ Node<K, V> actualNode = get(fqn);
+ ctx.getOptionOverrides().setSkipDataGravitation(false);
+
Fqn backupNodeFqn = null;
if (actualNode == null && searchSubtrees)
{
+
NodeSPI backupSubtree = findNode(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
if (backupSubtree != null)
{
@@ -2930,7 +2935,12 @@
// childName is the name of a buddy group since all child names in this
// collection are direct children of BUDDY_BACKUP_SUBTREE_FQN
backupNodeFqn = BuddyManager.getBackupFqn(childName.toString(), fqn);
- actualNode = findNode(backupNodeFqn);
+
+ // use a get() call into the cache to make sure cache loading takes place.
+ ctx.getOptionOverrides().setSkipDataGravitation(true);
+ actualNode = get(backupNodeFqn);
+ ctx.getOptionOverrides().setSkipDataGravitation(false);
+
if (actualNode != null) break;
}
}
@@ -2957,7 +2967,7 @@
backupNodeFqn = BuddyManager.getBackupFqn(BuddyManager.getGroupNameFromAddress(getLocalAddress()), fqn);
}
- List<NodeData> list = getNodeData(new LinkedList<NodeData>(), actualNode);
+ List<NodeData> list = getNodeData(new LinkedList<NodeData>(), (NodeSPI<K, V>) actualNode);
return GravitateResult.subtreeResult(list, backupNodeFqn);
}
17 years