public class GridFilesystem extends Object
Modifier and Type | Field and Description |
---|---|
protected Cache<String,byte[]> |
data |
protected int |
defaultChunkSize |
protected Cache<String,GridFile.Metadata> |
metadata |
Constructor and Description |
---|
GridFilesystem(Cache<String,byte[]> data,
Cache<String,GridFile.Metadata> metadata) |
GridFilesystem(Cache<String,byte[]> data,
Cache<String,GridFile.Metadata> metadata,
int defaultChunkSize)
Creates an instance.
|
Modifier and Type | Method and Description |
---|---|
File |
getFile(File parent,
String child) |
File |
getFile(File parent,
String child,
int chunkSize) |
File |
getFile(String pathname)
Returns the file denoted by pathname.
|
File |
getFile(String pathname,
int chunkSize)
Returns the file denoted by pathname.
|
File |
getFile(String parent,
String child) |
File |
getFile(String parent,
String child,
int chunkSize) |
InputStream |
getInput(File file)
Opens an InputStream for reading from the given file.
|
InputStream |
getInput(String pathname)
Opens an InputStream for reading from the file denoted by pathname.
|
OutputStream |
getOutput(GridFile file)
Opens an OutputStream for writing to the given file.
|
OutputStream |
getOutput(String pathname)
Opens an OutputStream for writing to the file denoted by pathname.
|
OutputStream |
getOutput(String pathname,
boolean append)
Opens an OutputStream for writing to the file denoted by pathname.
|
OutputStream |
getOutput(String pathname,
boolean append,
int chunkSize)
Opens an OutputStream for writing to the file denoted by pathname.
|
ReadableGridFileChannel |
getReadableChannel(String pathname)
Opens a ReadableGridFileChannel for reading from the file denoted by the given file path.
|
WritableGridFileChannel |
getWritableChannel(String pathname)
Opens a WritableGridFileChannel for writing to the file denoted by pathname.
|
WritableGridFileChannel |
getWritableChannel(String pathname,
boolean append)
Opens a WritableGridFileChannel for writing to the file denoted by pathname.
|
WritableGridFileChannel |
getWritableChannel(String pathname,
boolean append,
int chunkSize)
Opens a WritableGridFileChannel for writing to the file denoted by pathname.
|
protected final Cache<String,GridFile.Metadata> metadata
protected final int defaultChunkSize
public GridFilesystem(Cache<String,byte[]> data, Cache<String,GridFile.Metadata> metadata, int defaultChunkSize)
data
- the cache where the actual file contents are storedmetadata
- the cache where file meta-data is storeddefaultChunkSize
- the default size of the file chunkspublic GridFilesystem(Cache<String,byte[]> data, Cache<String,GridFile.Metadata> metadata)
public File getFile(String pathname)
pathname
- the full path of the requested filepublic File getFile(String pathname, int chunkSize)
pathname
- the full path of the requested filechunkSize
- the size of the file's chunks. This parameter is only used for non-existing files.public OutputStream getOutput(String pathname) throws IOException
pathname
- the path to write toIOException
- if an error occurspublic OutputStream getOutput(String pathname, boolean append) throws IOException
pathname
- the path to write toappend
- if true, the bytes written to the OutputStream will be appended to the end of the file. If false,
the bytes will overwrite the original contents.IOException
- if an error occurspublic OutputStream getOutput(String pathname, boolean append, int chunkSize) throws IOException
pathname
- the file to write toappend
- if true, the bytes written to the OutputStream will be appended to the end of the filechunkSize
- the size of the file's chunks. This parameter is honored only when the file at pathname does
not yet exist. If the file already exists, the file's own chunkSize has precedence.IOException
- if the file is a directory, cannot be created or some other error occurspublic OutputStream getOutput(GridFile file) throws IOException
file
- the file to write toIOException
- if an error occurspublic InputStream getInput(String pathname) throws FileNotFoundException
pathname
- the full path of the file to read fromFileNotFoundException
- if the file does not exist or is a directorypublic InputStream getInput(File file) throws FileNotFoundException
file
- the file to open for readingFileNotFoundException
- if the file does not exist or is a directorypublic ReadableGridFileChannel getReadableChannel(String pathname) throws FileNotFoundException
pathname
- path of the file to open for readingFileNotFoundException
- if the file does not exist or is a directorypublic WritableGridFileChannel getWritableChannel(String pathname) throws IOException
pathname
- the path to write toIOException
- if an error occurspublic WritableGridFileChannel getWritableChannel(String pathname, boolean append) throws IOException
pathname
- the path to write toappend
- if true, the bytes written to the WritableGridFileChannel will be appended to the end of the file.
If false, the bytes will overwrite the original contents.IOException
- if an error occurspublic WritableGridFileChannel getWritableChannel(String pathname, boolean append, int chunkSize) throws IOException
pathname
- the file to write toappend
- if true, the bytes written to the channel will be appended to the end of the filechunkSize
- the size of the file's chunks. This parameter is honored only when the file at pathname does
not yet exist. If the file already exists, the file's own chunkSize has precedence.IOException
- if the file is a directory, cannot be created or some other error occursCopyright © 2020 JBoss, a division of Red Hat. All rights reserved.