[jbosscache-commits] JBoss Cache SVN: r8400 - in core/trunk/src/main/java/org/jboss/cache: interceptors and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Sat May 8 16:30:47 EDT 2010


Author: bstansberry at jboss.com
Date: 2010-05-08 16:30:47 -0400 (Sat, 08 May 2010)
New Revision: 8400

Modified:
   core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java
Log:
[JBCACHE-1580] Ensure names of dead member backup node children are type Integer

Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java	2010-05-05 09:01:58 UTC (rev 8399)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java	2010-05-08 20:30:47 UTC (rev 8400)
@@ -26,7 +26,9 @@
 import org.jgroups.Address;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 /**
  * Knows how to transform between fqn and buddy-formated fqns.
@@ -176,4 +178,25 @@
          return Fqn.root();
       }
    }
+   
+   /**
+    * Takes a set of names that represent the children of a 
+    * {@link #isDeadBackupRoot(Fqn) dead backup root} and ensure they are
+    * all of the expected type, tranforming any that are not. See JBCACHE-1580.
+    * 
+    * 
+    * @param children names that represent the children of a dead backup root node
+    * 
+    * @return set, based on <code>names</code> whose members are all of the
+    *         expected type.
+    */
+   public Set<?> getDeadBackupRootChildren(Set<?> children)
+   {    
+      Set<Integer> result = new HashSet<Integer>(children.size());
+      for (Object child : children)
+      {
+         result.add((child instanceof Integer ? (Integer) child : Integer.valueOf(child.toString())));
+      }
+      return result;
+   }
 }

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java	2010-05-05 09:01:58 UTC (rev 8399)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java	2010-05-08 20:30:47 UTC (rev 8400)
@@ -27,6 +27,7 @@
 import org.jboss.cache.InternalNode;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
 import org.jboss.cache.commands.read.GetChildrenNamesCommand;
 import org.jboss.cache.commands.read.GetDataMapCommand;
 import org.jboss.cache.commands.read.GetKeyValueCommand;
@@ -82,6 +83,7 @@
 //   protected boolean usingVersionedInvalidation = false;
 
    protected MVCCNodeHelper helper;
+   protected BuddyFqnTransformer buddyFqnTransformer;
 
 
    /**
@@ -93,7 +95,8 @@
 
    @Inject
    protected void injectDependencies(TransactionTable txTable, CacheLoaderManager clm, Configuration configuration,
-                                     DataContainer dataContainer, Notifier notifier, MVCCNodeHelper helper)
+                                     DataContainer dataContainer, Notifier notifier, MVCCNodeHelper helper, 
+                                     BuddyFqnTransformer buddyFqnTransformer)
    {
       this.txTable = txTable;
       this.clm = clm;
@@ -383,6 +386,14 @@
          }
          return;
       }
+      
+      // The children of a dead buddy backup root must be Integer.
+      // Ensure that we didn't pull in the wrong type from a cache loader
+      // (e.g. FileCacheLoader) that can only return String
+      if (buddyFqnTransformer != null && buddyFqnTransformer.isDeadBackupRoot(fqn))
+      {
+         childrenNames = buddyFqnTransformer.getDeadBackupRootChildren(childrenNames);
+      }
 
       // Create if node had not been created already
       if (node == null)

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java	2010-05-05 09:01:58 UTC (rev 8399)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java	2010-05-08 20:30:47 UTC (rev 8400)
@@ -26,6 +26,7 @@
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.Modification;
 import org.jboss.cache.NodeSPI;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
 import org.jboss.cache.commands.AbstractVisitor;
 import org.jboss.cache.commands.VisitableCommand;
 import org.jboss.cache.commands.WriteCommand;
@@ -77,6 +78,7 @@
    CacheLoader loader;
    private CacheLoaderManager loaderManager;
    private boolean statsEnabled;
+   private BuddyFqnTransformer buddyFqnTransformer;
 
    public CacheStoreInterceptor()
    {
@@ -85,7 +87,8 @@
    }
 
    @Inject
-   protected void init(CacheLoaderManager loaderManager, TransactionManager txManager, CacheLoaderConfig clConfig)
+   protected void init(CacheLoaderManager loaderManager, TransactionManager txManager, CacheLoaderConfig clConfig, 
+         BuddyFqnTransformer buddyFqnTransformer)
    {
       // never inject a CacheLoader at this stage - only a CacheLoaderManager, since the CacheLoaderManager only creates a CacheLoader instance when it @Starts.
       this.loaderManager = loaderManager;
@@ -309,7 +312,15 @@
       //recurse
       Set childrenNames = loader.getChildrenNames(fqn);
       if (childrenNames != null)
-      {
+      {         
+         // The children of a dead buddy backup root must be Integer.
+         // Ensure that we didn't pull in the wrong type from a cache loader
+         // (e.g. FileCacheLoader) that can only return String
+         if (buddyFqnTransformer != null && buddyFqnTransformer.isDeadBackupRoot(fqn))
+         {
+            childrenNames = buddyFqnTransformer.getDeadBackupRootChildren(childrenNames);
+         }
+         
          for (Object child : childrenNames)
          {
             recursiveMove(Fqn.fromRelativeElements(fqn, child), Fqn.fromRelativeElements(newFqn, child));

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java	2010-05-05 09:01:58 UTC (rev 8399)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java	2010-05-08 20:30:47 UTC (rev 8400)
@@ -26,6 +26,7 @@
 import org.jboss.cache.Fqn;
 import org.jboss.cache.InvocationContext;
 import org.jboss.cache.NodeSPI;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
 import org.jboss.cache.commands.WriteCommand;
 import org.jboss.cache.commands.read.GetChildrenNamesCommand;
 import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -86,6 +87,7 @@
 
    protected boolean isActivation = false;
    protected boolean usingVersionedInvalidation = false;
+   protected BuddyFqnTransformer buddyFqnTransformer;
 
 
    /**
@@ -97,7 +99,8 @@
 
    @Inject
    protected void injectDependencies(TransactionTable txTable, CacheLoaderManager clm, Configuration configuration,
-                                     DataContainer dataContainer, LockManager lockManager, Notifier notifier)
+                                     DataContainer dataContainer, LockManager lockManager, Notifier notifier, 
+                                     BuddyFqnTransformer buddyFqnTransformer)
    {
       this.txTable = txTable;
       this.clm = clm;
@@ -106,6 +109,7 @@
       this.dataContainer = dataContainer;
       this.lockManager = lockManager;
       this.notifier = notifier;
+      this.buddyFqnTransformer = buddyFqnTransformer;
    }
 
    @Start
@@ -383,6 +387,14 @@
          }
          return;
       }
+      
+      // The children of a dead buddy backup root must be Integer.
+      // Ensure that we didn't pull in the wrong type from a cache loader
+      // (e.g. FileCacheLoader) that can only return String
+      if (buddyFqnTransformer != null && buddyFqnTransformer.isDeadBackupRoot(fqn))
+      {
+         childrenNames = buddyFqnTransformer.getDeadBackupRootChildren(childrenNames);
+      }
 
       // Create if node had not been created already
       if (node == null)



More information about the jbosscache-commits mailing list