[jboss-cvs] JBossCache/src/org/jboss/cache/loader/jdbm ...

Vladmir Blagojevic vladimir.blagojevic at jboss.com
Tue Sep 5 11:54:19 EDT 2006


  User: vblagojevic
  Date: 06/09/05 11:54:19

  Modified:    src/org/jboss/cache/loader/jdbm  JdbmCacheLoader.java
  Log:
  [JBCACHE-748] Make JdbmCacheLoader use the standard binary format for persistent state transfer
  
  Revision  Changes    Path
  1.12      +27 -130   JBossCache/src/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: JdbmCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -b -r1.11 -r1.12
  --- JdbmCacheLoader.java	31 Aug 2006 14:56:46 -0000	1.11
  +++ JdbmCacheLoader.java	5 Sep 2006 15:54:19 -0000	1.12
  @@ -13,6 +13,7 @@
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.buddyreplication.BuddyManager;
   import org.jboss.cache.loader.AbstractCacheLoader;
  +import org.jboss.cache.loader.NodeData;
   import org.jboss.cache.marshall.RegionManager;
   import org.jboss.cache.optimistic.FqnComparator;
   
  @@ -54,7 +55,7 @@
    * plans to fix this.
    *
    * @author Elias Ross
  - * @version $Id: JdbmCacheLoader.java,v 1.11 2006/08/31 14:56:46 vblagojevic Exp $
  + * @version $Id: JdbmCacheLoader.java,v 1.12 2006/09/05 15:54:19 vblagojevic Exp $
    */
   public class JdbmCacheLoader extends AbstractCacheLoader
   {
  @@ -550,110 +551,8 @@
         transactions.remove(tx);
      }
   
  -   /*public byte[] loadEntireState()
  -      throws Exception
  -   {
  -      return loadState(Fqn.ROOT);
  -   }*/
  -
  -   /**
  -    * Export the contents of the databases as a byte array.
  -    * If the databases are empty a zero-lenth array is returned.
  -    * 
  -    * kept as a reference until 
  -    * http://jira.jboss.com/jira/browse/JBCACHE-748
  -    * is fixed
  -    */
  -   /*public byte[] loadState(Fqn subtree)
  -      throws Exception
  -   {
  -      ClassLoader currentCL = Thread.currentThread().getContextClassLoader();
  -      
  -      try
  -      {
  -         // Set the TCCL to any classloader registered for subtree
  -         setUnmarshallingClassLoader(subtree);
  -         
  -         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
  -         ObjectOutputStream oos = new ObjectOutputStream(baos);
  -   
  -         synchronized (tree) {
  -            TupleBrowser browser = tree.browse(subtree);
  -            Tuple t = new Tuple();
  -            while (browser.getNext(t)) {
  -               Fqn fqn = (Fqn)t.getKey();
  -               if (!fqn.isChildOrEquals(subtree))
  -                  break;
  -               oos.writeObject(fqn);
  -               oos.writeObject(t.getValue());
  -            }
  -         }
  -         oos.flush();
  -         return baos.toByteArray();
  -      }
  -      finally
  -      {
  -         Thread.currentThread().setContextClassLoader(currentCL);
  -      }
  -   }*/
  -
  -   /**
  -    * Replace the contents of the databases with the given exported data.
  -    * If state is null or zero-length, the databases will be cleared.
  -    */
  -   /*public void storeEntireState(byte[] state)
  -      throws Exception
  -   {
  -      storeState(state, Fqn.ROOT);
  -   }*/
  -
  -   /**
  -    * Replace the contents of the databases with the given exported data.
  -    * If state is null or zero-length, the databases will be cleared.
  -    * 
  -    *  kept as a reference until 
  -    * http://jira.jboss.com/jira/browse/JBCACHE-748
  -    * is fixed
  -    */
  -   /*public void storeState(byte[] state, Fqn subtree) throws Exception 
  -   {
  -      ClassLoader currentCL = Thread.currentThread().getContextClassLoader();
  -      try
  -      {
  -         // Set the TCCL to any classloader registered for subtree
  -         setUnmarshallingClassLoader(subtree);
  -         
  -         ByteArrayInputStream bais = new ByteArrayInputStream(state);
  -         ObjectInputStream ois = new ObjectInputStream(bais);
  -         
  -         erase0(subtree);
  -         
  -         boolean moveToBuddy = 
  -            subtree.isChildOf(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN) && subtree.size() > 1;
  -   
  -         // store new state
  -         Fqn storeFqn;
  -         while (bais.available() > 0) {
  -            Fqn fqn = (Fqn)ois.readObject();
  -   
  -            if (moveToBuddy)
  -               storeFqn = BuddyManager.getBackupFqn(subtree, fqn);
  -            else
  -               storeFqn = fqn;
  -            
  -            Object value = ois.readObject();
  -            tree.insert(storeFqn, value, true);
  -         } 
  -         commit();
  -      }
  -      finally
  -      {
  -         Thread.currentThread().setContextClassLoader(currentCL);
  -      }
  -   }*/
  -   
      /*
  -    *TODO http://jira.jboss.com/jira/browse/JBCACHE-748
  +    *
       * 
       */
      public void loadEntireState(ObjectOutputStream os) throws Exception
  @@ -661,7 +560,7 @@
         loadState(Fqn.ROOT,os);
      }
      /*
  -    *TODO http://jira.jboss.com/jira/browse/JBCACHE-748
  +    *
       * 
       */
      public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
  @@ -682,11 +581,10 @@
                  Fqn fqn = (Fqn) t.getKey();
                  if (!fqn.isChildOrEquals(subtree))
                     break;
  -               os.writeObject(fqn);
  -               os.writeObject(t.getValue());
  +               NodeData nd = new NodeData(fqn,get(fqn));
  +               os.writeObject(nd);
               }
            }
  -         os.flush();         
         }
         finally
         {
  @@ -694,7 +592,7 @@
         }
      }
      /*
  -    *TODO http://jira.jboss.com/jira/browse/JBCACHE-748
  +    *
       * 
       */
      public void storeEntireState(ObjectInputStream is) throws Exception
  @@ -703,10 +601,10 @@
      }
      
      /*
  -    *TODO http://jira.jboss.com/jira/browse/JBCACHE-748
  +    *
       * 
       */
  -   public void storeState(Fqn subtree, ObjectInputStream is) throws Exception
  +   public void storeState(Fqn subtree, ObjectInputStream in) throws Exception
      {
         ClassLoader currentCL = Thread.currentThread().getContextClassLoader();
         try
  @@ -716,21 +614,20 @@
            
            erase0(subtree);
            
  -         boolean moveToBuddy = 
  -            subtree.isChildOf(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN) && subtree.size() > 1;
  +         boolean moveToBuddy = subtree.isChildOf(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN) && subtree.size() > 1;
      
  +         NodeData nd;
  +         Fqn fqn;
            // store new state
  -         Fqn storeFqn;
  -         while (is.available() > 0) {
  -            Fqn fqn = (Fqn)is.readObject();
  -   
  +         for (nd = (NodeData) in.readObject(); nd != null && !nd.isMarker(); nd = (NodeData) in.readObject())
  +         {
               if (moveToBuddy)
  -               storeFqn = BuddyManager.getBackupFqn(subtree, fqn);
  +               fqn = BuddyManager.getBackupFqn(subtree, nd.getFqn());
               else
  -               storeFqn = fqn;
  +               fqn = nd.getFqn();
  +
  +            put0(fqn, nd.getAttributes());
               
  -            Object value = is.readObject();
  -            tree.insert(storeFqn, value, true);
            } 
            commit();
         }
  
  
  



More information about the jboss-cvs-commits mailing list