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

Manik Surtani msurtani at jboss.com
Wed Jul 19 04:29:17 EDT 2006


  User: msurtani
  Date: 06/07/19 04:29:17

  Modified:    src/org/jboss/cache/loader/bdbje  BdbjeCacheLoader.java
  Log:
  Migration to new CacheLoader interface
  
  Revision  Changes    Path
  1.12      +112 -88   JBossCache/src/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BdbjeCacheLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -b -r1.11 -r1.12
  --- BdbjeCacheLoader.java	6 May 2006 10:01:54 -0000	1.11
  +++ BdbjeCacheLoader.java	19 Jul 2006 08:29:17 -0000	1.12
  @@ -9,15 +9,29 @@
   import com.sleepycat.je.*;
   import com.sleepycat.je.util.DbDump;
   import com.sleepycat.je.util.DbLoad;
  -import org.jboss.cache.Fqn;
  -import org.jboss.cache.Modification;
  -import org.jboss.cache.TreeCache;
  -import org.jboss.cache.loader.CacheLoader;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.jboss.cache.CacheSPI;
  +import org.jboss.cache.Fqn;
  +import org.jboss.cache.Modification;
  +import org.jboss.cache.loader.AbstractCacheLoader;
   
  -import java.io.*;
  -import java.util.*;
  +import java.io.BufferedReader;
  +import java.io.ByteArrayInputStream;
  +import java.io.ByteArrayOutputStream;
  +import java.io.File;
  +import java.io.IOException;
  +import java.io.InputStreamReader;
  +import java.io.PrintStream;
  +import java.io.Serializable;
  +import java.util.Collections;
  +import java.util.HashMap;
  +import java.util.HashSet;
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.Map;
  +import java.util.Properties;
  +import java.util.Set;
   
   
   /**
  @@ -33,9 +47,10 @@
    *
    * @author Mark Hayes May 16, 2004
    * @author Bela Ban
  - * @version $Id: BdbjeCacheLoader.java,v 1.11 2006/05/06 10:01:54 msurtani Exp $
  + * @version $Id: BdbjeCacheLoader.java,v 1.12 2006/07/19 08:29:17 msurtani Exp $
    */
  -public class BdbjeCacheLoader implements CacheLoader {
  +public class BdbjeCacheLoader extends AbstractCacheLoader
  +{
   
      private static final int MAX_TXN_RETRIES = 10;
      private static final char LOWEST_UTF_CHAR = '\u0001';
  @@ -43,7 +58,6 @@
      private static final Log log = LogFactory.getLog(BdbjeCacheLoader.class);
   
      private String configStr;
  -   private TreeCache treeCache;
      private Environment env;
      private String cacheDbName;
      private String catalogDbName;
  @@ -97,9 +111,9 @@
         log.trace("Starting BdbjeCacheLoader instance.");
         checkNotOpen();
   
  -      if (treeCache == null) {
  +      if (cache == null) {
            throw new IllegalStateException(
  -            "A non-null Cache property (TreeCache object) is required");
  +            "A non-null Cache property (CacheSPI object) is required");
         }
         if (configStr == null) {
            configStr=System.getProperty("java.io.tmpdir");
  @@ -123,7 +137,7 @@
            cacheDbName = configStr.substring(offset + 1);
         } else {
            homeDir = new File(configStr);
  -         cacheDbName = treeCache.getClusterName();
  +         cacheDbName = cache.getClusterName();
         }
         catalogDbName = cacheDbName + "_class_catalog";
   
  @@ -132,7 +146,7 @@
          * databases.  However, we always create a transactional environment
          * since it may be shared by transactional and non-transactional caches.
          */
  -      transactional = treeCache.getTransactionManager() != null;
  +      transactional = cache.getTransactionManager() != null;
   
         try {
            /* Open the environment, creating it if it doesn't exist. */
  @@ -235,9 +249,10 @@
      /**
       * Sets the TreeCache owner of this cache loader.
       */
  -   public void setCache(TreeCache c) {
  +   public void setCache(CacheSPI c)
  +   {
  +       super.setCache(c);
         checkNotOpen();
  -      treeCache = c;
      }
   
      /**
  @@ -247,7 +262,7 @@
       * browser applications.  Calling this method as part of a run-time
       * transaction is not recommended.
       */
  -   public Set getChildrenNames(Fqn name)
  +   public Set<String> getChildrenNames(Fqn name)
         throws Exception {
   
         checkOpen();
  @@ -259,7 +274,7 @@
   
         String namePart = "";
         int namePartIndex = name.size();
  -      Set set = null;
  +      Set<String> set = null;
   
         Cursor cursor = cacheDb.openCursor(null, null);
         try {
  @@ -272,7 +287,7 @@
                  break;
               }
               if (set == null) {
  -               set = new HashSet();
  +               set = new HashSet<String>();
               }
               Fqn childName = makeKeyObject(keyEntry);
               namePart = childName.get(namePartIndex).toString();
  @@ -429,6 +444,7 @@
         }
      }
   
  +
      /**
       * Internal version of put(Fqn,Map) that allows passing a
       * transaction.
  @@ -482,9 +498,8 @@
       * Intended to be used in a non-transactional environment, but will use
       * auto-commit in a transactional environment.
       */
  -   public void put(List modifications)
  -      throws Exception {
  -
  +   public void put(List<Modification> modifications) throws Exception
  +    {
         checkOpen();
         checkNonNull(modifications, "modifications");
   
  @@ -693,9 +708,8 @@
       * be called later with the same tx value.  Performs retries if necessary to
       * resolve deadlocks.</p>
       */
  -   public void prepare(Object tx, List modifications, boolean onePhase)
  -      throws Exception {
  -
  +   public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
  +    {
         checkOpen();
         checkNonNull(modifications, "modifications");
         if (!onePhase) {
  @@ -868,6 +882,16 @@
         openDatabases();
      }
   
  +    public byte[] loadState(Fqn subtree) throws Exception
  +    {
  +        throw new UnsupportedOperationException("setting and loading state for specific Fqns not supported");
  +    }
  +
  +    public void storeState(byte[] state, Fqn subtree) throws Exception
  +    {
  +        throw new UnsupportedOperationException("setting and loading state for specific Fqns not supported");
  +    }
  +
      /**
       * Loads one database in ASCII format, stopping at the DATA=END marker line
       * or EOF.
  
  
  



More information about the jboss-cvs-commits mailing list