diff options
author | Colin Decker <cgdecker@google.com> | 2013-10-04 10:29:44 -0400 |
---|---|---|
committer | Colin Decker <cgdecker@google.com> | 2013-10-04 10:29:44 -0400 |
commit | f55a7a1ee3db58cb8a2f353cf46ee820b6784370 (patch) | |
tree | 36efdbe591b6bd3810442afbaf5a2148232b75cc /jimfs/src/main | |
parent | 1115312c0075580fc84c6c56eb9b85c900ff499e (diff) | |
download | jimfs-f55a7a1ee3db58cb8a2f353cf46ee820b6784370.tar.gz |
Remove ability to configure regular file storage for now.
Diffstat (limited to 'jimfs/src/main')
7 files changed, 8 insertions, 143 deletions
diff --git a/jimfs/src/main/java/com/google/jimfs/Jimfs.java b/jimfs/src/main/java/com/google/jimfs/Jimfs.java index e583ba3..80f51bd 100644 --- a/jimfs/src/main/java/com/google/jimfs/Jimfs.java +++ b/jimfs/src/main/java/com/google/jimfs/Jimfs.java @@ -167,7 +167,6 @@ public final class Jimfs { private final Set<String> roots = new LinkedHashSet<>(); private String workingDirectory; - private Storage storage = Storage.block(); private AttributeViews attributes = AttributeViews.basic(); private Configuration(PathType pathType) { @@ -207,13 +206,6 @@ public final class Jimfs { } /** - * Returns the storage configuration for the file system. - */ - public Storage getStorage() { - return storage; - } - - /** * Returns the configured set of attribute views for the file system. */ public AttributeViews getAttributeViews() { @@ -268,16 +260,6 @@ public final class Jimfs { } /** - * Sets the storage configuration to use for the file system. - * - * <p>The default configuration is for block storage using 8192 byte blocks. - */ - public Configuration setStorage(Storage storage) { - this.storage = checkNotNull(storage); - return this; - } - - /** * Sets the attribute views to use for the file system. * * <p>The default is the {@link AttributeViews#basic() basic} view only, to minimize overhead of diff --git a/jimfs/src/main/java/com/google/jimfs/Storage.java b/jimfs/src/main/java/com/google/jimfs/Storage.java deleted file mode 100644 index f87ad26..0000000 --- a/jimfs/src/main/java/com/google/jimfs/Storage.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2013 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.jimfs; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.nio.ByteBuffer; - -/** - * Configuration for file system storage. - * - * @author Colin Decker - */ -public final class Storage { - - /** - * The default block size. - */ - public static final int DEFAULT_BLOCK_SIZE = 8192; - - /** - * Returns a new storage configuration for block storage. This is the preferred type of storage - * to use. - * - * <p>Block storage keeps a central store of data blocks per file system and provides files with - * blocks to store their data in. As files are deleted, those blocks are returned to the file - * system and reused for new files, resulting in much faster writes and much less garbage - * collection during use of the file system. - * - * <p>If no other options are configured, the returned configuration uses heap memory and a block - * size of 8192 bytes. - */ - public static Storage block() { - return new Storage(); - } - - private boolean direct = false; - private int blockSize = DEFAULT_BLOCK_SIZE; - - private Storage() { - } - - /** - * Returns whether or not direct storage should be used. - */ - public boolean isDirect() { - return direct; - } - - /** - * Returns the block size to use if block storage is used. - */ - public int getBlockSize() { - return blockSize; - } - - /** - * Configures this storage to store data in heap memory (e.g. in {@code byte} arrays). - * - * <p>This is the default. - */ - public Storage heap() { - this.direct = false; - return this; - } - - /** - * Configures this storage to store data in direct/native memory (e.g. in - * {@linkplain ByteBuffer#allocateDirect(int) direct ByteBuffers}). This may have slight - * performance advantages in certain situations (such as transferring files to sockets) but in - * general {@linkplain #heap() heap} storage is preferred. - */ - public Storage direct() { - this.direct = true; - return this; - } - - /** - * Configures this storage to allocate files in blocks of the given {@code blockSize} bytes. - * - * <p>The default block size is 8192 bytes. - * - * @throws IllegalArgumentException if {@code blockSize} is not positive - */ - public Storage blockSize(int blockSize) { - checkArgument(blockSize > 0, "blockSize must be positive"); - this.blockSize = blockSize; - return this; - } -} diff --git a/jimfs/src/main/java/com/google/jimfs/internal/DirectDisk.java b/jimfs/src/main/java/com/google/jimfs/internal/DirectDisk.java index 52a766e..6e76ffa 100644 --- a/jimfs/src/main/java/com/google/jimfs/internal/DirectDisk.java +++ b/jimfs/src/main/java/com/google/jimfs/internal/DirectDisk.java @@ -18,8 +18,6 @@ package com.google.jimfs.internal; import static com.google.jimfs.internal.Util.nextPowerOf2; -import com.google.jimfs.Storage; - import java.nio.ByteBuffer; import java.util.Arrays; @@ -33,7 +31,7 @@ final class DirectDisk extends Disk { private ByteBuffer[] blocks = new ByteBuffer[256]; DirectDisk() { - this(Storage.DEFAULT_BLOCK_SIZE); + this(DEFAULT_BLOCK_SIZE); } /** diff --git a/jimfs/src/main/java/com/google/jimfs/internal/Disk.java b/jimfs/src/main/java/com/google/jimfs/internal/Disk.java index 7ceb160..612e433 100644 --- a/jimfs/src/main/java/com/google/jimfs/internal/Disk.java +++ b/jimfs/src/main/java/com/google/jimfs/internal/Disk.java @@ -33,6 +33,11 @@ import java.util.Arrays; abstract class Disk extends RegularFileStorage { /** + * 8K blocks. + */ + protected static final int DEFAULT_BLOCK_SIZE = 8192; + + /** * Fixed size of each block for this disk. */ protected final int blockSize; diff --git a/jimfs/src/main/java/com/google/jimfs/internal/HeapDisk.java b/jimfs/src/main/java/com/google/jimfs/internal/HeapDisk.java index 5457675..84005f4 100644 --- a/jimfs/src/main/java/com/google/jimfs/internal/HeapDisk.java +++ b/jimfs/src/main/java/com/google/jimfs/internal/HeapDisk.java @@ -18,8 +18,6 @@ package com.google.jimfs.internal; import static com.google.jimfs.internal.Util.nextPowerOf2; -import com.google.jimfs.Storage; - import java.nio.ByteBuffer; import java.util.Arrays; @@ -33,7 +31,7 @@ final class HeapDisk extends Disk { private byte[][] blocks = new byte[256][]; HeapDisk() { - this(Storage.DEFAULT_BLOCK_SIZE); + this(DEFAULT_BLOCK_SIZE); } /** diff --git a/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystems.java b/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystems.java index b1e4543..f0fea63 100644 --- a/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystems.java +++ b/jimfs/src/main/java/com/google/jimfs/internal/JimfsFileSystems.java @@ -52,7 +52,7 @@ final class JimfsFileSystems { private static JimfsFileStore createFileStore( Jimfs.Configuration config, PathService pathService) { AttributeService attributeService = new AttributeService(config.getAttributeViews()); - RegularFileStorage storage = RegularFileStorage.from(config.getStorage()); + RegularFileStorage storage = new HeapDisk(); FileFactory fileFactory = new FileFactory(storage); File superRoot = fileFactory.createDirectory(); diff --git a/jimfs/src/main/java/com/google/jimfs/internal/RegularFileStorage.java b/jimfs/src/main/java/com/google/jimfs/internal/RegularFileStorage.java index 430e263..52d88e8 100644 --- a/jimfs/src/main/java/com/google/jimfs/internal/RegularFileStorage.java +++ b/jimfs/src/main/java/com/google/jimfs/internal/RegularFileStorage.java @@ -16,8 +16,6 @@ package com.google.jimfs.internal; -import com.google.jimfs.Storage; - /** * Factory for creating new byte stores for regular files. May also actually store the bytes for * those stores. One piece of the file store implementation. @@ -27,18 +25,6 @@ import com.google.jimfs.Storage; abstract class RegularFileStorage { /** - * Returns a {@link RegularFileStorage} instance matching the given configuration. - */ - public static RegularFileStorage from(Storage configuration) { - int blockSize = configuration.getBlockSize(); - if (configuration.isDirect()) { - return new DirectDisk(blockSize); - } else { - return new HeapDisk(blockSize); - } - } - - /** * Creates a new, empty byte store. */ public abstract ByteStore createByteStore(); |