/** * @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); }
/** * @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); }
/** * @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); }
/** * @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); }
@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); }
@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); }
@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); }