gcspy.tools
Class FileTrace

java.lang.Object
  extended by gcspy.utils.Verbose
      extended by gcspy.tools.FileTrace
All Implemented Interfaces:
InputGenerator, OutputGenerator
Direct Known Subclasses:
TerminalPlayTrace, TerminalStoreTrace

public class FileTrace
extends Verbose
implements OutputGenerator, InputGenerator

Contains facilities to store / retrieve traces to / from files

Author:
Tony Printezis

Field Summary
static int COMPRESSION_GZIP
          Use gzip format
static int COMPRESSION_NONE
          No compression
static int COMPRESSION_ZIP
          Use zip format
protected  java.lang.String fileName
          The name of the file containng the trace
 
Fields inherited from class gcspy.utils.Verbose
verbose
 
Constructor Summary
FileTrace(java.lang.String fileName, boolean verbose)
          Create a new FileTrace with default buffer length
FileTrace(java.lang.String fileName, int bufferLen, boolean verbose)
          Create a new FileTrace with default buffer length and compression not set
FileTrace(java.lang.String fileName, int bufferLen, boolean verbose, int compression)
          Create a new FileTrace with default buffer length with compression not set
 
Method Summary
 void close()
          Close the input / output
protected  void control(int spaceID, byte[] control)
          Handle a space's controls
 BufferedInput createBufferedInput()
          Create a new buffered input
 BufferedOutput createBufferedOutput()
          Create a buffered output
 Space createSpace()
          Create a new space
 void done(int len)
          Complete writing a stream
protected  void event(int eventID, int elapsedTime, int compensationTime)
          Handle an event
protected  void eventCount(int[] counts)
          Handle event counts
protected  java.lang.String getCompressionType()
          Get the files compression type (e.g.
 void parse()
          Parse input
 void setupInput()
          Set up the input
 void setupOutput()
          Set up the output
protected  void space(ServerSpace space)
          Handle a space
protected  void spaceInfo(int spaceID, java.lang.String spaceInfo)
          Handle space information
protected  void stream(int spaceID, int streamID, java.lang.Object data, int[] summary)
          Handle a stream's data and dummary values for a stream
 void writeControl(int spaceID, byte[] control)
          Write the controls for a space
 void writeEvent(int eventID, int elapsedTime, int compensationTime)
          Write an event
 void writeEventCount(int[] counts)
          Write event counts
 void writeSpace(Space space)
          Write a space
 void writeSpaceInfo(int spaceID, java.lang.String spaceInfo)
          Write the space inforrmation for a space
 void writeStream(int spaceID, int streamID, java.lang.Object data, int[] summary)
          Write a stream
 
Methods inherited from class gcspy.utils.Verbose
print, println, println, setVerbose, verbose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPRESSION_NONE

public static final int COMPRESSION_NONE
No compression

See Also:
Constant Field Values

COMPRESSION_GZIP

public static final int COMPRESSION_GZIP
Use gzip format

See Also:
Constant Field Values

COMPRESSION_ZIP

public static final int COMPRESSION_ZIP
Use zip format

See Also:
Constant Field Values

fileName

protected java.lang.String fileName
The name of the file containng the trace

Constructor Detail

FileTrace

public FileTrace(java.lang.String fileName,
                 boolean verbose)
Create a new FileTrace with default buffer length

Parameters:
fileName - The name of the file
verbose - SHould we be verbose?

FileTrace

public FileTrace(java.lang.String fileName,
                 int bufferLen,
                 boolean verbose)
Create a new FileTrace with default buffer length and compression not set

Parameters:
fileName - The name of the file
bufferLen - The length of the buffer
verbose - SHould we be verbose?

FileTrace

public FileTrace(java.lang.String fileName,
                 int bufferLen,
                 boolean verbose,
                 int compression)
Create a new FileTrace with default buffer length with compression not set

Parameters:
fileName - The name of the file
bufferLen - The length of the buffer
verbose - SHould we be verbose?
compression - The compression type
Method Detail

getCompressionType

protected java.lang.String getCompressionType()
Get the files compression type (e.g. non, gzip, zip, etc)

Returns:
the type

createBufferedOutput

public BufferedOutput createBufferedOutput()
                                    throws java.io.IOException
Create a buffered output

Specified by:
createBufferedOutput in interface OutputGenerator
Returns:
the bufferd outpu object
Throws:
java.io.IOException

done

public void done(int len)
          throws java.io.IOException
Complete writing a stream

Specified by:
done in interface OutputGenerator
Parameters:
len - the lenght of the stream
Throws:
java.io.IOException

writeStream

public void writeStream(int spaceID,
                        int streamID,
                        java.lang.Object data,
                        int[] summary)
Write a stream

Parameters:
spaceID - the space's ID
streamID - The stream's ID
data - The stream data
summary - The stream's summary values

writeControl

public void writeControl(int spaceID,
                         byte[] control)
Write the controls for a space

Parameters:
spaceID - The space's ID
control - The controls

writeEventCount

public void writeEventCount(int[] counts)
Write event counts

Parameters:
counts - The counts

writeEvent

public void writeEvent(int eventID,
                       int elapsedTime,
                       int compensationTime)
Write an event

Parameters:
eventID - The event's iD
elapsedTime - The eleapsed time for the event
compensationTime - The compensation time

writeSpaceInfo

public void writeSpaceInfo(int spaceID,
                           java.lang.String spaceInfo)
Write the space inforrmation for a space

Parameters:
spaceID - the space's ID
spaceInfo - the space information

writeSpace

public void writeSpace(Space space)
Write a space

Parameters:
space - The space

createBufferedInput

public BufferedInput createBufferedInput()
                                  throws java.io.IOException
Create a new buffered input

Specified by:
createBufferedInput in interface InputGenerator
Returns:
The new buffered input
Throws:
java.io.IOException

createSpace

public Space createSpace()
Create a new space

Specified by:
createSpace in interface InputGenerator
Returns:
a new space

stream

protected void stream(int spaceID,
                      int streamID,
                      java.lang.Object data,
                      int[] summary)
               throws java.io.IOException
Handle a stream's data and dummary values for a stream

Parameters:
spaceID - The space's ID
streamID - The stream's ID
data - The stream's data
summary - The summary values
Throws:
java.io.IOException

control

protected void control(int spaceID,
                       byte[] control)
                throws java.io.IOException
Handle a space's controls

Parameters:
spaceID - The space's ID
control - The controls
Throws:
java.io.IOException

eventCount

protected void eventCount(int[] counts)
                   throws java.io.IOException
Handle event counts

Parameters:
counts - The event counts
Throws:
java.io.IOException

event

protected void event(int eventID,
                     int elapsedTime,
                     int compensationTime)
              throws java.io.IOException
Handle an event

Parameters:
eventID - The event's ID
elapsedTime - The elapsed time for the event
compensationTime - Its compensation time
Throws:
java.io.IOException

spaceInfo

protected void spaceInfo(int spaceID,
                         java.lang.String spaceInfo)
                  throws java.io.IOException
Handle space information

Parameters:
spaceID - The space's ID
spaceInfo - Its space information
Throws:
java.io.IOException

space

protected void space(ServerSpace space)
              throws java.io.IOException
Handle a space

Parameters:
space - The space
Throws:
java.io.IOException

parse

public void parse()
           throws java.io.IOException
Parse input

Throws:
java.io.IOException

setupInput

public void setupInput()
Set up the input


setupOutput

public void setupOutput()
Set up the output


close

public void close()
Close the input / output