CommandScheduler

public class CommandScheduler
extends Object implements ICommandScheduler

java.lang.Object
   ↳ com.android.tradefed.command.CommandScheduler


מתזמן להרצת פקודות TradeFederation בכל המכשירים הזמינים.

המערכת תנסה לתת עדיפות להרצת פקודות על סמך ספירה כוללת של זמן הביצוע שלהן. לדוגמה, פקודות שמופעלות לעיתים רחוקות או פקודות שמופעלות במהירות יקבלו עדיפות על פני פקודות שמופעלות לאורך זמן.

פועל ברקע ללא הפסקה עד לכיבוי.

סיכום

Constructors ציבוריים

CommandScheduler()

יצירת CommandScheduler.

‫methods ציבוריים

Pair<Boolean, Integer> addCommand(String[] args)

הוספת פקודה למתזמן.

void addCommandFile(String cmdFilePath, extraArgs)

מוסיף את כל הפקודות מקובץ נתון למתזמן

void await()

הפונקציה ממתינה שהמתזמן יתחיל לפעול, כולל המתנה להשלמת ההעברה מ-TF ישן, אם רלוונטי.

static TradefedDelegator checkDelegation(String[] args)

יוצרים משתמש שנותן לאחרים הרשאה לניהול שיחות על סמך שורת הפקודה, כדי לבדוק אם צריך להעביר את ההרצה.

static createReleaseMap(IInvocationContext context, Throwable e)

ליצור מפה של מצב המכשירים כדי שניתן יהיה לשחרר אותם בצורה מתאימה.

ISandbox createSandbox()

יוצרים ISandbox שההפעלה תשתמש בו כדי לפעול.

void displayCommandQueue(PrintWriter printWriter)

הצגת פרטי ניפוי באגים מפורטים לגבי מצב תור הביצוע של הפקודות.

void displayCommandsInfo(PrintWriter printWriter, String regex)

הצגת רשימה של הפקודות הנוכחיות.

void displayInvocationsInfo(PrintWriter printWriter)

מוצגת רשימה של הפעלות נוכחיות.

void dumpCommandsXml(PrintWriter printWriter, String regex)

הפקת קובץ ה-XML המורחב של הפקודה עם כל הערכים של Option שצוינו לכל הפקודות הנוכחיות.

long execCommand(ICommandScheduler.IScheduledInvocationListener listener, ITestDevice device, String[] args)

ביצוע ישיר של פקודה במכשיר שכבר הוקצה.

long execCommand(ICommandScheduler.IScheduledInvocationListener listener, reservedDevices, String[] args)

הפעלה ישירה של פקודה במכשירים שכבר הוקצו.

long execCommand(IInvocationContext context, ICommandScheduler.IScheduledInvocationListener listener, String[] args)

מקצה מכשיר באופן ישיר ומבצע פקודה בלי להוסיף אותה לתור הפקודות באמצעות IInvocationContext שכבר קיים.

long execCommand(ICommandScheduler.IScheduledInvocationListener listener, String[] args)

הפקודה מקצה מכשיר באופן ישיר ומבצעת פקודה בלי להוסיף אותה לתור הפקודות.

CommandFileWatcher getCommandFileWatcher()

קבלת CommandFileWatcher מתאים לתזמן הזה

int getExecutingCommandCount()

הפונקציה מחזירה את מספר הפקודות במצב הפעלה.

CommandScheduler.HostState getHostState()
String getInvocationInfo(int invocationId)

אפשר להחזיר את המידע על הפעלה על ידי ציון מזהה ההפעלה.

CommandRunner.ExitCode getLastInvocationExitCode()

החזרת קוד השגיאה של ההפעלה האחרונה שהופעלה.

Throwable getLastInvocationThrowable()

החזרת הערך Throwable מההפעלה האחרונה שהופעלה.

int getReadyCommandCount()

הפונקציה מחזירה את מספר הפקודות במצב מוכן בתור.

long getShutdownTimeout()
boolean isDeviceInInvocationThread(ITestDevice device)

הפונקציה מחזירה את הערך True אם המכשיר נמצא בשימוש על ידי שרשור הפעלה פעיל.

boolean isShuttingDown()
void notifyFileChanged(File cmdFile, extraArgs)
void removeAllCommands()

הסרת כל הפקודות מהמתזמן

void run()

בלוק הביצוע הראשי של ה-thread הזה.

