/** * Defaults to {@link Integer#MAX_VALUE}. * * @param opts The FileSystem options. * @return The maximum size of the file. * @see #setMaxSize(FileSystemOptions, long) * @since 2.1 */ public long getLongMaxSize(final FileSystemOptions opts) { return getLong(opts, MAX_SIZE_KEY, Long.MAX_VALUE); }
/** * 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)); }
/** * @param newSize * @throws IOException if the new size exceeds the limit */ synchronized void resize(final long newSize) throws IOException { final RamFileSystem afs = getAbstractFileSystem(); final FileSystemOptions afsOptions = afs.getFileSystemOptions(); if (afsOptions != null) { final long maxSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(afsOptions); if (afs.size() + newSize - this.size() > maxSize) { throw new IOException("FileSystem capacity (" + maxSize + ") exceeded."); } } this.data.resize(newSize); }
@Before public void setUp() throws Exception { manager = new DefaultFileSystemManager(); manager.addProvider("ram", new RamFileProvider()); manager.init(); // File Systems Options RamFileSystemConfigBuilder.getInstance().setMaxSize(zeroSizedFso, 0L); RamFileSystemConfigBuilder.getInstance().setMaxSize(smallSizedFso, 10L); }
/** * @param newSize * @throws IOException if the new size exceeds the limit */ synchronized void resize(final long newSize) throws IOException { final RamFileSystem afs = getAbstractFileSystem(); final FileSystemOptions afsOptions = afs.getFileSystemOptions(); if (afsOptions != null) { final long maxSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(afsOptions); if (afs.size() + newSize - this.size() > maxSize) { throw new IOException("FileSystem capacity (" + maxSize + ") exceeded."); } } this.data.resize(newSize); }
@Before public void setUp() throws Exception { manager = new DefaultFileSystemManager(); manager.addProvider("ram", new RamFileProvider()); manager.init(); // File Systems Options RamFileSystemConfigBuilder.getInstance().setMaxSize(zeroSizedFso, 0L); RamFileSystemConfigBuilder.getInstance().setMaxSize(smallSizedFso, 10L); }
/** * @param newSize * @throws IOException if the new size exceeds the limit */ synchronized void resize(final long newSize) throws IOException { final RamFileSystem afs = getAbstractFileSystem(); final FileSystemOptions afsOptions = afs.getFileSystemOptions(); if (afsOptions != null) { final long maxSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(afsOptions); if (afs.size() + newSize - this.size() > maxSize) { throw new IOException("FileSystem capacity (" + maxSize + ") exceeded."); } } this.data.resize(newSize); }
@Before public void setUp() throws Exception { manager = new DefaultFileSystemManager(); manager.addProvider("ram", new RamFileProvider()); manager.init(); // File Systems Options RamFileSystemConfigBuilder.getInstance().setMaxSize(zeroSizedFso, 0L); RamFileSystemConfigBuilder.getInstance().setMaxSize(smallSizedFso, 10L); }
/** * Defaults to {@link Integer#MAX_VALUE}. * * @param opts The FileSystem options. * @return The maximum size of the file. * @see #setMaxSize(FileSystemOptions, long) * @since 2.1 */ public long getLongMaxSize(final FileSystemOptions opts) { return getLong(opts, MAX_SIZE_KEY, Long.MAX_VALUE); }
/** * 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)); }
/** * @param newSize * @throws IOException * if the new size exceeds the limit */ synchronized void resize(final long newSize) throws IOException { final RamFileSystem afs = getAbstractFileSystem(); final FileSystemOptions afsOptions = afs.getFileSystemOptions(); if (afsOptions != null) { final long maxSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(afsOptions); if (afs.size() + newSize - this.size() > maxSize) { throw new IOException("FileSystem capacity (" + maxSize + ") exceeded."); } } this.data.resize(newSize); }
/** * Defaults to {@link Integer#MAX_VALUE}. * * @param opts The FileSystem options. * @return The maximum size of the file. * @see #setMaxSize(FileSystemOptions, long) * @since 2.1 */ public long getLongMaxSize(final FileSystemOptions opts) { return getLong(opts, MAX_SIZE_KEY, Long.MAX_VALUE); }
/** * 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)); }
@Test public void testFSOptions() throws Exception { // Default FS final FileObject fo1 = manager.resolveFile("ram:/"); final FileObject fo2 = manager.resolveFile("ram:/"); assertTrue("Both files should exist in the same fs instance.", fo1.getFileSystem() == fo2.getFileSystem()); FileSystemOptions fsOptions = fo1.getFileSystem().getFileSystemOptions(); long maxFilesystemSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(fsOptions); assertEquals("Filesystem option maxSize must be unlimited", Long.MAX_VALUE, maxFilesystemSize); // Small FS final FileObject fo3 = manager.resolveFile("ram:/fo3", smallSizedFso); final FileObject fo4 = manager.resolveFile("ram:/", smallSizedFso); assertTrue("Both files should exist in the same FileSystem instance.", fo3.getFileSystem() == fo4.getFileSystem()); assertTrue("Both files should exist in different FileSystem instance.", fo1.getFileSystem() != fo3.getFileSystem()); fsOptions = fo3.getFileSystem().getFileSystemOptions(); maxFilesystemSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(fsOptions); assertEquals("Filesystem option maxSize must be set", 10, maxFilesystemSize); }
/** * Defaults to {@link Integer#MAX_VALUE}. * * @param opts The FileSystem options. * @return The maximum size of the file. * @see #setMaxSize(FileSystemOptions, long) * @since 2.1 */ public long getLongMaxSize(final FileSystemOptions opts) { return getLong(opts, MAX_SIZE_KEY, Long.MAX_VALUE); }
/** * 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)); }
@Test public void testFSOptions() throws Exception { // Default FS final FileObject fo1 = manager.resolveFile("ram:/"); final FileObject fo2 = manager.resolveFile("ram:/"); assertTrue("Both files should exist in the same fs instance.", fo1.getFileSystem() == fo2.getFileSystem()); FileSystemOptions fsOptions = fo1.getFileSystem().getFileSystemOptions(); long maxFilesystemSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(fsOptions); assertEquals("Filesystem option maxSize must be unlimited", Long.MAX_VALUE, maxFilesystemSize); // Small FS final FileObject fo3 = manager.resolveFile("ram:/fo3", smallSizedFso); final FileObject fo4 = manager.resolveFile("ram:/", smallSizedFso); assertTrue("Both files should exist in the same FileSystem instance.", fo3.getFileSystem() == fo4.getFileSystem()); assertTrue("Both files should exist in different FileSystem instance.", fo1.getFileSystem() != fo3.getFileSystem()); fsOptions = fo3.getFileSystem().getFileSystemOptions(); maxFilesystemSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(fsOptions); assertEquals("Filesystem option maxSize must be set", 10, maxFilesystemSize); }
/** * 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 getLong(opts, MAX_SIZE_KEY, Long.valueOf(Integer.MAX_VALUE)).intValue(); }
/** * Sets the maximum size of the file system. * * @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, Long.valueOf(sizeInBytes)); }
@Test public void testFSOptions() throws Exception { // Default FS final FileObject fo1 = manager.resolveFile("ram:/"); final FileObject fo2 = manager.resolveFile("ram:/"); assertTrue("Both files should exist in the same fs instance.", fo1.getFileSystem() == fo2.getFileSystem()); FileSystemOptions fsOptions = fo1.getFileSystem().getFileSystemOptions(); long maxFilesystemSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(fsOptions); assertEquals("Filesystem option maxSize must be unlimited", Long.MAX_VALUE, maxFilesystemSize); // Small FS final FileObject fo3 = manager.resolveFile("ram:/fo3", smallSizedFso); final FileObject fo4 = manager.resolveFile("ram:/", smallSizedFso); assertTrue("Both files should exist in the same FileSystem instance.", fo3.getFileSystem() == fo4.getFileSystem()); assertTrue("Both files should exist in different FileSystem instance.", fo1.getFileSystem() != fo3.getFileSystem()); fsOptions = fo3.getFileSystem().getFileSystemOptions(); maxFilesystemSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(fsOptions); assertEquals("Filesystem option maxSize must be set", 10, maxFilesystemSize); }