GlobalConfiguration

public class GlobalConfiguration
extends Object implements IGlobalConfiguration

java.lang.Object
   ↳ com.android.tradefed.config.GlobalConfiguration


An IGlobalConfiguration implementation that stores the loaded config objects in a map

Summary

Constants

String DEVICE_MANAGER_TYPE_NAME

String DEVICE_MONITOR_TYPE_NAME

String DEVICE_REQUIREMENTS_TYPE_NAME

String HOST_MONITOR_TYPE_NAME

String HOST_OPTIONS_TYPE_NAME

String KEY_STORE_TYPE_NAME

String MULTI_DEVICE_RECOVERY_TYPE_NAME

String SCHEDULER_TYPE_NAME

String SHARDING_STRATEGY_TYPE_NAME

String WTF_HANDLER_TYPE_NAME

Public methods

void cloneConfigWithFilter(File outputXml, String[] whitelistConfigs)

Filter the GlobalConfiguration based on a white list and output to an XML file.

static List<String> createGlobalConfiguration(String[] args)

Sets up the GlobalConfiguration singleton for this TF instance.

ICommandScheduler getCommandScheduler()

Gets the ICommandScheduler to use from the configuration.

Object getConfigurationObject(String typeName)

Gets the custom configuration object with given name.

String getDescription()
IDeviceManager getDeviceManager()

Gets the IDeviceManager to use from the configuration.

static IDeviceManager getDeviceManagerInstance()

Returns a reference to the singleton DeviceManager instance for this TF instance.

List<IDeviceMonitor> getDeviceMonitors()

Gets the list of IDeviceMonitor from the global config.

IDeviceSelection getDeviceRequirements()

Gets the IDeviceSelection to use from the configuration.

static List<IHostMonitor> getHostMonitorInstances()
List<IHostMonitor> getHostMonitors()

Gets the list of IHostMonitor from the global config.

IHostOptions getHostOptions()

Gets the IHostOptions to use from the configuration.

static IGlobalConfiguration getInstance()

Returns a reference to the singleton GlobalConfiguration instance for this TF instance.

IKeyStoreFactory getKeyStoreFactory()

Gets the IKeyStoreFactory to use from the configuration.

List<IMultiDeviceRecovery> getMultiDeviceRecoveryHandlers()

Gets the list of IMultiDeviceRecovery to use from the configuration.

String getName()
List<String> getOptionValues(String optionName)

Get a list of option's values.

IShardHelper getShardingStrategy()

Returns the IShardHelper that defines the way to shard a configuration.

ITerribleFailureHandler getWtfHandler()

Gets the ITerribleFailureHandler to use from the configuration.

void injectOptionValue(String optionName, String optionValue)

Inject a option value into the set of configuration objects.

void injectOptionValue(String optionName, String optionKey, String optionValue)

Inject a option value into the set of configuration objects.

void printCommandUsage(boolean importantOnly, PrintStream out)

Outputs a command line usage help text for this configuration to given printStream.

void setCommandScheduler(ICommandScheduler scheduler)

Set the ICommandScheduler, replacing any existing values.

void setConfigurationObject(String typeName, Object configObject)

Generic method to set the config object with the given name, replacing any existing value.

void setConfigurationObjectList(String typeName, List<?> configList)

Generic method to set the config object list for the given name, replacing any existing value.

void setDeviceManager(IDeviceManager manager)

Set the IDeviceManager, replacing any existing values.

void setDeviceMonitor(IDeviceMonitor monitor)

Set the IDeviceMonitor.

void setDeviceRequirements(IDeviceSelection devRequirements)

Set the IDeviceSelection, replacing any existing values.

void setHostMonitors(List<IHostMonitor> hostMonitors)

Set the IHostMonitor list.

void setHostOptions(IHostOptions hostOptions)

Set the IHostOptions, replacing any existing values.

void setKeyStoreFactory(IKeyStoreFactory factory)

Set the IKeyStoreFactory, replacing any existing values.

List<String> setOptionsFromCommandLineArgs(List<String> listArgs)

Set the global config Option fields with given set of command line arguments

See ArgsOptionParser for expected format

void setShardingStrategy(IShardHelper sharding)

Sets the IShardHelper to be used when sharding a configuration.

void setWtfHandler(ITerribleFailureHandler wtfHandler)

Set the ITerribleFailureHandler.

void validateOptions()

Validate option values.

Constants

DEVICE_MANAGER_TYPE_NAME

String DEVICE_MANAGER_TYPE_NAME

Constant Value: "device_manager"

DEVICE_MONITOR_TYPE_NAME

