You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2013/08/08 04:43:04 UTC

svn commit: r1511561 - in /commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram: RamFileObject.java RamFileSystem.java RamFileSystemConfigBuilder.java

Author: ggregory
Date: Thu Aug  8 02:43:04 2013
New Revision: 1511561

URL: http://svn.apache.org/r1511561
Log:
[VFS-483][RAM] Many suggestions to improve the RAM file provider. Use long for FS size limit.

Modified:
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileObject.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystem.java
    commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystemConfigBuilder.java

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileObject.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileObject.java?rev=1511561&r1=1511560&r2=1511561&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileObject.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileObject.java Thu Aug  8 02:43:04 2013
@@ -253,7 +253,7 @@ public class RamFileObject extends Abstr
     }
 
     /**
-     * @return Returns the size of the RAMFileData
+     * @return Returns the size of the {@link RamFileData}.
      */
     int size()
     {
@@ -271,8 +271,7 @@ public class RamFileObject extends Abstr
         final FileSystemOptions afsOptions = afs.getFileSystemOptions();
         if (afsOptions != null)
         {
-            // A future implementation may allow longs...
-            final int maxSize = RamFileSystemConfigBuilder.getInstance().getMaxSize(afsOptions);
+            final long maxSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(afsOptions);
             if (afs.size() + newSize - this.size() > maxSize)
             {
                 throw new IOException("FileSystem capacity (" + maxSize + ") exceeded.");

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystem.java?rev=1511561&r1=1511560&r2=1511561&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystem.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystem.java Thu Aug  8 02:43:04 2013
@@ -300,9 +300,9 @@ public class RamFileSystem extends Abstr
     /**
      * @return Returns the size of the FileSystem
      */
-    int size()
+    long size()
     {
-        int size = 0;
+        long size = 0;
         synchronized (cache)
         {
             final Iterator<RamFileData> iter = cache.values().iterator();

Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystemConfigBuilder.java?rev=1511561&r1=1511560&r2=1511561&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystemConfigBuilder.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystemConfigBuilder.java Thu Aug  8 02:43:04 2013
@@ -60,13 +60,28 @@ public final class RamFileSystemConfigBu
     }
 
     /**
+     * Defaults to {@link Integer#MAX_VALUE}
+     * 
      * @param opts The FileSystem options.
      * @return The maximum size of the file.
-     * @see #setMaxSize
+     * @see #setMaxSize(FileSystemOptions, long)
+     * @since 2.1
+     */
+    public long getLongMaxSize(final FileSystemOptions opts)
+    {
+        return getLong(opts, MAX_SIZE_KEY, Long.MAX_VALUE);
+    }
+
+    /**
+     * Defaults to {@link Integer#MAX_VALUE}
+     * 
+     * @param opts The FileSystem options.
+     * @return The maximum size of the file. The next major version will change the return type to a long.
+     * @see #setMaxSize(FileSystemOptions, int)
      */
     public int getMaxSize(final FileSystemOptions opts)
     {
-        return getInteger(opts, MAX_SIZE_KEY, Integer.MAX_VALUE);
+        return getLong(opts, MAX_SIZE_KEY, Long.valueOf(Integer.MAX_VALUE)).intValue();
     }
 
     /**
@@ -74,10 +89,23 @@ public final class RamFileSystemConfigBu
      *
      * @param opts The FileSystem options.
      * @param sizeInBytes The maximum file size.
+     * @deprecated Use {@link #setMaxSize(FileSystemOptions, long)}
      */
+    @Deprecated
     public void setMaxSize(final FileSystemOptions opts, final int sizeInBytes)
     {
-        setParam(opts, MAX_SIZE_KEY, Integer.valueOf(sizeInBytes));
+        setParam(opts, MAX_SIZE_KEY, Long.valueOf(sizeInBytes));
+    }
+
+    /**
+     * Sets the maximum size of the file system.
+     *
+     * @param opts The FileSystem options.
+     * @param sizeInBytes The maximum file size.
+     */
+    public void setMaxSize(final FileSystemOptions opts, final long sizeInBytes)
+    {
+        setParam(opts, MAX_SIZE_KEY, Long.valueOf(sizeInBytes));
     }
 
 }