void setClearcutClient(ClearcutClient client)

הגדרת הלקוח לדיווח על נתוני harness

void setMaxPollTime(long polling)
void setPrintSchedulingWarning(boolean print)
boolean shouldShutdownOnCmdfileError()

הפונקציה מחזירה את הערך True אם צריך להשבית את מתזמן המשימות בגלל שגיאות בפקודה

void shutdown(boolean notifyStop)

מנסים לבצע כיבוי תקין של מתזמן הפקודות.

void shutdownHard(boolean killAdb)

לנסות לכבות בכוח את מתזמן הפקודות.

void shutdownHard()

לנסות לכבות בכוח את מתזמן הפקודות.

void shutdownOnEmpty()

בדומה ל-shutdown(), אבל הפקודה הזו תמתין עד שכל הפקודות יבוצעו לפני היציאה.

void start()

הפעלת הכלי לתזמון, כולל הגדרת הרישום ביומן, הפעלה של DeviceManager וכו'

boolean stopInvocation(ITestInvocation invocation)

הפסקת הפעלה של פונקציה.

boolean stopInvocation(int invocationId, String cause)

כדי להפסיק הפעלה של פונקציה, מציינים את המזהה שלה.

void stopScheduling()

הוא מפסיק לתזמן ולבצע בדיקות חדשות, אבל לא מפסיק את Tradefed.

שיטות מוגנות

void cleanUp()

סוגר את היומנים ומבצע ניקוי נתונים נחוץ אחר לפני היציאה.

IConfiguration createConfiguration(String[] args)
IInvocationContext createInvocationContext()
void dryRunCommandReporting(ICommandScheduler.IScheduledInvocationListener handler, IConfiguration config)

קובעת אם פקודה נתונה היא הרצה יבשה.

long execCommand(IInvocationContext context, ICommandScheduler.IScheduledInvocationListener listener, reservedDevices, String[] args)
IConfigurationFactory getConfigFactory()

שיטת Factory לקבלת הפניה אל IConfigurationFactory

DeviceManagementGrpcServer getDeviceManagementServer()
IDeviceManager getDeviceManager()

שיטת Factory לקבלת הפניה אל IDeviceManager

TradefedFeatureServer getFeatureServer()
IHostOptions getHostOptions()
IKeyStoreClient getKeyStoreClient()

מאחזר IKeyStoreClient באמצעות IKeyStoreFactory שהוגדר ב-IGlobalConfiguration, או מחזיר null אם לא הוגדר IKeyStoreClient.

TestInvocationManagementServer getTestInvocationManagementServer()
void initLogging()

הפונקציה מאתחלת את היומן של ddmlib.

boolean isShutdown()
void processReadyCommands(IDeviceManager manager)

Constructors ציבוריים

CommandScheduler

public CommandScheduler ()

יצירת CommandScheduler.

הערה: צריך להפעיל את הפונקציה start לפני השימוש.

‫methods ציבוריים

addCommand

public Pair<Boolean, Integer> addCommand (String[] args)

הוספת פקודה למתזמן.

פקודה היא בעצם מופע של הגדרה להרצה והארגומנטים שמשויכים לה.

אם מציינים את הארגומנט ‎ "--help"‎, טקסט העזרה של ההגדרה יופיע בפלט stdout. אחרת, ההגדרה תתווסף לתור להרצה.

פרמטרים
args String: ארגומנטים של ההגדרה.

החזרות
Pair<Boolean, Integer> צמד ערכים, הערך הראשון הוא בוליאני true אם הפקודה נוספה בהצלחה. הערך השני הוא מזהה מעקב הפקודות הידוע(ערך לא שלילי) אם הפקודה נוספה בהצלחה. הערך שמוחזר הוא 0 אם הפקודה נוספה לכל המכשירים, אחרת הערך הוא ‎-1.

זריקות
ConfigurationException

addCommandFile

public void addCommandFile (String cmdFilePath, 
                 extraArgs)

מוסיף את כל הפקודות מקובץ נתון למתזמן

פרמטרים
cmdFilePath String: הנתיב במערכת הקבצים של קובץ הפקודה

extraArgs : ERROR(/List) של String ארגומנטים שיוגדרו להוספה לכל פקודה שנותחה מהקובץ. אפשר להשאיר את השדה ריק, אבל הוא לא יכול להיות null.

זריקות
ConfigurationException

await

public void await ()

