ClusterHostUtil
public
class
ClusterHostUtil
extends Object
java.lang.Object | |
↳ | com.android.tradefed.cluster.ClusterHostUtil |
TF 集群的静态实用程序函数,用于获取全局配置实例、主机信息等
摘要
公共构造函数 | |
---|---|
ClusterHostUtil()
|
公共方法 | |
---|---|
static
IClusterClient
|
getClusterClient()
获取用于与 TFC 后端交互的 |
static
IClusterOptions
|
getClusterOptions()
获取用于存储与集群相关设置的 |
static
long
|
getCurrentTimeMillis()
返回当前系统时间。 |
static
String
|
getHostIpAddress()
获取 IP 地址。 |
static
String
|
getHostName()
获取主机名。 |
static
String
|
getLocalDeviceSerial(String serial)
针对给定的唯一设备序列号返回本地设备序列号。 |
static
String
|
getRunTarget(DeviceDescriptor device, String runTargetFormat,
返回指定设备描述符的运行目标。 |
static
String
|
getTestHarness()
|
static
long
|
getTfStartTimeMillis()
|
static
String
|
getTfVersion()
获取此主机上运行的 TF 版本。 |
static
String
|
getUniqueDeviceSerial(DeviceDescriptor device)
返回设备的唯一设备序列号。 |
static
boolean
|
isLocalhostIpPort(String input)
检查给定输入是否为 localhost IP:PORT 字符串。 |
受保护的方法 | |
---|---|
static
String
|
toValidTfVersion(String version)
验证 TF 版本,并在有效时返回该版本。 |
公共构造函数
ClusterHostUtil
public ClusterHostUtil ()
公共方法
getClusterClient
public static IClusterClient getClusterClient ()
获取用于与 TFC 后端交互的 IClusterClient
实例。
返回 | |
---|---|
IClusterClient |
getClusterOptions
public static IClusterOptions getClusterOptions ()
获取用于存储与集群相关的设置的 IClusterOptions
实例。
返回 | |
---|---|
IClusterOptions |
getCurrentTimeMillis
public static long getCurrentTimeMillis ()
返回当前系统时间。
返回 | |
---|---|
long |
时间(以毫秒为单位)。 |
getHostIpAddress
public static String getHostIpAddress ()
获取 IP 地址。
返回 | |
---|---|
String |
IPv4 地址字符串,如果无法提取,则为“UNKNOWN”。 |
getHostName
public static String getHostName ()
获取主机名。
1. 尝试从 InetAddress 获取主机名。2. 如果失败,请尝试从 HOSTNAME 环境中获取主机名。3. 如果未设置,系统会生成唯一的主机名。
返回 | |
---|---|
String |
主机名,如果无法提取,则为 null。 |
getLocalDeviceSerial
public static String getLocalDeviceSerial (String serial)
针对给定的唯一设备序列号返回本地设备序列号。
TFC 会为 TF 无法识别的非实体设备发送唯一设备序列号。此方法会将其转换回本地设备序列号。
参数 | |
---|---|
serial |
String :TFC 提供的唯一设备序列号。 |
返回 | |
---|---|
String |
本地设备序列号。 |
getRunTarget
public static String getRunTarget (DeviceDescriptor device, String runTargetFormat,deviceTags)
返回指定设备描述符的运行目标。
参数 | |
---|---|
device |
DeviceDescriptor :要获取运行目标的 DeviceDescriptor 。 |
runTargetFormat |
String |
deviceTags |
|
返回 | |
---|---|
String |
运行目标。 |
getTestHarness
public static String getTestHarness ()
返回 | |
---|---|
String |
getTfStartTimeMillis
public static long getTfStartTimeMillis ()
返回 | |
---|---|
long |
getTfVersion
public static String getTfVersion ()
获取此主机上运行的 TF 版本。
返回 | |
---|---|
String |
此主机的 TF 版本。 |
getUniqueDeviceSerial
public static String getUniqueDeviceSerial (DeviceDescriptor device)
返回设备的唯一设备序列号。
非实体设备(例如模拟器)具有伪序列号,在不同主机上并非唯一。此方法会为这些文件添加主机名作为前缀,使其具有唯一性。
参数 | |
---|---|
device |
DeviceDescriptor :设备描述符。 |
返回 | |
---|---|
String |
唯一的设备序列号。 |
isLocalhostIpPort
public static boolean isLocalhostIpPort (String input)
检查给定输入是否为 localhost IP:PORT 字符串。
参数 | |
---|---|
input |
String :要检查的字符串 |
返回 | |
---|---|
boolean |
如果给定输入是 localhost IP:PORT 字符串,则为 true |
受保护的方法
toValidTfVersion
protected static String toValidTfVersion (String version)
验证 TF 版本,并在有效时返回该版本。
参数 | |
---|---|
version |
String :VersionParser 提供的 TF 版本的字符串 |
返回 | |
---|---|
String |
版本(如果有效)或默认版本(如果无效)。 |