net.dontdrinkandroot.cache.impl.disk.indexed.storage
Class DataFile

java.lang.Object
  extended by net.dontdrinkandroot.cache.impl.disk.indexed.storage.DataFile

public class DataFile
extends Object

Author:
Philip W. Sorst

Field Summary
protected  File file
           
protected  DataBlock lastBlock
          Pointer to the last used block.
protected  org.slf4j.Logger logger
           
protected  RandomAccessFile randomAccessFile
           
protected  TreeSet<DataBlock> usedBlocks
          Ordered set of used blocks
 
Constructor Summary
DataFile(File file)
           
 
Method Summary
 void allocateSpace(DataBlock dataBlock)
           
 boolean checkConsistency()
           
 void close()
          Closes the underlying random access file.
 void delete(DataBlock dataBlock, boolean truncate)
           
 String getFileName()
           
 int getNumAllocated()
           
 long length()
          Returns the length of the underlying random access file.
 byte[] read(DataBlock dataBlock)
           
 DataBlock write(byte[] data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.slf4j.Logger logger

randomAccessFile

protected final RandomAccessFile randomAccessFile

usedBlocks

protected final TreeSet<DataBlock> usedBlocks
Ordered set of used blocks


lastBlock

protected DataBlock lastBlock
Pointer to the last used block.


file

protected File file
Constructor Detail

DataFile

public DataFile(File file)
         throws FileNotFoundException
Throws:
FileNotFoundException
Method Detail

allocateSpace

public void allocateSpace(DataBlock dataBlock)
                   throws AllocationException
Throws:
AllocationException

checkConsistency

public boolean checkConsistency()

close

public void close()
           throws IOException
Closes the underlying random access file.

Throws:
IOException

delete

public void delete(DataBlock dataBlock,
                   boolean truncate)

getNumAllocated

public int getNumAllocated()

getFileName

public String getFileName()

length

public long length()
            throws IOException
Returns the length of the underlying random access file.

Throws:
IOException

read

public byte[] read(DataBlock dataBlock)
            throws IOException
Throws:
IOException

write

public DataBlock write(byte[] data)
                throws IOException
Throws:
IOException


Copyright © 2013 dontdrinkandroot. All Rights Reserved.