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()

Gets the TF version running on this host.

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 主機名稱,或無法擷取時為空值。

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 StringVersionParser 提供的 TF 版本字串

傳回
String 如果有效,則為該版本;否則為預設版本。