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

Fields

public static final String CREDENTIAL_FACTORY_TYPE_NAME

public static final String DEVICE_MANAGER_TYPE_NAME

public static final String DEVICE_MONITOR_TYPE_NAME

public static final String DEVICE_REQUIREMENTS_TYPE_NAME

public static final String GLOBAL_CONFIG_SERVER

public static final String GLOBAL_CONFIG_SERVER_CONFIG_VARIABLE

public static final String GLOBAL_CONFIG_VARIABLE

public static final String HOST_MONITOR_TYPE_NAME

public static final String HOST_OPTIONS_TYPE_NAME

public static final String HOST_RESOURCE_MANAGER_TYPE_NAME

public static final String KEY_STORE_TYPE_NAME

public static final String MULTI_DEVICE_RECOVERY_TYPE_NAME

public static final String RESOURCE_METRIC_COLLECTOR_TYPE_NAME

public static final String SANDBOX_FACTORY_TYPE_NAME

public static final String SCHEDULER_TYPE_NAME

public static final String SHARDING_STRATEGY_TYPE_NAME

public static final String TF_DEVICE_MANAGEMENT_SERVER_NAME

public static final String TF_FEATURE_SERVER_NAME

public static final String TF_INVOCATION_SERVER_NAME

public static final String WTF_HANDLER_TYPE_NAME

Public methods

void cleanup()

Proper cleanup when tradefed shutdown.

File cloneConfigWithFilter( exclusionPatterns, String... allowlistConfigs)

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

File cloneConfigWithFilter( exclusionPatterns, IConfigOptionValueTransformer transformer, boolean deepCopy, String... allowlistConfigs)

Filter the GlobalConfiguration based on a white list while allowing for manipulation of option values and output to an XML file.

File cloneConfigWithFilter(String... allowlistConfigs)

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

static 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.

ICredentialFactory getCredentialFactory()

Gets the ICredentialFactory for creating credentials.

String getDescription()
DeviceManagementGrpcServer getDeviceManagementServer()

Returns the DeviceManagementGrpcServer or null if undefined.

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.

getDeviceMonitors()

Gets the list of IDeviceMonitor from the global config.

IDeviceSelection getDeviceRequirements()

Gets the IDeviceSelection to use from the configuration.

TradefedFeatureServer getFeatureServer()

Returns the TradefedFeatureServer or null if undefined.

IConfigurationServer getGlobalConfigServer()

Gets global config server.

static getHostMonitorInstances()
getHostMonitors()

Gets the list of IHostMonitor from the global config.

IHostOptions getHostOptions()

Gets the IHostOptions to use from the configuration.

IHostResourceManager getHostResourceManager()

Gets the IHostResourceManager from the global config.

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.

getMultiDeviceRecoveryHandlers()

Gets the list of IMultiDeviceRecovery to use from the configuration.

String getName()
getOptionValues(String optionName)

Get a list of option's values.

getResourceMetricCollectors()

Gets the list of IResourceMetricCollector from the global config.

ISandboxFactory getSandboxFactory()

Get a sandbox factory that can be used to run an invocation

IShardHelper getShardingStrategy()

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

TestInvocationManagementServer getTestInvocationManagementSever()

Returns the TestInvocationManagementServer or null if undefined.

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 setConfigurationFactory(IConfigurationFactory configFactory)

Set the IConfigurationFactory for this configuration.

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, configList)

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

void setDeviceManagementServer(DeviceManagementGrpcServer server)

Sets the DeviceManagementGrpcServer.

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( hostMonitors)

Set the IHostMonitor list.

void setHostOptions(IHostOptions hostOptions)

Set the IHostOptions, replacing any existing values.

void setHostResourceManager(IHostResourceManager hostResourceManager)

Set the IHostResourceManager, replacing any existing values.

void setInvocationServer(TestInvocationManagementServer server)

Sets the TestInvocationManagementServer.

void setKeyStoreFactory(IKeyStoreFactory factory)

Set the IKeyStoreFactory, replacing any existing values.

setOptionsFromCommandLineArgs( listArgs)

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

See ArgsOptionParser for expected format

void setOriginalConfig(String config)

Sets the original config used to create the global configuration.

void setResourceMetricCollector(IResourceMetricCollector collector)

Sets the IResourceMetricCollector.

void setSandboxFactory(ISandboxFactory factory)

Set the ISandboxFactory, replacing any existing values.

void setShardingStrategy(IShardHelper sharding)

Sets the IShardHelper to be used when sharding a configuration.

void setTradefedFeatureServer(TradefedFeatureServer server)

Sets the TradefedFeatureServer.

void setWtfHandler(ITerribleFailureHandler wtfHandler)

Set the ITerribleFailureHandler.

void setup()

Proper setup at the start of tradefed.

void validateOptions()

Validate option values.

Protected methods

IConfigurationFactory getConfigurationFactory()

Fields

CREDENTIAL_FACTORY_TYPE_NAME

public static final String CREDENTIAL_FACTORY_TYPE_NAME