הפונקציה ממתינה שהמתזמן יתחיל לפעול, כולל המתנה להשלמת ההעברה מ-TF ישן, אם רלוונטי.

checkDelegation

public static TradefedDelegator checkDelegation (String[] args)

יוצרים משתמש שנותן לאחרים הרשאה לניהול שיחות על סמך שורת הפקודה, כדי לבדוק אם צריך להעביר את ההרצה.

פרמטרים
args String

החזרות
TradefedDelegator

זריקות
com.android.tradefed.config.ConfigurationException
ConfigurationException

createReleaseMap

public static  createReleaseMap (IInvocationContext context, 
                Throwable e)

ליצור מפה של מצב המכשירים כדי שניתן יהיה לשחרר אותם בצורה מתאימה.

פרמטרים
context IInvocationContext

e Throwable

החזרות

createSandbox

public ISandbox createSandbox ()

יוצרים ISandbox שההפעלה תשתמש בו כדי לפעול.

החזרות
ISandbox

displayCommandQueue

public void displayCommandQueue (PrintWriter printWriter)

הצגת פרטי ניפוי באגים מפורטים לגבי מצב תור הביצוע של הפקודות.

displayCommandsInfo

public void displayCommandsInfo (PrintWriter printWriter, 
                String regex)

הצגת רשימה של הפקודות הנוכחיות.

פרמטרים
printWriter PrintWriter: ERROR(/PrintWriter) שאליו רוצים להוציא את הפלט.

regex String: הביטוי הרגולרי שאליו הפקודות צריכות להתאים כדי להדפיס אותן. אם הערך הוא null, כל הפקודות יודפסו.

displayInvocationsInfo

public void displayInvocationsInfo (PrintWriter printWriter)

מוצגת רשימה של הפעלות נוכחיות.

פרמטרים
printWriter PrintWriter: ERROR(/PrintWriter) שאליו רוצים להוציא את הפלט.

dumpCommandsXml

public void dumpCommandsXml (PrintWriter printWriter, 
                String regex)

הפקת קובץ ה-XML המורחב של הפקודה עם כל הערכים של Option שצוינו לכל הפקודות הנוכחיות.

פרמטרים
printWriter PrintWriter: ERROR(/PrintWriter) שאליו יוצא הסטטוס.

regex String: הביטוי הרגולרי שאליו הפקודות צריכות להתאים כדי שקובץ ה-XML יימחק. אם הערך הוא null, כל הפקודות יוצגו.

execCommand

public long execCommand (ICommandScheduler.IScheduledInvocationListener listener, 
                ITestDevice device, 
                String[] args)

ביצוע ישיר של פקודה במכשיר שכבר הוקצה.

פרמטרים
listener ICommandScheduler.IScheduledInvocationListener: ICommandScheduler.IScheduledInvocationListener שצריך לעדכן

device ITestDevice: ITestDevice שבו רוצים להשתמש

args String: הארגומנטים של הפקודה

החזרות
long מזהה ההפעלה של הפקודה המתוזמנת.

זריקות
ConfigurationException

execCommand

public long execCommand (ICommandScheduler.IScheduledInvocationListener listener, 
                 reservedDevices, 
                String[] args)

הפעלה ישירה של פקודה במכשירים שכבר הוקצו.

פרמטרים
listener ICommandScheduler.IScheduledInvocationListener: ICommandScheduler.IScheduledInvocationListener שצריך לעדכן

reservedDevices : ERROR(/List) שבו רוצים להשתמש

args String: הארגומנטים של הפקודה

החזרות
long מזהה ההפעלה של הפקודה המתוזמנת.

זריקות
ConfigurationException

execCommand

public long execCommand (IInvocationContext context, 
                ICommandScheduler.IScheduledInvocationListener listener, 
                String[] args)

מקצה מכשיר באופן ישיר ומבצע פקודה בלי להוסיף אותה לתור הפקודות באמצעות IInvocationContext שכבר קיים.

פרמטרים
context IInvocationContext: IInvocationContext קיים.

listener ICommandScheduler.IScheduledInvocationListener: ICommandScheduler.IScheduledInvocationListener שצריך לעדכן

args String: הארגומנטים של הפקודה

החזרות
long

זריקות
ConfigurationException
NoDeviceException

execCommand

public long execCommand (ICommandScheduler.IScheduledInvocationListener listener, 
                String[] args)

