[infinispan-commits] Infinispan SVN: r1583 - in trunk: core/src/main/java/org/infinispan/loaders/bucket and 1 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed Mar 10 06:17:39 EST 2010


Author: manik.surtani at jboss.com
Date: 2010-03-10 06:17:38 -0500 (Wed, 10 Mar 2010)
New Revision: 1583

Modified:
   trunk/cachestore/cloud/src/main/java/org/infinispan/loaders/cloud/CloudCacheStore.java
   trunk/core/src/main/java/org/infinispan/loaders/bucket/BucketBasedCacheStore.java
   trunk/core/src/main/java/org/infinispan/loaders/file/FileCacheStore.java
Log:
[ISPN-322] (BucketBasedCacheStore - insertBucket and updateBucket should be combined)

Modified: trunk/cachestore/cloud/src/main/java/org/infinispan/loaders/cloud/CloudCacheStore.java
===================================================================
--- trunk/cachestore/cloud/src/main/java/org/infinispan/loaders/cloud/CloudCacheStore.java	2010-03-09 16:01:38 UTC (rev 1582)
+++ trunk/cachestore/cloud/src/main/java/org/infinispan/loaders/cloud/CloudCacheStore.java	2010-03-10 11:17:38 UTC (rev 1583)
@@ -257,7 +257,7 @@
    }
 
    @Override
-   protected void insertBucket(Bucket bucket) throws CacheLoaderException {
+   protected void updateBucket(Bucket bucket) throws CacheLoaderException {
       Blob blob = blobStore.newBlob(encodeBucketName(bucket.getBucketName()));
       writeToBlob(blob, bucket);
 
@@ -306,11 +306,6 @@
       }
    }
 
-   @Override
-   protected void updateBucket(Bucket bucket) throws CacheLoaderException {
-      insertBucket(bucket);
-   }
-
    private void writeToBlob(Blob blob, Bucket bucket) throws CacheLoaderException {
       long earliestExpiryTime = -1;
       for (InternalCacheEntry e : bucket.getEntries().values()) {

Modified: trunk/core/src/main/java/org/infinispan/loaders/bucket/BucketBasedCacheStore.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/loaders/bucket/BucketBasedCacheStore.java	2010-03-09 16:01:38 UTC (rev 1582)
+++ trunk/core/src/main/java/org/infinispan/loaders/bucket/BucketBasedCacheStore.java	2010-03-10 11:17:38 UTC (rev 1583)
@@ -95,11 +95,21 @@
     * @param bucket bucket to insert
     * @throws CacheLoaderException in case of problems with the store.
     */
-   protected abstract void insertBucket(Bucket bucket) throws CacheLoaderException;
+   protected void insertBucket(Bucket bucket) throws CacheLoaderException {
+      // the default behavior is to assume that updateBucket() will create a new bucket, so we just forward calls to
+      // updateBucket().
+      updateBucket(bucket);
+   }
 
    /**
     * Updates a bucket in the store with the Bucket passed in to the method.  This method assumes that the bucket
-    * already exists in the store.
+    * already exists in the store, however some implementations may choose to simply create a new bucket if the bucket
+    * does not exist.
+    * <p />
+    * The default behavior is that non-existent buckets are created on the fly.  If this is <i>not</i> the case in your
+    * implementation, then you would have to override {@link #insertBucket(Bucket)} as well so that it doesn't blindly
+    * forward calls to {@link #updateBucket(Bucket)}.
+    * <p />
     * @param bucket bucket to update.
     * @throws CacheLoaderException in case of problems with the store.
     */

Modified: trunk/core/src/main/java/org/infinispan/loaders/file/FileCacheStore.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/loaders/file/FileCacheStore.java	2010-03-09 16:01:38 UTC (rev 1582)
+++ trunk/core/src/main/java/org/infinispan/loaders/file/FileCacheStore.java	2010-03-10 11:17:38 UTC (rev 1583)
@@ -213,10 +213,6 @@
       return bucket;
    }
 
-   protected void insertBucket(Bucket bucket) throws CacheLoaderException {
-      updateBucket(bucket);
-   }
-
    public void updateBucket(Bucket b) throws CacheLoaderException {
       File f = new File(root, b.getBucketName());
       if (f.exists()) {



More information about the infinispan-commits mailing list