PreviousBeginningNext

Reading Configuration Information


A benchmark or a driver usually has specific configuration information that needs to be obtained before the run starts. This is typically done in the driver's constructor. The driver context provides facilities to access such configuration information from any agent, local or remote.

Reading Global Configuration Information

A driver may read global configuration information from any part of the config file using an XPath identifying the location of said information. This is useful if such information is general configuration information used by the Faban harness or used by multiple drivers. The DriverContext.getXPathValue() method is the one and only access point for such information. The following example shows a snippet from the config file:

 <webBenchmark>

....

<serverConfig>
<host>129.146.207.112</host>
<port>80</port>
</serverConfig>
</webBenchmark>

The following code snipped shows how to read the target host name/ip address and port from the config file.

    DriverContext context = DriverContext.getContext();
String host = context.getXPathValue("/webBenchmark/serverConfig/host");
String port = context.getXPathValue("/webBenchmark/serverConfig/port");

Namespaces

In many instances, the driver needs to get hold of namespaced Faban configuration parameters such as a the list of hosts managed by the Faban harness, like the following sample configuration entry:

 <webBenchmark>

....

<dbServer>
<fa:hostConfig xmlns="http://faban.sunsource.net/ns/fabanharness"
xmlns:fa
="http://faban.sunsource.net/ns/faban">
<fa:host>129.146.207.112</fa:host>
<enabled>true</enabled>
<cpus>0</cpus>
<tools/>
<userCommands/>
</fa:hostConfig>

....

</dbServer>
</webBenchmark>

For such cases, it is important to note the namespace of the entry you're reading. Faban implicitly resolves prefixes to namespaces as follows:

Prefix Namespace
fa http://faban.sunsource.net/ns/faban
fh http://faban.sunsource.net/ns/fabanharness
fd http://faban.sunsource.net/ns/fabandriver

The following code shows an example for accessing Faban namespaced XPaths from the XML segment above:

    DriverContext context = DriverContext.getContext();
String host = context.getXPathValue(
"/webBenchmark/dbServer/fa:hostConfig/fa:host");
String userCommands = context.getXPathValue(
"/webBenchmark/dbServer/fa:hostConfig/fh:userCommands");

Note that even though the userCommands element did not have a namespace alias prefix in the XML segment above, it is actually in the http://faban.sunsource.net/ns/fabanharness namespace since this is the default namespace for the fa:hostConfig element and all its child elements. We still need to use the fh namespace to query for the userCommands.

Reading Driver Properties

Each driver may have it's own properties. Driver properties are name to value maps and allow for multiple values for a name. The Faban driver framework allows for a few flexible ways to specify the properties and to read them. The properties must be listed under the <properties> node under the <driverConfig> node of the given driver. The following shows the different ways to specify properties:

 <webBenchmark>
....
<runConfig definition="sample.driver.WebDriver"
xmlns
="http://faban.sunsource.net/ns/fabandriver"
xmlns:fa
="http://faban.sunsource.net/ns/faban">
....
<driverConfig name="WebDriver">
....
<properties>
<!-- Demonstrates the different ways to specify properties -->
<!-- The first way is a full name value pair, multiple
values are supported, but only one name -->
<property>
<name>path1</name>
<value>systems</value>
</property>
<!-- The second way is a little more compact while preserving
the ability to set multiple values for a name -->
<property name="path2">
<value>software</value>
</property>
<!-- The third way is very compact but you can only use one
value. This is adequate for most applications. -->
<property name="path3">services</property>
</properties>
....
</driverConfig>
....
</runConfig>
....
</webBenchmark>

Such properties can be read, only by the specific driver (in this case, "WebDriver"), using the following methods of the driver context:

For more complex properties, the values under the <properties> element can also be any XML subtree. You can certainly obtain the whole DOM tree and manipulate it using the DOM or XPath APIs directly. The following driver context method is used for obtaining the whole properties subtree:


PreviousBeginningNext