public class VirtualFileSystem
extends java.lang.Object
VirtualFileSystem allows to deal with data in terms of files, input and output streams.
VirtualFileSystem works over an Environment instance, so VirtualFileSystem is
a transactional file system with strong isolation guarantees. Any VirtualFileSystem operation requires
a Transaction instance. Even creation of VirtualFileSystem can be transactional (using
constructors VirtualFileSystem(Environment, VfsConfig, Transaction) and
VirtualFileSystem(Environment, VfsConfig, StoreConfig, Transaction)). An application working with
VirtualFileSystem should shutdown() file system before stopping itself.
To create a file, use createFile(Transaction, long, String) and createFile(Transaction, long, String) methods. To create file with unique pathname and specified path prefix, use createUniqueFile(Transaction, String). To open existing file or to create the new file, use openFile(Transaction, String, boolean).
To read File contents, open InputStream using readFile(Transaction, File), readFile(Transaction, File, long) and readFile(Transaction, long) methods. To write File contents, open OutputStream using appendFile(Transaction, File), writeFile(Transaction, File), writeFile(Transaction, File, long), writeFile(Transaction, long) and writeFile(Transaction, long, long) methods.
| Constructor and Description |
|---|
VirtualFileSystem(@NotNull jetbrains.exodus.env.Environment env)
Creates
VirtualFileSystem over specified Environment with default settings
VfsConfig.DEFAULT. |
VirtualFileSystem(@NotNull jetbrains.exodus.env.Environment env,
@NotNull VfsConfig config)
Creates
VirtualFileSystem over specified Environment with specified VfsConfig. |
VirtualFileSystem(@NotNull jetbrains.exodus.env.Environment env,
@NotNull VfsConfig config,
@NotNull jetbrains.exodus.env.StoreConfig contentsStoreConfig)
Creates
VirtualFileSystem over specified Environment with specified VfsConfig
and StoreConfig. |
VirtualFileSystem(@NotNull jetbrains.exodus.env.Environment env,
@NotNull VfsConfig config,
@NotNull jetbrains.exodus.env.StoreConfig contentsStoreConfig,
@Nullable jetbrains.exodus.env.Transaction txn)
Creates
VirtualFileSystem over specified Environment with specified VfsConfig
and StoreConfig inside specified Transaction. |
VirtualFileSystem(@NotNull jetbrains.exodus.env.Environment env,
@NotNull VfsConfig config,
@Nullable jetbrains.exodus.env.Transaction txn)
Creates
VirtualFileSystem over specified Environment with specified VfsConfig
inside specified Transaction. |
| Modifier and Type | Method and Description |
|---|---|
java.io.OutputStream |
appendFile(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull File file)
Returns OutputStream to write the contents of the specified file from the end of the file.
|
@NotNull File |
createFile(@NotNull jetbrains.exodus.env.Transaction txn,
long fileDescriptor,
@NotNull java.lang.String path)
Creates new file inside specified Transaction with specified file descriptor and path and returns
the File instance.
|
@NotNull File |
createFile(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull java.lang.String path)
Creates new file inside specified Transaction with specified path and returns
the File instance.
|
File |
createUniqueFile(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull java.lang.String pathPrefix)
Creates new File with unique auto-generated path starting with specified
pathPrefix. |
@Nullable File |
deleteFile(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull java.lang.String path)
Deletes existing file with the specified
path. |
long |
diskUsage(@NotNull jetbrains.exodus.env.Transaction txn)
Returns total size of all the files in the filesystem.
|
void |
dump(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull java.nio.file.Path directory) |
@Nullable IOCancellingPolicyProvider |
getCancellingPolicyProvider() |
@Nullable ClusterConverter |
getClusterConverter() |
VfsConfig |
getConfig() |
jetbrains.exodus.env.Environment |
getEnvironment() |
long |
getFileLength(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull File file) |
long |
getFileLength(@NotNull jetbrains.exodus.env.Transaction txn,
long fileDescriptor) |
@NotNull java.lang.Iterable<File> |
getFiles(@NotNull jetbrains.exodus.env.Transaction txn) |
long |
getNumberOfFiles(@NotNull jetbrains.exodus.env.Transaction txn) |
@Nullable File |
openFile(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull java.lang.String path,
boolean create)
Returns existing File with specified path or creates the new one if
create is true,
otherwise returns null. |
VfsInputStream |
readFile(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull File file)
Returns InputStream to read contents of the specified file from the beginning.
|
@NotNull VfsInputStream |
readFile(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull File file,
long fromPosition)
Returns InputStream to read contents of the specified file from the specified position.
|
VfsInputStream |
readFile(@NotNull jetbrains.exodus.env.Transaction txn,
long fileDescriptor)
Returns InputStream to read contents of the specified file from the beginning.
|
boolean |
renameFile(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull File origin,
@NotNull java.lang.String newPath)
Renames
origin file to the specified newPath and returns true if the file was actually
renamed. |
void |
setCancellingPolicyProvider(@NotNull IOCancellingPolicyProvider cancellingPolicyProvider) |
void |
setClusterConverter(@Nullable ClusterConverter clusterConverter) |
void |
shutdown()
Shuts down the
VirtualFileSystem. |
void |
touchFile(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull File file)
Touches the specified File, i.e.
|
java.io.OutputStream |
writeFile(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull File file)
Returns OutputStream to write the contents of the specified file from the beginning.
|
java.io.OutputStream |
writeFile(@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull File file,
long fromPosition)
Returns OutputStream to write the contents of the specified file from the specified position.
|
java.io.OutputStream |
writeFile(@NotNull jetbrains.exodus.env.Transaction txn,
long fileDescriptor)
Returns OutputStream to write the contents of the specified file from the beginning.
|
java.io.OutputStream |
writeFile(@NotNull jetbrains.exodus.env.Transaction txn,
long fileDescriptor,
long fromPosition)
Returns OutputStream to write the contents of the specified file from the specified position.
|
public VirtualFileSystem(@NotNull
@NotNull jetbrains.exodus.env.Environment env)
VirtualFileSystem over specified Environment with default settings
VfsConfig.DEFAULT.env - Environment instanceEnvironmentpublic VirtualFileSystem(@NotNull
@NotNull jetbrains.exodus.env.Environment env,
@NotNull
@NotNull VfsConfig config)
VirtualFileSystem over specified Environment with specified VfsConfig.public VirtualFileSystem(@NotNull
@NotNull jetbrains.exodus.env.Environment env,
@NotNull
@NotNull VfsConfig config,
@Nullable
@Nullable jetbrains.exodus.env.Transaction txn)
VirtualFileSystem over specified Environment with specified VfsConfig
inside specified Transaction.public VirtualFileSystem(@NotNull
@NotNull jetbrains.exodus.env.Environment env,
@NotNull
@NotNull VfsConfig config,
@NotNull
@NotNull jetbrains.exodus.env.StoreConfig contentsStoreConfig)
public VirtualFileSystem(@NotNull
@NotNull jetbrains.exodus.env.Environment env,
@NotNull
@NotNull VfsConfig config,
@NotNull
@NotNull jetbrains.exodus.env.StoreConfig contentsStoreConfig,
@Nullable
@Nullable jetbrains.exodus.env.Transaction txn)
public jetbrains.exodus.env.Environment getEnvironment()
VirtualFileSystem works over.@NotNull public @NotNull File createFile(@NotNull @NotNull jetbrains.exodus.env.Transaction txn, @NotNull @NotNull java.lang.String path)
txn - Transaction instancepath - file pathFileExistsException - if a File with specified path already existscreateFile(Transaction, long, String),
File@NotNull public @NotNull File createFile(@NotNull @NotNull jetbrains.exodus.env.Transaction txn, long fileDescriptor, @NotNull @NotNull java.lang.String path)
txn - Transaction instancefileDescriptor - file descriptorpath - file pathFileExistsException - if a File with specified path already existscreateFile(Transaction, String),
File,
File.getDescriptor()public File createUniqueFile(@NotNull @NotNull jetbrains.exodus.env.Transaction txn, @NotNull @NotNull java.lang.String pathPrefix)
pathPrefix.txn - Transaction instancepathPrefix - prefix which the path of the result will start fromFile,
File.getPath()@Nullable public @Nullable File openFile(@NotNull @NotNull jetbrains.exodus.env.Transaction txn, @NotNull @NotNull java.lang.String path, boolean create)
create is true,
otherwise returns null. If create is true it never returns null.public boolean renameFile(@NotNull
@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull
@NotNull File origin,
@NotNull
@NotNull java.lang.String newPath)
origin file to the specified newPath and returns true if the file was actually
renamed. Otherwise another file with the path newPath exists. File contents and file descriptor are
not affected.txn - Transaction instanceorigin - origin FilenewPath - new name of the filetrue if the file was actually renamed, otherwise another file with the path newPath existsFile,
File.getDescriptor()@Nullable public @Nullable File deleteFile(@NotNull @NotNull jetbrains.exodus.env.Transaction txn, @NotNull @NotNull java.lang.String path)
path.public long getNumberOfFiles(@NotNull
@NotNull jetbrains.exodus.env.Transaction txn)
txn - Transaction instanceVirtualFileSystem@NotNull public @NotNull java.lang.Iterable<File> getFiles(@NotNull @NotNull jetbrains.exodus.env.Transaction txn)
public long getFileLength(@NotNull
@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull
@NotNull File file)
public long getFileLength(@NotNull
@NotNull jetbrains.exodus.env.Transaction txn,
long fileDescriptor)
txn - Transaction instancefileDescriptor - file descriptorFile,
File.getDescriptor()public long diskUsage(@NotNull
@NotNull jetbrains.exodus.env.Transaction txn)
txn - Transaction instancepublic VfsInputStream readFile(@NotNull @NotNull jetbrains.exodus.env.Transaction txn, @NotNull @NotNull File file)
txn - Transaction instancefile - File instancereadFile(Transaction, long),
readFile(Transaction, File, long),
writeFile(Transaction, File),
writeFile(Transaction, long),
writeFile(Transaction, File, long),
writeFile(Transaction, long, long),
appendFile(Transaction, File),
touchFile(Transaction, File)public VfsInputStream readFile(@NotNull @NotNull jetbrains.exodus.env.Transaction txn, long fileDescriptor)
txn - Transaction instancefileDescriptor - file descriptorreadFile(Transaction, File),
readFile(Transaction, File, long),
writeFile(Transaction, File),
writeFile(Transaction, long),
writeFile(Transaction, File, long),
writeFile(Transaction, long, long),
appendFile(Transaction, File),
touchFile(Transaction, File),
File.getDescriptor()@NotNull public @NotNull VfsInputStream readFile(@NotNull @NotNull jetbrains.exodus.env.Transaction txn, @NotNull @NotNull File file, long fromPosition)
txn - Transaction instancefile - File instancefromPosition - file position to read fromreadFile(Transaction, File),
readFile(Transaction, long),
writeFile(Transaction, File),
writeFile(Transaction, long),
writeFile(Transaction, File, long),
writeFile(Transaction, long, long),
appendFile(Transaction, File),
touchFile(Transaction, File)public void touchFile(@NotNull
@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull
@NotNull File file)
txn - Transaction instancefile - File instancereadFile(Transaction, File),
readFile(Transaction, long),
readFile(Transaction, File, long),
writeFile(Transaction, File),
writeFile(Transaction, long),
writeFile(Transaction, File, long),
writeFile(Transaction, long, long),
appendFile(Transaction, File),
File.getLastModified()public java.io.OutputStream writeFile(@NotNull
@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull
@NotNull File file)
txn - Transaction instancefile - File instancereadFile(Transaction, File),
readFile(Transaction, long),
readFile(Transaction, File, long),
writeFile(Transaction, long),
writeFile(Transaction, File, long),
writeFile(Transaction, long, long),
appendFile(Transaction, File),
touchFile(Transaction, File)public java.io.OutputStream writeFile(@NotNull
@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull
@NotNull File file,
long fromPosition)
txn - Transaction instancefile - File instancefromPosition - file position to write fromreadFile(Transaction, File),
readFile(Transaction, long),
readFile(Transaction, File, long),
writeFile(Transaction, File),
writeFile(Transaction, long),
writeFile(Transaction, long, long),
appendFile(Transaction, File),
touchFile(Transaction, File)public java.io.OutputStream writeFile(@NotNull
@NotNull jetbrains.exodus.env.Transaction txn,
long fileDescriptor)
txn - Transaction instancefileDescriptor - file descriptorreadFile(Transaction, File),
readFile(Transaction, long),
readFile(Transaction, File, long),
writeFile(Transaction, File),
writeFile(Transaction, File, long),
writeFile(Transaction, long, long),
appendFile(Transaction, File),
touchFile(Transaction, File),
File.getDescriptor(),
File.getLastModified()public java.io.OutputStream writeFile(@NotNull
@NotNull jetbrains.exodus.env.Transaction txn,
long fileDescriptor,
long fromPosition)
txn - Transaction instancefileDescriptor - file descriptorfromPosition - file position to write fromreadFile(Transaction, File),
readFile(Transaction, long),
readFile(Transaction, File, long),
writeFile(Transaction, File),
writeFile(Transaction, long),
writeFile(Transaction, File, long),
appendFile(Transaction, File),
touchFile(Transaction, File),
File.getDescriptor(),
File.getLastModified()public java.io.OutputStream appendFile(@NotNull
@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull
@NotNull File file)
txn - Transaction instancefile - File instancereadFile(Transaction, File),
readFile(Transaction, long),
readFile(Transaction, File, long),
writeFile(Transaction, File),
writeFile(Transaction, long),
writeFile(Transaction, File, long),
writeFile(Transaction, long, long),
touchFile(Transaction, File)public void shutdown()
VirtualFileSystem.@Nullable public @Nullable IOCancellingPolicyProvider getCancellingPolicyProvider()
public void setCancellingPolicyProvider(@NotNull
@NotNull IOCancellingPolicyProvider cancellingPolicyProvider)
@Nullable public @Nullable ClusterConverter getClusterConverter()
public void setClusterConverter(@Nullable
@Nullable ClusterConverter clusterConverter)
public void dump(@NotNull
@NotNull jetbrains.exodus.env.Transaction txn,
@NotNull
@NotNull java.nio.file.Path directory)
throws java.io.IOException
java.io.IOException