com.sun.faban.driver.engine
Class NullContext

java.lang.Object
  extended by com.sun.faban.driver.DriverContext
      extended by com.sun.faban.driver.engine.NullContext

public class NullContext
extends DriverContext

The null context is used for testing driver code for the Faban driver framework without actually running the agents. It ensures that the same driver code can be tested in it's own main method.

Author:
Akara Sucharitakul

Constructor Summary
NullContext()
           
 
Method Summary
 void attachMetrics(CustomMetrics metrics)
          Attaches a custom metrics as the miscellaneous stats.
 void attachMetrics(String name, CustomMetrics metrics)
          Attaches a custom metrics object to the primary metrics, given a name or description.
 void attachMetrics(String name, CustomTableMetrics metrics)
          Attaches a custom table metrics object to the primary metrics, given a name or description.
 int getAgentId()
          Obtains the agent id.
 String getBaseDir()
          Obtains the base directory where the benchmark currently being run is installed.
 int getClientsInAgent()
          Obtains the number of client threads in this agent.
 int getClientsInDriver()
          Obtains the total number of clients threads for this driver.
 String getCurrentOperation()
          Returns the current operation.
 String getDriverName()
          Returns the driver name.
 Logger getLogger()
          Obtains the logger for this driver thread.
 long getNanoTime()
          Obtain the current nano time offset from the base time.
 int getOperationCount()
          Gets the current count of the operations done by this thread.
 int getOperationId()
          Obtains the operation id of the current operation.
 Element getPropertiesNode()
          Gets the properties node from the dom tree.
 String getProperty(String name)
          Gets the driver property.
 String[] getPropertyValues(String name)
          Gets the driver properties by name.
 int getRampDown()
          Obtains the ramp down time.
 int getRampUp()
          Obtains the rampup time.
 Random getRandom()
          Obtains the random value generator for this thread.
 String getResourceDir()
          Obtains the resource directory used for this benchmark, if exists.
 int getScale()
          Obtains the scale of this run.
 int getSteadyState()
          Obtains the steady state time.
 int getSteadyStateStart()
          Obtains the relative time steady state starts.
 long getSteadyStateStartNanos()
          Obtain the nano time offset where steady state starts.
 int getThreadId()
          Obtains the current thread id.
 int getTime()
          Obtains the relative current time.
 String getXPathValue(String xPath)
          Returns a value matching the given xpath in the configuration file.
 boolean isTxSteadyState()
          Checks whether we're in the steady state.
 void pauseTime()
          Pauses the time measurement.
 void recordTime()
          Records the start and end of time measurement.
 void resetMix()
          Resets the mix.
 
Methods inherited from class com.sun.faban.driver.DriverContext
getContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NullContext

public NullContext()
Method Detail

getScale

public int getScale()
Obtains the scale of this run. This implementation always return 0.

Specified by:
getScale in class DriverContext
Returns:
Always 0
See Also:
DriverContext.getScale()

getClientsInAgent

public int getClientsInAgent()
Obtains the number of client threads in this agent.

Specified by:
getClientsInAgent in class DriverContext
Returns:
the number of client threads

getClientsInDriver

public int getClientsInDriver()
Obtains the total number of clients threads for this driver.

Specified by:
getClientsInDriver in class DriverContext
Returns:
the number of client threads for this driver

getThreadId

public int getThreadId()
Obtains the current thread id. This implementation always returns 0.

Specified by:
getThreadId in class DriverContext
Returns:
Always 0
See Also:
DriverContext.getThreadId()

getAgentId

public int getAgentId()
Obtains the agent id. This implementation always returns 0.

Specified by:
getAgentId in class DriverContext
Returns:
Always returns 0
See Also:
DriverContext.getAgentId()

getDriverName

public String getDriverName()
Returns the driver name. In this case a dummy driver name "DriverTestNullContext".

Specified by:
getDriverName in class DriverContext
Returns:
The dummy driver name.
See Also:
DriverContext.getDriverName()

getLogger

public Logger getLogger()
Obtains the logger for this driver thread. The logger name is always "faban.test."

Specified by:
getLogger in class DriverContext
Returns:
The logger for this thread.
See Also:
DriverContext.getLogger()

attachMetrics

public void attachMetrics(CustomMetrics metrics)
Attaches a custom metrics as the miscellaneous stats. This implementation does nothing.

Specified by:
attachMetrics in class DriverContext
Parameters:
metrics - The metrics to attach
See Also:
DriverContext.attachMetrics(com.sun.faban.driver.CustomMetrics)

attachMetrics

public void attachMetrics(String name,
                          CustomMetrics metrics)
Attaches a custom metrics object to the primary metrics, given a name or description. The name/description must be unique. This should be done by the driver at initialization time. Only one custom metrics can be attached. Subsequent calls to this method replaces the previously attached metrics.

Specified by:
attachMetrics in class DriverContext
Parameters:
name - The name or description of this metrics
metrics - The custom metrics to be replaced

attachMetrics

public void attachMetrics(String name,
                          CustomTableMetrics metrics)
Attaches a custom table metrics object to the primary metrics, given a name or description. The name/description must be unique. This should be done by the driver at initialization time. Only one custom metrics can be attached. Subsequent calls to this method replaces the previously attached metrics.

