com.slamd.tools.tcpreplay
Class CaptureData

java.lang.Object
  extended by com.slamd.tools.tcpreplay.CaptureData

public class CaptureData
extends java.lang.Object

This class provides a data structure that may be used to hold data that has been captured in a form that can be replayed to generate load against a server.

Author:
Neil A. Wilson

Constructor Summary
CaptureData(int captureVersion, long captureTime, byte[] data)
          Creates a new capture data object with the provided information.
 
Method Summary
static CaptureData decodeFrom(java.io.InputStream inputStream)
          Reads an encoded form of this capture data from the provided input stream.
 void encodeTo(java.io.OutputStream outputStream)
          Encodes this capture data and writes it to the provided output stream.
 long getCaptureTime()
          Retrieves the time that the data was captured.
 int getCaptureVersion()
          Retrieves the capture version used for this capture.
 byte[] getData()
          Retrieves the data that was captured.
 void replayTo(java.io.OutputStream outputStream)
          Replays the captured data to the provided output stream.
 void replayTo(java.nio.channels.SocketChannel socketChannel)
          Replays the captured data to the provided socket channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CaptureData

public CaptureData(int captureVersion,
                   long captureTime,
                   byte[] data)
Creates a new capture data object with the provided information.

Parameters:
captureVersion - The capture version used.
captureTime - The time that this data was captured.
data - The actual data that was captured.
Method Detail

getCaptureVersion

public int getCaptureVersion()
Retrieves the capture version used for this capture.

Returns:
The capture version used for this capture.

getCaptureTime

public long getCaptureTime()
Retrieves the time that the data was captured.

Returns:
The time that the data was captured.

getData

public byte[] getData()
Retrieves the data that was captured.

Returns:
The data that was captured.

decodeFrom

public static CaptureData decodeFrom(java.io.InputStream inputStream)
                              throws java.io.IOException,
                                     CaptureException
Reads an encoded form of this capture data from the provided input stream.

Parameters:
inputStream - The input stream from which to read the capture data to decode.
Returns:
The capture data decoded from the provided input stream, or null if there is no more data to read from the input stream.
Throws:
java.io.IOException - If a problem occurs while trying to read the data from the input stream.
CaptureException - If a problem occurs while attempting to decode the data read from the input stream.

encodeTo

public void encodeTo(java.io.OutputStream outputStream)
              throws java.io.IOException
Encodes this capture data and writes it to the provided output stream.

Parameters:
outputStream - The output stream to which the encoded data should be written.
Throws:
java.io.IOException - If a problem occurs while writing the data to the provided output stream.

replayTo

public void replayTo(java.io.OutputStream outputStream)
              throws java.io.IOException
Replays the captured data to the provided output stream.

Parameters:
outputStream - The output stream to which the data should be written.
Throws:
java.io.IOException - If a problem occurs while writing the data to the provided output stream.

replayTo

public void replayTo(java.nio.channels.SocketChannel socketChannel)
              throws java.io.IOException
Replays the captured data to the provided socket channel.

Parameters:
socketChannel - The socket channel to which the data should be written.
Throws:
java.io.IOException - If a problem occurs while writing the data to the provided socket channel.