ClusterHostUtil
public class ClusterHostUtil
extends Object
java.lang.Object | |
↳ | com.android.tradefed.cluster.ClusterHostUtil |
TF Cluster 的静态 util 函数,用于获取全局配置实例、主机信息等。
概括
公共构造函数 | |
---|---|
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, deviceTags) getRunTarget ( DeviceDescriptor device, String runTargetFormat, deviceTags) 返回给定设备描述符的运行目标。 |
static String | getTestHarness () |
static long | getTfStartTimeMillis () |
static String | getTfVersion () 获取在此主机上运行的 TF 版本。 |
static String | getUniqueDeviceSerial ( DeviceDescriptor device) 返回设备的唯一设备序列号。 |
static boolean | isLocalhostIpPort (String input) 检查给定输入是否为本地主机 IP:PORT 字符串。 |
受保护的方法 | |
---|---|
static String | toValidTfVersion (String version) 验证 TF 版本并在正常时返回它。 |
公共构造函数
ClusterHostUtil
public ClusterHostUtil ()
公共方法
getClusterClient
public static IClusterClient getClusterClient ()
获取用于与 TFC 后端交互的IClusterClient
实例。
退货 | |
---|---|
IClusterClient |
获取集群选项
public static IClusterOptions getClusterOptions ()
获取用于存储集群相关设置的IClusterOptions
实例。
退货 | |
---|---|
IClusterOptions |
获取当前时间毫秒
public static long getCurrentTimeMillis ()
返回当前系统时间。
退货 | |
---|---|
long | 以毫秒为单位的时间。 |
获取主机IP地址
public static String getHostIpAddress ()
获取 IP 地址。
退货 | |
---|---|
String | IPV4 地址字符串或“UNKNOWN”(如果我们无法获取它)。 |
获取主机名
public static String getHostName ()
获取主机名。
1. 尝试从 InetAddress 获取主机名。 2. 如果失败,尝试从 HOSTNAME 环境中获取主机名。 3. 如果没有设置,生成一个唯一的主机名。
退货 | |
---|---|
String | 主机名或 null 如果我们无法获取它。 |
获取本地设备序列号
public static String getLocalDeviceSerial (String serial)
返回给定唯一设备序列号的本地设备序列号。
TFC 为 TF 不理解的非物理设备发送唯一的设备序列号。此方法将它们转换回本地设备序列号。
参数 | |
---|---|
serial | String :来自 TFC 的唯一设备序列号。 |
退货 | |
---|---|
String | 本地设备序列号。 |
获取运行目标
public static String getRunTarget (DeviceDescriptor device, String runTargetFormat,deviceTags)
返回给定设备描述符的运行目标。
参数 | |
---|---|
device | DeviceDescriptor :要获取运行目标的DeviceDescriptor 。 |
runTargetFormat | String |
deviceTags |
退货 | |
---|---|
String | 运行目标。 |
获取测试工具
public static String getTestHarness ()
退货 | |
---|---|
String |
getTfStartTime 毫秒
public static long getTfStartTimeMillis ()
退货 | |
---|---|
long |
获取版本
public static String getTfVersion ()
获取在此主机上运行的 TF 版本。
退货 | |
---|---|
String | 此主机的 TF 版本。 |
获取唯一设备序列号
public static String getUniqueDeviceSerial (DeviceDescriptor device)
返回设备的唯一设备序列号。
非物理设备(例如模拟器)具有跨主机不唯一的伪序列号。此方法为那些带有主机名的前缀以使其唯一。
参数 | |
---|---|
device | DeviceDescriptor :设备描述符。 |
退货 | |
---|---|
String | 一个独特的设备序列号。 |
isLocalhostIpPort
public static boolean isLocalhostIpPort (String input)
检查给定输入是否为本地主机 IP:PORT 字符串。
参数 | |
---|---|
input | String : 要检查的字符串 |
退货 | |
---|---|
boolean | 如果给定的输入是本地主机 IP:PORT 字符串,则为真 |
受保护的方法
toValidTfVersion
protected static String toValidTfVersion (String version)
验证 TF 版本并在正常时返回它。
参数 | |
---|---|
version | String : VersionParser 提供的 TF 版本的字符串 |
退货 | |
---|---|
String | 如果有效则为版本,否则为默认版本。 |