הפקודה מקצה מכשיר באופן ישיר ומבצעת פקודה בלי להוסיף אותה לתור הפקודות.

פרמטרים
listener ICommandScheduler.IScheduledInvocationListener: ICommandScheduler.IScheduledInvocationListener שצריך לעדכן

args String: הארגומנטים של הפקודה

החזרות
long מזהה ההפעלה של הפקודה המתוזמנת.

זריקות
ConfigurationException
NoDeviceException

getCommandFileWatcher

public CommandFileWatcher getCommandFileWatcher ()

קבלת CommandFileWatcher מתאים לתזמן הזה

החזרות
CommandFileWatcher

getExecutingCommandCount

public int getExecutingCommandCount ()

הפונקציה מחזירה את מספר הפקודות במצב הפעלה.

החזרות
int

getHostState

public CommandScheduler.HostState getHostState ()

החזרות
CommandScheduler.HostState

getInvocationInfo

public String getInvocationInfo (int invocationId)

אפשר להחזיר את המידע על הפעלה על ידי ציון מזהה ההפעלה.

פרמטרים
invocationId int: מזהה המעקב של הקריאה.

החזרות
String רכיב String שמכיל מידע על הקריאה.

getLastInvocationExitCode

public CommandRunner.ExitCode getLastInvocationExitCode ()

החזרת קוד השגיאה של ההפעלה האחרונה שהופעלה. הפונקציה מחזירה 0 (ללא שגיאה) אם עדיין לא הופעלה קריאה.

החזרות
CommandRunner.ExitCode

getLastInvocationThrowable

public Throwable getLastInvocationThrowable ()

החזרת הערך Throwable מההפעלה האחרונה שהופעלה. הפונקציה מחזירה ערך null אם אין חריג זמין.

החזרות
Throwable

getReadyCommandCount

public int getReadyCommandCount ()

הפונקציה מחזירה את מספר הפקודות במצב מוכן בתור.

החזרות
int

getShutdownTimeout

public long getShutdownTimeout ()

החזרות
long

isDeviceInInvocationThread

public boolean isDeviceInInvocationThread (ITestDevice device)

הפונקציה מחזירה את הערך True אם המכשיר נמצא בשימוש על ידי שרשור הפעלה פעיל.

פרמטרים
device ITestDevice

החזרות
boolean

isShuttingDown

public boolean isShuttingDown ()

החזרות
boolean

notifyFileChanged

public void notifyFileChanged (File cmdFile, 
                 extraArgs)

פרמטרים
cmdFile File

extraArgs

removeAllCommands

public void removeAllCommands ()

הסרת כל הפקודות מהמתזמן

ראן

public void run ()

בלוק הביצוע הראשי של ה-thread הזה.

setClearcutClient

public void setClearcutClient (ClearcutClient client)

הגדרת הלקוח לדיווח על נתוני harness

פרמטרים
client ClearcutClient

setMaxPollTime

public void setMaxPollTime (long polling)

פרמטרים
polling long

setPrintSchedulingWarning

public void setPrintSchedulingWarning (boolean print)

פרמטרים
print boolean

shouldShutdownOnCmdfileError

public boolean shouldShutdownOnCmdfileError ()

הפונקציה מחזירה את הערך True אם צריך להשבית את מתזמן המשימות בגלל שגיאות בפקודה

החזרות
boolean

כיבוי

public void shutdown (boolean notifyStop)

מנסים לבצע כיבוי תקין של מתזמן הפקודות.

פרמטרים
notifyStop boolean: אם הערך הוא true, נשלחת הודעה על הפעלות של כיבוי TF.

shutdownHard

public void shutdownHard (boolean killAdb)

לנסות לכבות בכוח את מתזמן הפקודות.

דומה ל-shutdown(), אבל גם ינסה להפסיק את החיבור ל-adb, כדי לזרז את השלמת ההפעלות שנמצאות בתהליך.

פרמטרים
killAdb boolean

shutdownHard

public void shutdownHard ()

לנסות לכבות בכוח את מתזמן הפקודות. זהה ל-shutdownHard(true).

shutdownOnEmpty

public void shutdownOnEmpty ()

בדומה ל-shutdown(), אבל הפקודה הזו תמתין עד שכל הפקודות יבוצעו לפני היציאה.

שימו לב: אם יש פקודות במצב לולאה, מתזמן המשימות לא ייצא לעולם.