String DEVICE_MONITOR_TYPE_NAME

Constant Value: "device_monitor"

DEVICE_REQUIREMENTS_TYPE_NAME

String DEVICE_REQUIREMENTS_TYPE_NAME

Constant Value: "device_requirements"

HOST_MONITOR_TYPE_NAME

String HOST_MONITOR_TYPE_NAME

Constant Value: "host_monitor"

HOST_OPTIONS_TYPE_NAME

String HOST_OPTIONS_TYPE_NAME

Constant Value: "host_options"

KEY_STORE_TYPE_NAME

String KEY_STORE_TYPE_NAME

Constant Value: "key_store"

MULTI_DEVICE_RECOVERY_TYPE_NAME

String MULTI_DEVICE_RECOVERY_TYPE_NAME

Constant Value: "multi_device_recovery"

SCHEDULER_TYPE_NAME

String SCHEDULER_TYPE_NAME

Constant Value: "command_scheduler"

SHARDING_STRATEGY_TYPE_NAME

String SHARDING_STRATEGY_TYPE_NAME

Constant Value: "sharding_strategy"

WTF_HANDLER_TYPE_NAME

String WTF_HANDLER_TYPE_NAME

Constant Value: "wtf_handler"

Public methods

cloneConfigWithFilter

void cloneConfigWithFilter (File outputXml, 
                String[] whitelistConfigs)

Filter the GlobalConfiguration based on a white list and output to an XML file.

For example, for following configuration: <xml> <configuration> <device_monitor class="com.android.tradefed.device.DeviceMonitorMultiplexer" /> <wtf_handler class="com.android.tradefed.log.TerribleFailureEmailHandler" /> <key_store class="com.android.tradefed.util.keystore.JSONFileKeyStoreFactory" /> </configuration> </xml>

all config except "key_store" will be filtered out, and result a config file with following content: <xml> <configuration> <key_store class="com.android.tradefed.util.keystore.JSONFileKeyStoreFactory" /> </configuration> </xml>

Parameters
outputXml File: the XML file to write to

whitelistConfigs String: a String array of configs to be included in the new XML file. If it's set to null, a default list should be used.

Throws
IOException

createGlobalConfiguration

List<String> createGlobalConfiguration (String[] args)

Sets up the GlobalConfiguration singleton for this TF instance. Must be called once and only once, before anything attempts to call getInstance()

Parameters
args String

Returns
List<String>

Throws
IllegalStateException if called more than once
ConfigurationException

getCommandScheduler

ICommandScheduler getCommandScheduler ()

Gets the ICommandScheduler to use from the configuration.

Returns
ICommandScheduler the ICommandScheduler. Will never return null.

getConfigurationObject

Object getConfigurationObject (String typeName)

Gets the custom configuration object with given name.

Parameters
typeName String: the unique type of the configuration object

Returns
Object the object or null if object with that name is not found

getDescription

String getDescription ()

Returns
String a short user readable description this Configuration

getDeviceManager

IDeviceManager getDeviceManager ()

Gets the IDeviceManager to use from the configuration. Manages the set of available devices for testing

Returns
IDeviceManager the IDeviceManager provided in the configuration.

getDeviceManagerInstance

IDeviceManager getDeviceManagerInstance ()

Returns a reference to the singleton DeviceManager instance for this TF instance.

Returns
IDeviceManager

Throws
IllegalStateException if createGlobalConfiguration(String[]) has not already been called.

getDeviceMonitors

List<IDeviceMonitor> getDeviceMonitors ()

Gets the list of IDeviceMonitor from the global config.

Returns
List<IDeviceMonitor> the list of IDeviceMonitor from the global config, or null if none was specified.

getDeviceRequirements

IDeviceSelection getDeviceRequirements ()

Gets the IDeviceSelection to use from the configuration. Represents a global filter on which devices the DeviceManager can see.

Returns
IDeviceSelection the IDeviceSelection provided in the configuration.

getHostMonitorInstances

List<IHostMonitor> getHostMonitorInstances ()

Returns
List<IHostMonitor>

getHostMonitors

List<IHostMonitor> getHostMonitors ()

Gets the list of IHostMonitor from the global config.

Returns
List<IHostMonitor> the list of IHostMonitor from the global config, or null if none was specified.

getHostOptions

IHostOptions getHostOptions ()

Gets the IHostOptions to use from the configuration.

Returns
IHostOptions the IDeviceManager provided in the configuration.

getInstance

IGlobalConfiguration getInstance ()

Returns a reference to the singleton GlobalConfiguration instance for this TF instance.

Returns
IGlobalConfiguration

