com.sun.faban.driver.engine
Class FlatSequenceMix

java.lang.Object
  extended by com.sun.faban.driver.engine.Mix
      extended by com.sun.faban.driver.engine.FlatSequenceMix
All Implemented Interfaces:
Serializable, Cloneable

public class FlatSequenceMix
extends Mix

The implementation of the flat sequence mix annotation. This mix allows you to specify a set of sequences of operations. For example, a workload may define two scenarios: shopping and browsing. The shopping operation itself is made up of three ordered operations (login, buy, home) and the browsing operation is made up of two operations (search, home). Say that 75% of the workload is browsing and 25% of the workload is shopping. Such a mix of operations would be represented like this:

 @FlatSequenceMix (
 sequences = {
 @OperationSequence({"login", "buy", "home" }),
 @OperationSequence({"search", "home" })
 },
 mix = { 25, 75 },
 deviation = 2
 )
The resulting metric will be the number of the 4 operations (login, buy, search, home) in the time defined for each operation. The driver will expect 45.75% of the operations to be home (50% of 75% of the operations from browsing and 33% of 25% of the operations from shopping), 37.5% to be search, and 8.25% each for login and buy.

Author:
Scott Oaks
See Also:
Serialized Form

Nested Class Summary
static class FlatSequenceMix.Selector
          The selector implementation for the FlatSequenceMix.
 
Field Summary
 
Fields inherited from class com.sun.faban.driver.engine.Mix
className
 
Constructor Summary
FlatSequenceMix()
           
 
Method Summary
 Object clone()
          The clone operation for this object is a deep copy.
 void configure(Element driverConfigNode)
          Configures the flat mix based on the ratios given in the configuration file.
 FlatMix flatMix()
          Returns the flat mix representation of this mix.
 void init(Class<?> driverClass, Annotation a)
          Initializes this mix according to the annotation.
 void init(OperationSequence[] seq)
          Initialized the mix based on the defined sequences from the driver annotations.
 void normalize()
          Normalizes the mix so each row will have a sum of 1.0d.
 String[] operations()
          Returns an array of the operation names used in this FlatMix.
 FlatSequenceMix.Selector selector(Random random)
          Obtains the per-thread and per-driver instance selector.
 String toString()
          Provides a string representation of this FlatSequenceMix.
 void validate()
          Validates the mix spec in the benchmark definitions to ensure all the rows and columns are valid.
 
Methods inherited from class com.sun.faban.driver.engine.Mix
getLogger, getMix
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FlatSequenceMix

public FlatSequenceMix()
Method Detail

init

public void init(Class<?> driverClass,
                 Annotation a)
          throws DefinitionException
Initializes this mix according to the annotation.

Specified by:
init in class Mix
Parameters:
driverClass - The driver class annotating this mix
a - The annotation
Throws:
DefinitionException - If there is an error in the annotation

init

public void init(OperationSequence[] seq)
Initialized the mix based on the defined sequences from the driver annotations.

Parameters:
seq - An array of OperationSequence

operations

public String[] operations()
Returns an array of the operation names used in this FlatMix.

Returns:
operations The names of the operations

clone

public Object clone()
The clone operation for this object is a deep copy.

Overrides:
clone in class Mix
Returns:
a clone of this instance.
See Also:
Cloneable

configure

public void configure(Element driverConfigNode)
               throws ConfigurationException
Configures the flat mix based on the ratios given in the configuration file.

Specified by:
configure in class Mix
Parameters:
driverConfigNode - The DOM node holding the driver config
Throws:
ConfigurationException - If the configuration is invalid for the mix

validate

public void validate()
              throws DefinitionException
Validates the mix spec in the benchmark definitions to ensure all the rows and columns are valid.

Throws:
DefinitionException - Found missing or invalid row/column

normalize

public void normalize()
Normalizes the mix so each row will have a sum of 1.0d. This is important as we do not require the spec input to sum to this amount but the selector (doMenu) will base the random number generator to 1.

Specified by:
normalize in class Mix

flatMix

public FlatMix flatMix()
Returns the flat mix representation of this mix. This is used for consistent reporting.

Specified by:
flatMix in class Mix
Returns:
The flat mix representation.

toString

public String toString()
Provides a string representation of this FlatSequenceMix.

Overrides:
toString in class Object
Returns:
The string representation
See Also:
Object.toString()

selector

public FlatSequenceMix.Selector selector(Random random)
Obtains the per-thread and per-driver instance selector.

Specified by:
selector in class Mix
Parameters:
random - The per-thread random value generator
Returns:
The selector to be used by the driver