DEVICE_MANAGER_TYPE_NAME

public static final String DEVICE_MANAGER_TYPE_NAME

DEVICE_MONITOR_TYPE_NAME

public static final String DEVICE_MONITOR_TYPE_NAME

DEVICE_REQUIREMENTS_TYPE_NAME

public static final String DEVICE_REQUIREMENTS_TYPE_NAME

GLOBAL_CONFIG_SERVER

public static final String GLOBAL_CONFIG_SERVER

GLOBAL_CONFIG_SERVER_CONFIG_VARIABLE

public static final String GLOBAL_CONFIG_SERVER_CONFIG_VARIABLE

GLOBAL_CONFIG_VARIABLE

public static final String GLOBAL_CONFIG_VARIABLE

HOST_MONITOR_TYPE_NAME

public static final String HOST_MONITOR_TYPE_NAME

HOST_OPTIONS_TYPE_NAME

public static final String HOST_OPTIONS_TYPE_NAME

HOST_RESOURCE_MANAGER_TYPE_NAME

public static final String HOST_RESOURCE_MANAGER_TYPE_NAME

KEY_STORE_TYPE_NAME

public static final String KEY_STORE_TYPE_NAME

MULTI_DEVICE_RECOVERY_TYPE_NAME

public static final String MULTI_DEVICE_RECOVERY_TYPE_NAME

RESOURCE_METRIC_COLLECTOR_TYPE_NAME

public static final String RESOURCE_METRIC_COLLECTOR_TYPE_NAME

SANDBOX_FACTORY_TYPE_NAME

public static final String SANDBOX_FACTORY_TYPE_NAME

SCHEDULER_TYPE_NAME

public static final String SCHEDULER_TYPE_NAME

SHARDING_STRATEGY_TYPE_NAME

public static final String SHARDING_STRATEGY_TYPE_NAME

TF_DEVICE_MANAGEMENT_SERVER_NAME

public static final String TF_DEVICE_MANAGEMENT_SERVER_NAME

TF_FEATURE_SERVER_NAME

public static final String TF_FEATURE_SERVER_NAME

TF_INVOCATION_SERVER_NAME

public static final String TF_INVOCATION_SERVER_NAME

WTF_HANDLER_TYPE_NAME

public static final String WTF_HANDLER_TYPE_NAME

Public methods

cleanup

public void cleanup ()

Proper cleanup when tradefed shutdown.

cloneConfigWithFilter

public File cloneConfigWithFilter ( exclusionPatterns, 
                String... allowlistConfigs)

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

Parameters
exclusionPatterns : The pattern of class name to exclude from the dump.

allowlistConfigs 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.

Returns
File the File containing the new filtered global config.

cloneConfigWithFilter

public File cloneConfigWithFilter ( exclusionPatterns, 
                IConfigOptionValueTransformer transformer, 
                boolean deepCopy, 
                String... allowlistConfigs)

Filter the GlobalConfiguration based on a white list while allowing for manipulation of option values and output to an XML file.

Parameters
exclusionPatterns : The pattern of class name to exclude from the dump.

transformer IConfigOptionValueTransformer

deepCopy boolean

allowlistConfigs 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.

Returns
File the File containing the new filtered global config.

cloneConfigWithFilter

public File cloneConfigWithFilter (String... allowlistConfigs)

Filter the GlobalConfiguration based on a allowed 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
allowlistConfigs 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.

Returns
File the File containing the new filtered global config.

createGlobalConfiguration

public static  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

Throws
IllegalStateException if called more than once
ConfigurationException

getCommandScheduler

public ICommandScheduler getCommandScheduler ()

Gets the ICommandScheduler to use from the configuration.

Returns
ICommandScheduler the ICommandScheduler. Will never return null.

getConfigurationObject

public 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

getCredentialFactory

public ICredentialFactory getCredentialFactory ()

Gets the ICredentialFactory for creating credentials.

Returns
ICredentialFactory ICredentialFactory or null if none was specified.

getDescription

public String getDescription ()

Returns
String a short user readable description this Configuration

getDeviceManagementServer

public DeviceManagementGrpcServer getDeviceManagementServer ()

Returns the DeviceManagementGrpcServer or null if undefined.

Returns
DeviceManagementGrpcServer

getDeviceManager

public 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

public static 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

public  getDeviceMonitors ()

Gets the list of IDeviceMonitor from the global config.

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

getDeviceRequirements

public 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.

getFeatureServer

public TradefedFeatureServer getFeatureServer ()

Returns the TradefedFeatureServer or null if undefined.

Returns
TradefedFeatureServer

getGlobalConfigServer

public IConfigurationServer getGlobalConfigServer ()

Gets global config server. Global config server is used to get host configs from a server instead of getting it from local files.

Returns
IConfigurationServer

getHostMonitorInstances

public static  getHostMonitorInstances ()

Returns

getHostMonitors

public  getHostMonitors ()

Gets the list of IHostMonitor from the global config.

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

getHostOptions

