ClusterHostUtil

public class ClusterHostUtil
extends Object

java.lang.Object
com.android.tradefed.cluster.ClusterHostUtil


TF 集群的静态实用程序函数,用于获取全局配置实例、主机信息等。

摘要

公共构造函数

ClusterHostUtil()

公共方法

static IClusterClient getClusterClient()

获取用于与 TFC 后端交互的 IClusterClient 实例。

static IClusterOptions getClusterOptions()

获取用于存储集群相关设置的 IClusterOptions 实例。

static long getCurrentTimeMillis()

返回当前系统时间。

static String getHostIpAddress()

获取 IP 地址。

static String getHostName()

获取主机名。

static String getLocalDeviceSerial(String serial)

为给定的唯一设备序列号返回本地设备序列号。

static String getRunTarget(DeviceDescriptor device, String runTargetFormat, Map<String, String> deviceTags)

为给定的设备描述符返回运行目标。

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, 
                Map<String, String> deviceTags)

为给定的设备描述符返回运行目标。

参数
device DeviceDescriptor:要获取运行目标的 DeviceDescriptor

runTargetFormat String

deviceTags Map

返回
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 如果有效,则返回版本;否则,返回默认版本。