Specified by:
attachMetrics in class DriverContext
Parameters:
name - The name or description of this metrics
metrics - The custom table metrics to be replaced

getCurrentOperation

public String getCurrentOperation()
Returns the current operation. For the null context, it is a dummy name "DriverTestNullContext."

Specified by:
getCurrentOperation in class DriverContext
Returns:
The dummy name of the current operation.
See Also:
DriverContext.getCurrentOperation()

getOperationId

public int getOperationId()
Obtains the operation id of the current operation. This implementation always returns 0.

Specified by:
getOperationId in class DriverContext
Returns:
Always 0
See Also:
DriverContext.getOperationId()

getOperationCount

public int getOperationCount()
Gets the current count of the operations done by this thread.

Specified by:
getOperationCount in class DriverContext
Returns:
Always 1 for this implementation
See Also:
DriverContext.getOperationCount()

getRandom

public Random getRandom()
Obtains the random value generator for this thread.

Specified by:
getRandom in class DriverContext
Returns:
Always the same random value generator
See Also:
DriverContext.getRandom()

recordTime

public void recordTime()
Records the start and end of time measurement. This implemenation does nothing.

Specified by:
recordTime in class DriverContext
See Also:
DriverContext.recordTime()

pauseTime

public void pauseTime()
Pauses the time measurement. This implementation does nothing.

Specified by:
pauseTime in class DriverContext
See Also:
DriverContext.pauseTime()

getTime

public int getTime()
Obtains the relative current time.

Specified by:
getTime in class DriverContext
Returns:
The current relative time
See Also:
DriverContext.getTime()

getSteadyStateStart

public int getSteadyStateStart()
Obtains the relative time steady state starts. This implementation always returns the relative time, 5 seconds from the current time which is in the future.

Specified by:
getSteadyStateStart in class DriverContext
Returns:
The steady state start time
See Also:
DriverContext.getSteadyStateStart()

getNanoTime

public long getNanoTime()
Obtain the current nano time offset from the base time.

Specified by:
getNanoTime in class DriverContext
Returns:
The current nano time
See Also:
DriverContext.getNanoTime()

getSteadyStateStartNanos

public long getSteadyStateStartNanos()
Obtain the nano time offset where steady state starts.

Specified by:
getSteadyStateStartNanos in class DriverContext
Returns:
A dummy time 5 seconds after the base time
See Also:
DriverContext.getSteadyStateStartNanos()

getRampUp

public int getRampUp()
Obtains the rampup time. This implementation always returns 0.

Specified by:
getRampUp in class DriverContext
Returns:
The rampup time which is 0
See Also:
DriverContext.getRampUp()

getSteadyState

public int getSteadyState()
Obtains the steady state time. This implementation returns a very large dummy number of Integer.MAX_VALUE / 2.

Specified by:
getSteadyState in class DriverContext
Returns:
A dummy steady state time
See Also:
DriverContext.getSteadyState()

getRampDown

public int getRampDown()
Obtains the ramp down time. This implementation returns 0.

Specified by:
getRampDown in class DriverContext
Returns:
A dummy ramp down time of 0.
See Also:
DriverContext.getRampDown()

resetMix

public void resetMix()
Resets the mix. We don't use mixes with the null context so this implementation does nothing.

Specified by:
resetMix in class DriverContext
See Also:
DriverContext.resetMix()

isTxSteadyState

public boolean isTxSteadyState()
Checks whether we're in the steady state. This implementation always return true.

Specified by:
isTxSteadyState in class DriverContext
Returns:
Always true
See Also:
DriverContext.isTxSteadyState()

getProperty

public String getProperty(String name)
Gets the driver property. This implementation gets the property from the java properties.

Specified by:
getProperty in class DriverContext
Parameters:
name - The name of the property
Returns:
The property value, or null if it does not exist
See Also:
DriverContext.getProperty(java.lang.String)

getPropertyValues

public String[] getPropertyValues(String name)
Gets the driver properties by name. This implementation gets the property from the java properties and returns an array of size 1 at most. If the property is not set, returns null.

Specified by:
getPropertyValues in class DriverContext
Parameters:
name - The name of the property
Returns:
An array of size 1 containing the value, or null if not exist
See Also:
DriverContext.getPropertyValues(java.lang.String)

getPropertiesNode

public Element getPropertiesNode()
Gets the properties node from the dom tree. NullContext does not use a run configuration so this will always return null.

Specified by:
getPropertiesNode in class DriverContext
Returns:
Always null.
See Also:
DriverContext.getPropertiesNode()

getXPathValue

public String getXPathValue(String xPath)
Returns a value matching the given xpath in the configuration file. NullContext does not use a run configuration so this will always return null.

Specified by:
getXPathValue in class DriverContext
Parameters:
xPath - The xpath
Returns:
Always null
See Also:
DriverContext.getXPathValue(java.lang.String)

getBaseDir

public String getBaseDir()
Obtains the base directory where the benchmark currently being run is installed.

Specified by:
getBaseDir in class DriverContext
Returns:
The benchmark's base directory

getResourceDir

public String getResourceDir()
Obtains the resource directory used for this benchmark, if exists.

Specified by:
getResourceDir in class DriverContext
Returns:
The resource directory for this benchmark