[jbosscache-commits] JBoss Cache SVN: r6368 - in core/branches/2.2.X/src/main/java/org/jboss/cache: buddyreplication and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Jul 22 21:15:41 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-07-22 21:15:41 -0400 (Tue, 22 Jul 2008)
New Revision: 6368

Modified:
   core/branches/2.2.X/src/main/java/org/jboss/cache/Fqn.java
   core/branches/2.2.X/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
   core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
   core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
Log:
Performance tweaks

Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/Fqn.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/Fqn.java	2008-07-23 00:52:12 UTC (rev 6367)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/Fqn.java	2008-07-23 01:15:41 UTC (rev 6368)
@@ -188,6 +188,21 @@
    }
 
    /**
+    * Retrieves an Fqn that represents the list of elements passed in.
+    *
+    * @param names list of elements that comprise the Fqn
+    * @param safe  if true, the list passed in is not defensively copied but used directly.  <b>Use with care.</b>  Make sure
+    *              you know what you are doing before you pass in a <tt>true</tt> value to <tt>safe</tt>, as it can have adverse effects on
+    *              performance or correctness.  The defensive copy of list elements is not just for safety but also for performance as
+    *              an appropriare List implementation is used, which works well with Fqn operations.
+    * @return an Fqn
+    */
+   public static <E> Fqn<E> fromList(List<E> elements, boolean safe)
+   {
+      return new Fqn<E>(true, elements, safe);
+   }
+
+   /**
     * If safe is false, Collections.unmodifiableList() is used to wrap the list passed in.  This is an optimisation so
     * Fqn.fromString(), probably the most frequently used factory method, doesn't end up needing to use the unmodifiableList()
     * since it creates the list internally.

Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java	2008-07-23 00:52:12 UTC (rev 6367)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java	2008-07-23 01:15:41 UTC (rev 6368)
@@ -1,11 +1,11 @@
 package org.jboss.cache.buddyreplication;
 
+import org.jboss.cache.CacheException;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.CacheException;
 import org.jgroups.Address;
 
+import java.util.ArrayList;
 import java.util.List;
-import java.util.ArrayList;
 
 /**
  * Knows how to transform between fqn and buddy-formated fqns.
@@ -47,7 +47,7 @@
       elements.add(buddyGroupName);
       elements.addAll(origFqn.peekElements());
 
-      return Fqn.fromList(elements);
+      return Fqn.fromList(elements, true);
    }
 
    /**
@@ -68,7 +68,7 @@
       elements.add(buddyGroupRoot.get(1));
       elements.addAll(origFqn.peekElements());
 
-      return Fqn.fromList(elements);
+      return Fqn.fromList(elements, true);
    }
 
    public boolean isBackupFqn(Fqn name)

Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java	2008-07-23 00:52:12 UTC (rev 6367)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java	2008-07-23 01:15:41 UTC (rev 6368)
@@ -24,7 +24,16 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
 
 /**
  * An enhanced marshaller for RPC calls between CacheImpl instances.
@@ -676,7 +685,7 @@
          {
             elements.add(unmarshallObject(in, refMap));
          }
-         fqn = Fqn.fromList(elements);
+         fqn = Fqn.fromList(elements, true);
       }
       else
       {

Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java	2008-07-23 00:52:12 UTC (rev 6367)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java	2008-07-23 01:15:41 UTC (rev 6368)
@@ -14,6 +14,7 @@
 import org.jgroups.MembershipListener;
 import org.jgroups.Message;
 import org.jgroups.MessageListener;
+import org.jgroups.blocks.GroupRequest;
 import org.jgroups.blocks.RpcDispatcher;
 import org.jgroups.blocks.RspFilter;
 import org.jgroups.util.Rsp;
@@ -105,7 +106,7 @@
          throw new NotSerializableException("RpcDispatcher returned a null.  This is most often caused by args for " + command.getClass().getSimpleName() + " not being serializable.");
       }
 
-      if (retval.isEmpty() || containsOnlyNulls(retval))
+      if (mode == GroupRequest.GET_NONE || retval.isEmpty() || containsOnlyNulls(retval))
          return null;
       else
          return retval;




More information about the jbosscache-commits mailing list