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 | 如果有效則為版本,否則為默認版本。 |