集群主機工具
public class ClusterHostUtil
extends Object
對象 | |
↳ | com.android.tradefed.cluster.ClusterHostUtil |
TF Cluster 的靜態 util 函數,用於獲取全局配置實例、主機信息等。
概括
公共構造函數 | |
---|---|
ClusterHostUtil () |
公共方法 | |
---|---|
static IClusterClient | getClusterClient () 獲取 |
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 版本並在正常時返回它。 |
公共構造函數
集群主機工具
public ClusterHostUtil ()
公共方法
獲取集群客戶端
public static IClusterClient getClusterClient ()
獲取IClusterClient
用於與TFC後端交互實例。
退貨 | |
---|---|
IClusterClient |
獲取集群選項
public static IClusterOptions getClusterOptions ()
獲取IClusterOptions
用於存儲集群相關的設置實例。
退貨 | |
---|---|
IClusterOptions |
獲取當前時間毫秒
public static long getCurrentTimeMillis ()
返回當前系統時間。
退貨 | |
---|---|
long | 時間以毫秒為單位。 |
獲取主機地址
public static String getHostIpAddress ()
獲取 IP 地址。
退貨 | |
---|---|
String | 如果我們無法獲取 IPV4 地址字符串或“未知”。 |
獲取主機名
public static String getHostName ()
獲取主機名。
1. 嘗試從 InetAddress 獲取主機名。 2. 如果失敗,嘗試從 HOSTNAME env 中獲取主機名。 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 |
getTfStartTimeMillis
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 字符串,則為 true |
受保護的方法
toValidTfVersion
protected static String toValidTfVersion (String version)
驗證 TF 版本並在正常時返回它。
參數 | |
---|---|
version | String :所提供的TF版本的字符串VersionParser |
退貨 | |
---|---|
String | 版本(如果有效)或默認值(如果無效)。 |