[jboss-cvs] JBossCache/src/org/jboss/cache/buddyreplication ...

Manik Surtani msurtani at jboss.com
Mon Jan 29 20:22:57 EST 2007


  User: msurtani
  Date: 07/01/29 20:22:57

  Modified:    src/org/jboss/cache/buddyreplication  BuddyManager.java
  Log:
  Fixed dodgy persistent state tfr without transient state breakage
  
  Revision  Changes    Path
  1.63      +43 -1     JBossCache/src/org/jboss/cache/buddyreplication/BuddyManager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BuddyManager.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/buddyreplication/BuddyManager.java,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -b -r1.62 -r1.63
  --- BuddyManager.java	19 Jan 2007 16:00:32 -0000	1.62
  +++ BuddyManager.java	30 Jan 2007 01:22:57 -0000	1.63
  @@ -13,6 +13,7 @@
   import org.jboss.cache.CacheImpl;
   import org.jboss.cache.Fqn;
   import org.jboss.cache.Region;
  +import org.jboss.cache.util.ExposedByteArrayOutputStream;
   import org.jboss.cache.config.BuddyReplicationConfig;
   import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
   import org.jboss.cache.lock.TimeoutException;
  @@ -21,8 +22,10 @@
   import org.jboss.cache.marshall.MethodDeclarations;
   import org.jboss.cache.statetransfer.StateTransferManager;
   import org.jboss.util.stream.MarshalledValueInputStream;
  +import org.jboss.util.stream.MarshalledValueOutputStream;
   import org.jgroups.Address;
   import org.jgroups.View;
  +import org.jgroups.util.Util;
   
   import java.io.ByteArrayInputStream;
   import java.util.ArrayList;
  @@ -667,7 +670,7 @@
   
            try
            {
  -            byte[] state = cache.generateState(fqn, timeouts[i], force, false);
  +            byte[] state = generateState(fqn, timeouts[i], force, false);
               if (log.isDebugEnabled())
               {
                  log.debug("acquireState(): got state");
  @@ -709,6 +712,45 @@
      }
   
      /**
  +    * Returns the state for the portion of the cache named by <code>fqn</code>.
  +    * <p/>
  +    * State returned is a serialized byte[][], element 0 is the transient state
  +    * (or null), and element 1 is the persistent state (or null).
  +    *
  +    * @param fqn            Fqn indicating the uppermost node in the
  +    *                       portion of the cache whose state should be returned.
  +    * @param timeout        max number of ms this method should wait to acquire
  +    *                       a read lock on the nodes being transferred
  +    * @param force          if a read lock cannot be acquired after
  +    *                       <code>timeout</code> ms, should the lock acquisition
  +    *                       be forced, and any existing transactions holding locks
  +    *                       on the nodes be rolled back? <strong>NOTE:</strong>
  +    *                       In release 1.2.4, this parameter has no effect.
  +    * @param suppressErrors should any Throwable thrown be suppressed?
  +    * @return a serialized byte[][], element 0 is the transient state
  +    *         (or null), and element 1 is the persistent state (or null).
  +    */
  +   public byte[] generateState(Fqn fqn, long timeout, boolean force, boolean suppressErrors) throws Throwable
  +   {
  +
  +      MarshalledValueOutputStream out = null;
  +      byte[] result = null;
  +      try
  +      {
  +         ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(16 * 1024);
  +         out = new MarshalledValueOutputStream(baos);
  +         cache.getStateTransferManager().getState(out, fqn, timeout, force, suppressErrors);
  +         result = baos.getRawBuffer();
  +      }
  +      finally
  +      {
  +         Util.close(out);
  +      }
  +
  +      return result;
  +   }
  +
  +   /**
       * Called by the BuddyGroupMembershipMonitor every time a view change occurs.
       */
      private void broadcastBuddyPoolMembership()
  
  
  



More information about the jboss-cvs-commits mailing list