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)
檢查指定輸入內容是否為本機 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 |
主機名稱,如果無法擷取,則傳回空值。 |
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)
檢查指定輸入內容是否為本機 IP:PORT 字串。
參數 | |
---|---|
input |
String :要檢查的字串 |
傳回 | |
---|---|
boolean |
如果指定的輸入內容為本機 IP:PORT 字串,則傳回 true |
受保護的方法
toValidTfVersion
protected static String toValidTfVersion (String version)
驗證 TF 版本,並在版本正常運作時傳回。
參數 | |
---|---|
version |
String :VersionParser 提供的 TF 版本字串 |
傳回 | |
---|---|
String |
版本 (如果有效) 或預設值 (如果無效)。 |