public class GridFilesystem
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected Cache<java.lang.String,byte[]> |
data |
protected int |
defaultChunkSize |
protected Cache<java.lang.String,GridFile.Metadata> |
metadata |
| Constructor and Description |
|---|
GridFilesystem(Cache<java.lang.String,byte[]> data,
Cache<java.lang.String,GridFile.Metadata> metadata) |
GridFilesystem(Cache<java.lang.String,byte[]> data,
Cache<java.lang.String,GridFile.Metadata> metadata,
int defaultChunkSize)
Creates an instance.
|
| Modifier and Type | Method and Description |
|---|---|
java.io.File |
getFile(java.io.File parent,
java.lang.String child) |
java.io.File |
getFile(java.io.File parent,
java.lang.String child,
int chunkSize) |
java.io.File |
getFile(java.lang.String pathname)
Returns the file denoted by pathname.
|
java.io.File |
getFile(java.lang.String pathname,
int chunkSize)
Returns the file denoted by pathname.
|
java.io.File |
getFile(java.lang.String parent,
java.lang.String child) |
java.io.File |
getFile(java.lang.String parent,
java.lang.String child,
int chunkSize) |
java.io.InputStream |
getInput(java.io.File file)
Opens an InputStream for reading from the given file.
|
java.io.InputStream |
getInput(java.lang.String pathname)
Opens an InputStream for reading from the file denoted by pathname.
|
java.io.OutputStream |
getOutput(GridFile file)
Opens an OutputStream for writing to the given file.
|
java.io.OutputStream |
getOutput(java.lang.String pathname)
Opens an OutputStream for writing to the file denoted by pathname.
|
java.io.OutputStream |
getOutput(java.lang.String pathname,
boolean append)
Opens an OutputStream for writing to the file denoted by pathname.
|
java.io.OutputStream |
getOutput(java.lang.String pathname,
boolean append,
int chunkSize)
Opens an OutputStream for writing to the file denoted by pathname.
|
ReadableGridFileChannel |
getReadableChannel(java.lang.String pathname)
Opens a ReadableGridFileChannel for reading from the file denoted by the given file path.
|
WritableGridFileChannel |
getWritableChannel(java.lang.String pathname)
Opens a WritableGridFileChannel for writing to the file denoted by pathname.
|
WritableGridFileChannel |
getWritableChannel(java.lang.String pathname,
boolean append)
Opens a WritableGridFileChannel for writing to the file denoted by pathname.
|
WritableGridFileChannel |
getWritableChannel(java.lang.String pathname,
boolean append,
int chunkSize)
Opens a WritableGridFileChannel for writing to the file denoted by pathname.
|
protected final Cache<java.lang.String,byte[]> data
protected final Cache<java.lang.String,GridFile.Metadata> metadata
protected final int defaultChunkSize
public GridFilesystem(Cache<java.lang.String,byte[]> data, Cache<java.lang.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<java.lang.String,byte[]> data, Cache<java.lang.String,GridFile.Metadata> metadata)
public java.io.File getFile(java.lang.String pathname)
pathname - the full path of the requested filepublic java.io.File getFile(java.lang.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 java.io.File getFile(java.lang.String parent,
java.lang.String child)
public java.io.File getFile(java.lang.String parent,
java.lang.String child,
int chunkSize)
public java.io.File getFile(java.io.File parent,
java.lang.String child)
public java.io.File getFile(java.io.File parent,
java.lang.String child,
int chunkSize)
public java.io.OutputStream getOutput(java.lang.String pathname)
throws java.io.IOException
pathname - the path to write tojava.io.IOException - if an error occurspublic java.io.OutputStream getOutput(java.lang.String pathname,
boolean append)
throws java.io.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.java.io.IOException - if an error occurspublic java.io.OutputStream getOutput(java.lang.String pathname,
boolean append,
int chunkSize)
throws java.io.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.java.io.IOException - if the file is a directory, cannot be created or some other error occurspublic java.io.OutputStream getOutput(GridFile file) throws java.io.IOException
file - the file to write tojava.io.IOException - if an error occurspublic java.io.InputStream getInput(java.lang.String pathname)
throws java.io.FileNotFoundException
pathname - the full path of the file to read fromjava.io.FileNotFoundException - if the file does not exist or is a directorypublic java.io.InputStream getInput(java.io.File file)
throws java.io.FileNotFoundException
file - the file to open for readingjava.io.FileNotFoundException - if the file does not exist or is a directorypublic ReadableGridFileChannel getReadableChannel(java.lang.String pathname) throws java.io.FileNotFoundException
pathname - path of the file to open for readingjava.io.FileNotFoundException - if the file does not exist or is a directorypublic WritableGridFileChannel getWritableChannel(java.lang.String pathname) throws java.io.IOException
pathname - the path to write tojava.io.IOException - if an error occurspublic WritableGridFileChannel getWritableChannel(java.lang.String pathname, boolean append) throws java.io.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.java.io.IOException - if an error occurspublic WritableGridFileChannel getWritableChannel(java.lang.String pathname, boolean append, int chunkSize) throws java.io.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.java.io.IOException - if the file is a directory, cannot be created or some other error occurs