|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.javaseis.io.VirtualIO
public class VirtualIO
The VirtualIO class provides I/O support for datasets potentially spread across multiple file systems. In this implementation, allocation of extents is handled by an ExtentManager class (org.javaseis.io.ExtentManager) which handles the details of looking for space, keeping track of extents, etc.
Field Summary | |
---|---|
protected java.nio.channels.FileChannel |
_dataChannel
|
protected java.io.File |
_dataFile
|
protected java.lang.String |
_dataMode
|
protected java.io.RandomAccessFile |
_dataStream
|
protected long |
_extentCreateSize
|
protected ExtentManager |
_extentManager
|
protected java.lang.String |
_extentName
|
protected long |
_extentSize
|
protected long |
_extentStartOffset
|
protected int |
_fileIndex
|
protected long |
_fileOffset
|
protected java.lang.String |
_filePath
|
protected long |
_filePosition
|
protected long |
_ioTime
|
protected boolean |
_isChanged
|
protected boolean |
_isReadOnly
|
protected boolean |
_isVirtual
|
static java.util.logging.Logger |
_logger
|
static java.util.logging.Level |
_logLevel
|
protected long |
_numBytes
|
protected long |
_t0
|
protected long |
_t0v
|
protected boolean |
_trackTime
|
protected long |
_virtualTime
|
protected static int |
MAX_FILES
|
Constructor Summary | |
---|---|
VirtualIO(java.lang.String path)
Open a VFIO non-virtual file for subsequent I/O operations. |
|
VirtualIO(java.lang.String path,
java.lang.String openMode)
Open a VFIO file for subsequent I/O operations. |
|
VirtualIO(java.lang.String path,
java.lang.String openMode,
java.lang.String[] alternateDirectories)
Open a VFIO file for subsequent I/O operations. |
|
VirtualIO(java.lang.String path,
java.lang.String extentBaseName,
java.lang.String[] extentDirs,
long fileSize,
int numExtents)
Create a VFIO virtual file for subsequent I/O operations. |
|
VirtualIO(java.lang.String path,
java.lang.String extentBaseName,
java.lang.String[] extentDirs,
long fileSize,
int numExtents,
ExtentPolicy policy,
IParallelContext pc)
Create a VFIO virtual file in a parallel context. |
Method Summary | |
---|---|
void |
allocateExtents()
|
void |
close()
Closes a VFIO file. |
boolean |
delete()
Closes and deletes a open Virtual file. |
static boolean |
delete(java.lang.String path)
If the path to the file exists and represents a virtual file, delete the extents for the file and then the properties file defining the extents. |
void |
flush()
Flushes a VFIO data to disk. |
java.io.FileDescriptor |
getFD()
|
long |
getIoBytes()
Return number of bytes read and/or written if I/O rate tracking is enabled |
float |
getIoRate()
Return I/O rate in MegaBytes per second (MB/s) |
float |
getIoTime()
Return current I/O time in seconds if I/O rate tracking is enabled |
float |
getLoadTime()
Return overhead time spent in Virtual File Properties load/store operations |
float |
getLockTime()
Return overhead time spent in Virtual File Properties lock operations |
java.lang.String |
getPath()
Returns the VFIO file path. |
float |
getVirtualRate()
Return effectve I/O rate including overhead time |
float |
getVirtualTime()
Return total time spent in Virtual File operations |
boolean |
isVirtual()
Returns the virtual status flag. |
static boolean |
isVirtual(java.lang.String path)
Test to see if a file represents a virtual file. |
static void |
log(java.util.logging.Level logLevel,
java.lang.String message)
|
static void |
main(java.lang.String[] args)
Simple test harness for VirtualIO class |
void |
open(java.lang.String path,
java.lang.String openMode,
java.lang.String[] alternateDirectories)
Constructs (and opens) a VFIO file for subsequent I/O operations. |
protected void |
openExtent(long newPosition)
Opens the extent that containts the specified position. |
protected void |
openNonVirtual()
Opens a VFIO non-virtual file. |
protected void |
openVirtual()
Opens a VFIO non-virtual file. |
int |
read(java.nio.ByteBuffer buffer)
Reads from data channel to buffer. |
int |
readBuffer(java.nio.ByteBuffer buffer)
Reads from data channel to buffer. |
int |
readBuffer(java.nio.ByteBuffer buffer,
int len)
Reads from data channel to buffer. |
static void |
setLogLevel(java.util.logging.Level logLevel)
|
long |
setPosition(long newPosition)
Sets the position for subsequent VFIO operations. |
void |
trackTime(boolean flag)
Set flag that determines if I/O rate is tracked |
int |
write(java.nio.ByteBuffer buffer)
Writes from buffer to data channel. |
int |
writeBuffer(java.nio.ByteBuffer buffer)
Writes from buffer to data channel. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.nio.channels.FileChannel _dataChannel
protected java.io.File _dataFile
protected java.lang.String _dataMode
protected java.io.RandomAccessFile _dataStream
protected long _extentCreateSize
protected ExtentManager _extentManager
protected java.lang.String _extentName
protected long _extentSize
protected long _extentStartOffset
protected int _fileIndex
protected long _fileOffset
protected java.lang.String _filePath
protected long _filePosition
protected long _ioTime
protected boolean _isChanged
protected boolean _isReadOnly
protected boolean _isVirtual
public static final java.util.logging.Logger _logger
public static java.util.logging.Level _logLevel
protected long _numBytes
protected long _t0
protected long _t0v
protected boolean _trackTime
protected long _virtualTime
protected static int MAX_FILES
Constructor Detail |
---|
public VirtualIO(java.lang.String path) throws SeisException
path
- The file path.
SeisException
- Thrown on create or open errors error.public VirtualIO(java.lang.String path, java.lang.String openMode) throws SeisException
path
- The file path.openMode
- "rw" for "read/write"; "r" for "read only".
SeisException
- Thrown on open error.public VirtualIO(java.lang.String path, java.lang.String openMode, java.lang.String[] alternateDirectories) throws SeisException
path
- The file path.openMode
- "rw" for "read/write"; "r" for "read only".alternateDirectories
- A list of alternate directories to search for extents (in case of a rename)
SeisException
- Thrown on open error.public VirtualIO(java.lang.String path, java.lang.String extentBaseName, java.lang.String[] extentDirs, long fileSize, int numExtents) throws SeisException
path
- The file path.extentName
- The name of the file extent.extentDirs
- The directories to use for virtual file extents.extentSize
- The maximum size for virtual file extents.
SeisException
- Thrown on file creation or other ExtentManager errorspublic VirtualIO(java.lang.String path, java.lang.String extentBaseName, java.lang.String[] extentDirs, long fileSize, int numExtents, ExtentPolicy policy, IParallelContext pc) throws SeisException
path
- The file path.extentName
- The name of the file extent.extentDirs
- The directories to use for virtual file extents.extentSize
- The maximum size for virtual file extents.
SeisException
- Thrown on file creation or other ExtentManager errorsMethod Detail |
---|
public void allocateExtents() throws SeisException
SeisException
public void close() throws SeisException
SeisException
- Thrown on close error.public boolean delete()
public static boolean delete(java.lang.String path)
path
- full path to the virtual file to be deleted
public void flush() throws SeisException
SeisException
- Thrown on flush error.public java.io.FileDescriptor getFD()
public long getIoBytes()
public float getIoRate()
public float getIoTime()
public float getLoadTime()
public float getLockTime()
public java.lang.String getPath()
public float getVirtualRate()
public float getVirtualTime()
public boolean isVirtual()
public static boolean isVirtual(java.lang.String path)
path
- full path name to be tested
public static void log(java.util.logging.Level logLevel, java.lang.String message)
public static void main(java.lang.String[] args) throws SeisException
args
- not used
SeisException
- on test errorspublic void open(java.lang.String path, java.lang.String openMode, java.lang.String[] alternateDirectories) throws SeisException
path
- The file path.extentName
- The name of the file extent.openMode
- "rw" for "read/write"; "r" for "read only".extentDirs
- An array of extent directories, or "null" to use those in the properties file.
SeisException
- Thrown on open error.protected void openExtent(long newPosition) throws SeisException
newPosition
- The file position for which the containing extent should be opened.
SeisException
- Thrown on extent open errors.protected void openNonVirtual() throws SeisException
SeisException
- Thrown on open error.protected void openVirtual() throws SeisException
SeisException
- Thrown on open error.public int read(java.nio.ByteBuffer buffer) throws SeisException
buffer
- The buffer to hold data read from channel.
SeisException
- Thrown on buffer read errors.public int readBuffer(java.nio.ByteBuffer buffer) throws SeisException
buffer
- The buffer to hold data read from channel.
SeisException
- Thrown on buffer read errors.public int readBuffer(java.nio.ByteBuffer buffer, int len) throws SeisException
buffer
- The buffer to hold data read from channel.
SeisException
- Thrown on buffer read errors.public static void setLogLevel(java.util.logging.Level logLevel)
public long setPosition(long newPosition) throws SeisException
newPosition
- The new file position.
SeisException
- Thrown on positioning errors.public void trackTime(boolean flag)
flag
- true if I/O time is to be trackedpublic int write(java.nio.ByteBuffer buffer) throws SeisException
buffer
- The buffer of data to write to channel.
SeisException
- Thrown on buffer write errors.public int writeBuffer(java.nio.ByteBuffer buffer) throws SeisException
buffer
- The buffer of data to write to channel.
SeisException
- Thrown on buffer write errors.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |