spec.io
Class FileCache

java.lang.Object
  extended by spec.io.FileCache

public class FileCache
extends java.lang.Object

This class cache (read only) files in memory, to be able to used in benchmarks to avoid unwanted contention on the file system. Note! This class must be used in a thread safe way. Files should therefore be put in cache by the harness execution. This is done by loading validation files in cache before first execution of the benchmark is started. This is done by loading files in the setupBenchmark method in the benchmarks.


Nested Class Summary
 class FileCache.CachedFile
           
 
Constructor Summary
FileCache()
           
 
Method Summary
 void clearCache()
           
 void discard(java.lang.String fileName)
           
 byte[] getByteArray(java.lang.String fileName)
           
 int getLength(java.lang.String fileName)
           
 java.io.ByteArrayInputStream getStream(java.lang.String fileName)
           
 void loadFile(java.lang.String fileName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileCache

public FileCache()
Method Detail

getStream

public java.io.ByteArrayInputStream getStream(java.lang.String fileName)
                                       throws java.io.IOException
Throws:
java.io.IOException

discard

public void discard(java.lang.String fileName)

getLength

public int getLength(java.lang.String fileName)

clearCache

public void clearCache()

getByteArray

public byte[] getByteArray(java.lang.String fileName)

loadFile

public void loadFile(java.lang.String fileName)
              throws java.io.IOException
Throws:
java.io.IOException