public IHostOptions getHostOptions ()

Gets the IHostOptions to use from the configuration.

Returns
IHostOptions the IDeviceManager provided in the configuration.

getHostResourceManager

public IHostResourceManager getHostResourceManager ()

Gets the IHostResourceManager from the global config.

Returns
IHostResourceManager the IHostResourceManager from the global config, or default implementation LocalHostResourceManager if none is specified in host config.

getInstance

public static 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

public IKeyStoreFactory getKeyStoreFactory ()

Gets the IKeyStoreFactory to use from the configuration.

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

getMultiDeviceRecoveryHandlers

public  getMultiDeviceRecoveryHandlers ()

Gets the list of IMultiDeviceRecovery to use from the configuration.

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

getName

public String getName ()

Returns
String the name of this Configuration

getOptionValues

public  getOptionValues (String optionName)

Get a list of option's values.

Parameters
optionName String: the map option name

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

getResourceMetricCollectors

public  getResourceMetricCollectors ()

Gets the list of IResourceMetricCollector from the global config.

Returns
the list of IResourceMetricCollector from the global config or null if none was specified.

getSandboxFactory

public ISandboxFactory getSandboxFactory ()

Get a sandbox factory that can be used to run an invocation

Returns
ISandboxFactory

getShardingStrategy

public IShardHelper getShardingStrategy ()

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

Returns
IShardHelper

getTestInvocationManagementSever

public TestInvocationManagementServer getTestInvocationManagementSever ()

Returns the TestInvocationManagementServer or null if undefined.

Returns
TestInvocationManagementServer

getWtfHandler

public 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

public 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

public 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

public 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 ERROR(/PrintStream) to use.

Throws
com.android.tradefed.config.ConfigurationException
ConfigurationException

setCommandScheduler

public void setCommandScheduler (ICommandScheduler scheduler)

Set the ICommandScheduler, replacing any existing values.

setConfigurationFactory

public void setConfigurationFactory (IConfigurationFactory configFactory)

Set the IConfigurationFactory for this configuration.

Parameters
configFactory IConfigurationFactory

setConfigurationObject

public 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

public void setConfigurationObjectList (String typeName, 
                 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 : the config object list

Throws
ConfigurationException

setDeviceManagementServer

public void setDeviceManagementServer (DeviceManagementGrpcServer server)

Sets the DeviceManagementGrpcServer.

Parameters
server DeviceManagementGrpcServer

setDeviceManager

public void setDeviceManager (IDeviceManager manager)

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

setDeviceMonitor

public void setDeviceMonitor (IDeviceMonitor monitor)

Set the IDeviceMonitor.

Parameters
monitor IDeviceMonitor: The monitor

setDeviceRequirements

public 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

public void setHostMonitors ( hostMonitors)

Set the IHostMonitor list.

Parameters
hostMonitors : The list of monitors

setHostOptions

public void setHostOptions (IHostOptions hostOptions)

Set the IHostOptions, replacing any existing values.

setHostResourceManager

public void setHostResourceManager (IHostResourceManager hostResourceManager)

Set the IHostResourceManager, replacing any existing values.

setInvocationServer

public void setInvocationServer (TestInvocationManagementServer server)

Sets the TestInvocationManagementServer.

Parameters
server TestInvocationManagementServer

setKeyStoreFactory

public void setKeyStoreFactory (IKeyStoreFactory factory)

Set the IKeyStoreFactory, replacing any existing values.

setOptionsFromCommandLineArgs

public  setOptionsFromCommandLineArgs ( listArgs)

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

See ArgsOptionParser for expected format

Parameters
listArgs : the command line arguments

Returns
the unconsumed arguments

Throws
ConfigurationException

setOriginalConfig

public void setOriginalConfig (String config)

Sets the original config used to create the global configuration.

Parameters
config String

setResourceMetricCollector

public void setResourceMetricCollector (IResourceMetricCollector collector)

Sets the IResourceMetricCollector.

Parameters
collector IResourceMetricCollector

setSandboxFactory

public void setSandboxFactory (ISandboxFactory factory)

Set the ISandboxFactory, replacing any existing values.

setShardingStrategy

public void setShardingStrategy (IShardHelper sharding)

Sets the IShardHelper to be used when sharding a configuration.

Parameters
sharding IShardHelper

setTradefedFeatureServer

public void setTradefedFeatureServer (TradefedFeatureServer server)

Sets the TradefedFeatureServer.

Parameters
server TradefedFeatureServer

setWtfHandler

public void setWtfHandler (ITerribleFailureHandler wtfHandler)

Set the ITerribleFailureHandler.

Parameters
wtfHandler ITerribleFailureHandler: the WTF handler

setup

public void setup ()

Proper setup at the start of tradefed.

Throws
ConfigurationException

validateOptions

public void validateOptions ()

Validate option values.

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

Throws
ConfigurationException

Protected methods

getConfigurationFactory

protected IConfigurationFactory getConfigurationFactory ()

Returns
IConfigurationFactory