התחל

public void start ()

הפעלת המתזמן, כולל הגדרת הרישום ביומן, הפעלה ראשונית של DeviceManager וכו'

stopInvocation

public boolean stopInvocation (ITestInvocation invocation)

הפסקת הפעלה של פונקציה.

פרמטרים
invocation ITestInvocation

החזרות
boolean הערך true אם ההפעלה הופסקה, אחרת הערך הוא false

stopInvocation

public boolean stopInvocation (int invocationId, 
                String cause)

כדי להפסיק הפעלה של פונקציה, מציינים את המזהה שלה.

פרמטרים
invocationId int: מזהה המעקב של הקריאה.

cause String: הסיבה להפסקת הקריאה.

החזרות
boolean הערך true אם ההפעלה הופסקה, אחרת הערך הוא false

stopScheduling

public void stopScheduling ()

הוא מפסיק לתזמן ולבצע בדיקות חדשות, אבל לא מפסיק את Tradefed. המטרה היא לאפשר כיבוי בשני שלבים, שבו קודם מרוקנים את כל הבדיקות הפעילות ואז מסיימים את התהליך של Tradefed.

שיטות מוגנות

cleanUp

protected void cleanUp ()

סוגר את היומנים ומבצע ניקוי נתונים נחוץ אחר לפני היציאה.

הפונקציה חשופה כדי שבדיקות יחידה יוכלו לבצע מוקינג.

createConfiguration

protected IConfiguration createConfiguration (String[] args)

פרמטרים
args String

החזרות
IConfiguration

זריקות
ConfigurationException

createInvocationContext

protected IInvocationContext createInvocationContext ()

החזרות
IInvocationContext

dryRunCommandReporting

protected void dryRunCommandReporting (ICommandScheduler.IScheduledInvocationListener handler, 
                IConfiguration config)

קובעת אם פקודה נתונה היא הרצה יבשה. אם הפקודה היא הרצה יבשה, מאמתים אותה. אם יש בעיה בהגדרות, תופיע הודעת שגיאה מסוג ConfigurationException.

פרמטרים
handler ICommandScheduler.IScheduledInvocationListener: ERROR(/InvocationEventHandler) כדי לדווח על אירועים לצורך אימות של הרצה יבשה.

config IConfiguration

החזרות
void הערך true אם הפקודה היא הרצה יבשה, אחרת הערך הוא false.

זריקות
com.android.tradefed.config.ConfigurationException
ConfigurationException

execCommand

protected long execCommand (IInvocationContext context, 
                ICommandScheduler.IScheduledInvocationListener listener, 
                 reservedDevices, 
                String[] args)

פרמטרים
context IInvocationContext

listener ICommandScheduler.IScheduledInvocationListener

reservedDevices

args String

החזרות
long

זריקות
ConfigurationException

getConfigFactory

protected IConfigurationFactory getConfigFactory ()

שיטת Factory לקבלת הפניה אל IConfigurationFactory

החזרות
IConfigurationFactory הIConfigurationFactory לשימוש

getDeviceManagementServer

protected DeviceManagementGrpcServer getDeviceManagementServer ()

החזרות
DeviceManagementGrpcServer

getDeviceManager

protected IDeviceManager getDeviceManager ()

שיטת Factory לקבלת הפניה אל IDeviceManager

החזרות
IDeviceManager הIDeviceManager לשימוש

getFeatureServer

protected TradefedFeatureServer getFeatureServer ()

החזרות
TradefedFeatureServer

getHostOptions

protected IHostOptions getHostOptions ()

החזרות
IHostOptions

getKeyStoreClient

protected IKeyStoreClient getKeyStoreClient ()

מאחזר IKeyStoreClient באמצעות IKeyStoreFactory שהוגדר ב-IGlobalConfiguration, או null אם לא הוגדר אף אחד.

החזרות
IKeyStoreClient IKeyStoreClient

getTestInvocationManagementServer

protected TestInvocationManagementServer getTestInvocationManagementServer ()

החזרות
TestInvocationManagementServer

initLogging

protected void initLogging ()

מאתחל את יומן ddmlib.

הפונקציה חשופה כדי שבדיקות יחידה יוכלו לבצע מוקינג.

isShutdown

protected boolean isShutdown ()

החזרות
boolean

processReadyCommands

protected void processReadyCommands (IDeviceManager manager)

פרמטרים
manager IDeviceManager