com.metamatrix.common.buffer.storage.file
Class FileStorageManager

java.lang.Object
  extended by com.metamatrix.common.buffer.storage.file.FileStorageManager
All Implemented Interfaces:
StorageManager

public class FileStorageManager
extends java.lang.Object
implements StorageManager

This class stores batches in files on disk in a specified directory. Every tuple source gets it's own set of files, named b_id_num where id is the unique id value of the TupleSourceID, and num is a file counter for the files associated with the TupleSourceID. Batches are stored random access into the file, typically but not necessarily in order. An in memory data structure stores info about all open files and where the batches are in the file (file pointers and lengths).


Field Summary
 
Fields inherited from interface com.metamatrix.common.buffer.StorageManager
TYPE_DATABASE, TYPE_FILE, TYPE_MEMORY, TYPE_REMOTE
 
Constructor Summary
FileStorageManager()
           
 
Method Summary
 void addBatch(TupleSourceID sourceID, TupleBatch batch, java.lang.String[] types)
          Add a batch to the storage manager.
 TupleBatch getBatch(TupleSourceID sourceID, int beginRow, java.lang.String[] types)
          Get a batch from the storage manager based on the beginRow.
 int getOpenFiles()
           
 int getStorageType()
          Return file type: com.metamatrix.common.buffer.StorageManager.TYPE_FILE
 void initialize(java.util.Properties props)
          Initialize with properties
 void removeBatch(TupleSourceID sourceID, int beginRow)
          This method does nothing - rather than deleting batches from the middle of a RandomAccessFile, which would be very expensive, we just handle the possibility that a batch already exists in the addBatch method.
 void removeBatches(TupleSourceID sourceID)
          Remove all batches for a sourceID.
 void shutdown()
          This method removes all storage area files by walking through the file info map and closing and removing each file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileStorageManager

public FileStorageManager()
Method Detail

initialize

public void initialize(java.util.Properties props)
                throws MetaMatrixComponentException
Initialize with properties

Specified by:
initialize in interface StorageManager
Parameters:
props - Initialization properties
Throws:
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)
See Also:
BufferManagerPropertyNames.BUFFER_STORAGE_DIRECTORY, BufferManagerPropertyNames.MAX_OPEN_FILES, BufferManagerPropertyNames.MAX_FILE_SIZE

getStorageType

public int getStorageType()
Return file type: com.metamatrix.common.buffer.StorageManager.TYPE_FILE

Specified by:
getStorageType in interface StorageManager
Returns:
File type constant
See Also:
StorageManager.TYPE_MEMORY, StorageManager.TYPE_DATABASE, StorageManager.TYPE_FILE, StorageManager.TYPE_REMOTE

addBatch

public void addBatch(TupleSourceID sourceID,
                     TupleBatch batch,
                     java.lang.String[] types)
              throws MetaMatrixComponentException
Add a batch to the storage manager. Because we don't implement remove, it's possible that this batch already exists, in which case nothing is done.

Specified by:
addBatch in interface StorageManager
Parameters:
sourceID - Source identifier
batch - Batch to add
types - a hint to the StorageManager about the types of data in the batch
Throws:
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)

getBatch

public TupleBatch getBatch(TupleSourceID sourceID,
                           int beginRow,
                           java.lang.String[] types)
                    throws TupleSourceNotFoundException,
                           MetaMatrixComponentException
Get a batch from the storage manager based on the beginRow.

Specified by:
getBatch in interface StorageManager
Parameters:
sourceID - Source identifier
beginRow - Beginning row of batch to retrieve
types - a hint to the StorageManager about the types of data in the batch
Returns:
Batch retrieved
Throws:
TupleSourceNotFoundException - indicating the sourceID is unknown
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)

removeBatch

public void removeBatch(TupleSourceID sourceID,
                        int beginRow)
                 throws TupleSourceNotFoundException,
                        MetaMatrixComponentException
This method does nothing - rather than deleting batches from the middle of a RandomAccessFile, which would be very expensive, we just handle the possibility that a batch already exists in the addBatch method.

Specified by:
removeBatch in interface StorageManager
Parameters:
sourceID - Source identifier
beginRow - Beginning batch row to remove
Throws:
TupleSourceNotFoundException - indicating the sourceID is unknown
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)

removeBatches

public void removeBatches(TupleSourceID sourceID)
                   throws MetaMatrixComponentException
Remove all batches for a sourceID. Before removal, the file is closed.

Specified by:
removeBatches in interface StorageManager
Parameters:
sourceID - Tuple source ID
Throws:
MetaMatrixComponentException - indicating a non-business-related exception (such as a communication exception)

shutdown

public void shutdown()
This method removes all storage area files by walking through the file info map and closing and removing each file.

Specified by:
shutdown in interface StorageManager

getOpenFiles

public int getOpenFiles()


Copyright © 2009. All Rights Reserved.