Throws
IllegalStateException if createGlobalConfiguration(String[]) has not already been called.

getKeyStoreFactory

IKeyStoreFactory getKeyStoreFactory ()

Gets the IKeyStoreFactory to use from the configuration.

Returns
IKeyStoreFactory the IKeyStoreFactory or null if no key store factory is set.

getMultiDeviceRecoveryHandlers

List<IMultiDeviceRecovery> getMultiDeviceRecoveryHandlers ()

Gets the list of IMultiDeviceRecovery to use from the configuration.

Returns
List<IMultiDeviceRecovery> the list of IMultiDeviceRecovery, or null if not set.

getName

String getName ()

Returns
String the name of this Configuration

getOptionValues

List<String> getOptionValues (String optionName)

Get a list of option's values.

Parameters
optionName String: the map option name

Returns
List<String> a list of the given option's values. null if the option name does not exist.

getShardingStrategy

IShardHelper getShardingStrategy ()

Returns the IShardHelper that defines the way to shard a configuration.

Returns
IShardHelper

getWtfHandler

ITerribleFailureHandler getWtfHandler ()

Gets the ITerribleFailureHandler to use from the configuration. Handles what to do in the event that a WTF (What a Terrible Failure) occurs.

Returns
ITerribleFailureHandler the ITerribleFailureHandler provided in the configuration, or null if no handler is set

injectOptionValue

void injectOptionValue (String optionName, 
                String optionValue)

Inject a option value into the set of configuration objects.

Useful to provide values for options that are generated dynamically.

Parameters
optionName String: the option name

optionValue String: the option value(s)

Throws
ConfigurationException

injectOptionValue

void injectOptionValue (String optionName, 
                String optionKey, 
                String optionValue)

Inject a option value into the set of configuration objects.

Useful to provide values for options that are generated dynamically.

Parameters
optionName String: the map option name

optionKey String: the map option key

optionValue String: the map option value

Throws
ConfigurationException

printCommandUsage

void printCommandUsage (boolean importantOnly, 
                PrintStream out)

Outputs a command line usage help text for this configuration to given printStream.

Parameters
importantOnly boolean

out PrintStream: the PrintStream to use.

Throws
ConfigurationException

setCommandScheduler

void setCommandScheduler (ICommandScheduler scheduler)

Set the ICommandScheduler, replacing any existing values.

setConfigurationObject

void setConfigurationObject (String typeName, 
                Object configObject)

Generic method to set the config object with the given name, replacing any existing value.

Parameters
typeName String: the unique name of the config object type.

configObject Object: the config object

Throws
ConfigurationException

setConfigurationObjectList

void setConfigurationObjectList (String typeName, 
                List<?> configList)

Generic method to set the config object list for the given name, replacing any existing value.

Parameters
typeName String: the unique name of the config object type.

configList List: the config object list

Throws
ConfigurationException

setDeviceManager

void setDeviceManager (IDeviceManager manager)

Set the IDeviceManager, replacing any existing values. This sets the manager for the test devices

setDeviceMonitor

void setDeviceMonitor (IDeviceMonitor monitor)

Set the IDeviceMonitor.

Parameters
monitor IDeviceMonitor: The monitor

setDeviceRequirements

void setDeviceRequirements (IDeviceSelection devRequirements)

Set the IDeviceSelection, replacing any existing values. This sets a global device filter on which devices the DeviceManager can see.

setHostMonitors

void setHostMonitors (List<IHostMonitor> hostMonitors)

Set the IHostMonitor list.

Parameters
hostMonitors List: The list of monitors

setHostOptions

void setHostOptions (IHostOptions hostOptions)

Set the IHostOptions, replacing any existing values.

setKeyStoreFactory

void setKeyStoreFactory (IKeyStoreFactory factory)

Set the IKeyStoreFactory, replacing any existing values.

setOptionsFromCommandLineArgs

List<String> setOptionsFromCommandLineArgs (List<String> listArgs)

Set the global config Option fields with given set of command line arguments

See ArgsOptionParser for expected format

Parameters
listArgs List: the command line arguments

Returns
List<String> the unconsumed arguments

Throws
ConfigurationException

setShardingStrategy

void setShardingStrategy (IShardHelper sharding)

Sets the IShardHelper to be used when sharding a configuration.

Parameters
sharding IShardHelper

setWtfHandler

void setWtfHandler (ITerribleFailureHandler wtfHandler)

Set the ITerribleFailureHandler.

Parameters
wtfHandler ITerribleFailureHandler: the WTF handler

validateOptions

void validateOptions ()

Validate option values.

Currently this will just validate that all mandatory options have been set

Throws
ConfigurationException