CommandScheduler

public class CommandScheduler
extends Object implements ICommandScheduler

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


Un planificateur permettant d'exécuter des commandes TradeFederation sur tous les appareils disponibles.

Essaye de hiérarchiser les commandes à exécuter en fonction du nombre total d'exécutions de leur temps d'exécution. Par exemple, les commandes exécutées rarement ou rapidement seront prioritaires sur les commandes exécutées sur une longue période.

S'exécute en arrière-plan sans fin jusqu'à l'arrêt.

Résumé

Constructeurs publics

CommandScheduler()

Crée un objet CommandScheduler.

Méthodes publiques

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

Ajoute une commande au planificateur.

void addCommandFile(String cmdFilePath, extraArgs)

Ajoute toutes les commandes du fichier donné au planificateur

void await()

Attend que le planificateur commence à s'exécuter, y compris qu'il attend la fin de la transition de l'ancien TF, le cas échéant.

static TradefedDelegator checkDelegation(String[] args)

Créez un délégué basé sur la ligne de commande pour voir si nous devons déléguer l'exécution.

static createReleaseMap(IInvocationContext context, Throwable e)

Créez une carte de l'état des appareils afin qu'ils puissent être libérés de manière appropriée.

ISandbox createSandbox()

Créez un ISandbox que l'appel utilisera pour s'exécuter.

void displayCommandQueue(PrintWriter printWriter)

Affiche des informations de débogage détaillées sur l'état de la file d'exécution des commandes.

void displayCommandsInfo(PrintWriter printWriter, String regex)

Affiche une liste des commandes en cours.

void displayInvocationsInfo(PrintWriter printWriter)

Affiche la liste des invocations en cours.

void dumpCommandsXml(PrintWriter printWriter, String regex)

Videz le fichier XML développé pour la commande avec toutes les valeurs Option spécifiées pour toutes les commandes en cours.

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

Exécutez directement la commande sur un appareil déjà alloué.

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

Exécutez directement la commande sur les appareils déjà alloués.

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

Alloue directement un appareil et exécute une commande sans l'ajouter à la file d'attente de commandes à l'aide d'un IInvocationContext déjà existant.

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

Alloue directement un appareil et exécute une commande sans l'ajouter à la file d'attente de commandes.

CommandFileWatcher getCommandFileWatcher()

Obtenir le CommandFileWatcher approprié pour ce planificateur

int getExecutingCommandCount()

Renvoie le nombre de commandes en cours d'exécution.

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

Renvoyez les informations sur une invocation en spécifiant l'ID d'invocation.

CommandRunner.ExitCode getLastInvocationExitCode()

Renvoie le code d'erreur de la dernière invocation exécutée.

Throwable getLastInvocationThrowable()

Renvoie le Throwable de la dernière invocation exécutée.

int getReadyCommandCount()

Renvoie le nombre de commandes prêtes dans la file d'attente.

long getShutdownTimeout()
boolean isDeviceInInvocationThread(ITestDevice device)

Renvoie la valeur "true" si l'appareil est utilisé par un thread d'invocation actif.

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

Supprimer toutes les commandes du planificateur

void run()

Bloc d'exécution principal de ce thread.

void setClearcutClient(ClearcutClient client)

Configurer le client pour générer des rapports sur les données du faisceau

boolean shouldShutdownOnCmdfileError()

Renvoie la valeur "true" si nous devons arrêter le planificateur en cas d'erreur de commande.

void shutdown(boolean notifyStop)

Essayez d'arrêter de manière appropriée le planificateur de commandes.

void shutdownHard(boolean killAdb)

Tentative d'arrêt forcé du planificateur de commandes.

void shutdownHard()

Tentative d'arrêt forcé du planificateur de commandes.

void shutdownOnEmpty()

Semblable à shutdown(), mais attend que toutes les commandes soient exécutées avant de se fermer.

void start()

Démarre le planificateur, y compris la configuration de la journalisation, l'initialisation de DeviceManager, etc.

boolean stopInvocation(ITestInvocation invocation)

Arrêtez une invocation en cours d'exécution.

boolean stopInvocation(int invocationId, String cause)

Arrêtez une invocation en cours d'exécution en spécifiant son ID.

void stopScheduling()

Arrêt de la planification et de l'acceptation de nouveaux tests, mais Tradefed continue de fonctionner.

Méthodes protégées

void cleanUp()

Ferme les journaux et effectue tout nettoyage nécessaire avant de quitter.

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

Détermine si une commande donnée est une simulation.

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

Méthode de fabrique permettant d'obtenir une référence à IConfigurationFactory

DeviceManagementGrpcServer getDeviceManagementServer()
IDeviceManager getDeviceManager()

Méthode de fabrique permettant d'obtenir une référence à IDeviceManager

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

Récupère un IKeyStoreClient à l'aide du IKeyStoreFactory déclaré dans IGlobalConfiguration ou de la valeur nulle si aucun n'est défini.

TestInvocationManagementServer getTestInvocationManagementServer()
void initLogging()

Initialise le journal ddmlib.

boolean isShutdown()
void processReadyCommands(IDeviceManager manager)

Constructeurs publics

CommandScheduler

public CommandScheduler ()

Crée un objet CommandScheduler.

Remarque: start doit être appelé avant d'être utilisé.

Méthodes publiques

addCommand

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

Ajoute une commande au planificateur.

Une commande est essentiellement une instance d'une configuration à exécuter et de ses arguments associés.

Si l'argument "--help" est spécifié, le texte d'aide de la configuration est affiché sur la sortie standard. Sinon, la configuration sera ajoutée à la file d'attente pour être exécutée.

Paramètres
args String: arguments de configuration.

Renvoie
Pair<Boolean, Integer> Paire de valeurs, la première étant un true booléen si la commande a été ajoutée avec succès. La deuxième valeur correspond à l'ID de suivi de la commande connu(valeur non négative) si la commande a été ajoutée avec succès. Elle renvoie 0 lorsque la commande est ajoutée pour tous les appareils, sinon -1.

Génère
ConfigurationException

addCommandFile

public void addCommandFile (String cmdFilePath, 
                 extraArgs)

Ajoute toutes les commandes du fichier donné au planificateur

Paramètres
cmdFilePath String: chemin d'accès au système de fichiers du fichier de commande

extraArgs : ERROR(/List) d'arguments String à ajouter à chaque commande analysée à partir d'un fichier. Peut être vide, mais ne doit pas être nul.

Génère
ConfigurationException

await

public void await ()

Attend que le planificateur commence à s'exécuter, y compris qu'il attend la fin de la transition de l'ancien TF, le cas échéant.

checkDelegation

public static TradefedDelegator checkDelegation (String[] args)

Créez un délégué basé sur la ligne de commande pour voir si nous devons déléguer l'exécution.

Paramètres
args String

Renvoie
TradefedDelegator

Génère
com.android.tradefed.config.ConfigurationException
ConfigurationException

createReleaseMap

public static  createReleaseMap (IInvocationContext context, 
                Throwable e)

Créez une carte de l'état des appareils afin qu'ils puissent être libérés de manière appropriée.

Paramètres
context IInvocationContext

e Throwable

Renvoie

createSandbox

public ISandbox createSandbox ()

Créez un ISandbox que l'appel utilisera pour s'exécuter.

Renvoie
ISandbox

displayCommandQueue

public void displayCommandQueue (PrintWriter printWriter)

Affiche des informations de débogage détaillées sur l'état de la file d'exécution des commandes.

displayCommandsInfo

public void displayCommandsInfo (PrintWriter printWriter, 
                String regex)

Affiche une liste des commandes en cours.

Paramètres
printWriter PrintWriter: ERROR(/PrintWriter) à utiliser pour la sortie.

regex String: expression régulière à laquelle les commandes doivent correspondre pour être imprimées. Si la valeur est nulle, toutes les commandes sont imprimées.

displayInvocationsInfo

public void displayInvocationsInfo (PrintWriter printWriter)

Affiche la liste des invocations en cours.

Paramètres
printWriter PrintWriter: ERROR(/PrintWriter) à utiliser pour la sortie.

dumpCommandsXml

public void dumpCommandsXml (PrintWriter printWriter, 
                String regex)

Videz le fichier XML développé pour la commande avec toutes les valeurs Option spécifiées pour toutes les commandes en cours.

Paramètres
printWriter PrintWriter: ERROR(/PrintWriter) à utiliser pour afficher l'état.

regex String: expression régulière à laquelle les commandes doivent correspondre pour que le fichier XML soit extrait. Si la valeur est nulle, toutes les commandes sont affichées.

execCommand

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

Exécutez directement la commande sur un appareil déjà alloué.

Paramètres
listener ICommandScheduler.IScheduledInvocationListener: ICommandScheduler.IScheduledInvocationListener à informer

device ITestDevice: ITestDevice à utiliser

args String: arguments de la commande

Renvoie
long ID d'appel de la commande planifiée.

Génère
ConfigurationException

execCommand

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

Exécutez directement la commande sur les appareils déjà alloués.

Paramètres
listener ICommandScheduler.IScheduledInvocationListener: ICommandScheduler.IScheduledInvocationListener à informer

reservedDevices : ERROR(/List) à utiliser

args String: arguments de la commande

Renvoie
long ID d'appel de la commande planifiée.

Génère
ConfigurationException

execCommand

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

Alloue directement un appareil et exécute une commande sans l'ajouter à la file d'attente de commandes à l'aide d'un IInvocationContext déjà existant.

Paramètres
context IInvocationContext: IInvocationContext existant.

listener ICommandScheduler.IScheduledInvocationListener: ICommandScheduler.IScheduledInvocationListener à informer

args String: arguments de la commande

Renvoie
long

Génère
ConfigurationException
NoDeviceException

execCommand

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

Alloue directement un appareil et exécute une commande sans l'ajouter à la file d'attente de commandes.

Paramètres
listener ICommandScheduler.IScheduledInvocationListener: ICommandScheduler.IScheduledInvocationListener à informer

args String: arguments de la commande

Renvoie
long ID d'appel de la commande planifiée.

Génère
ConfigurationException
NoDeviceException

getCommandFileWatcher

public CommandFileWatcher getCommandFileWatcher ()

Obtenir le CommandFileWatcher approprié pour ce planificateur

Renvoie
CommandFileWatcher

getExecutingCommandCount

public int getExecutingCommandCount ()

Renvoie le nombre de commandes en cours d'exécution.

Renvoie
int

getHostState

public CommandScheduler.HostState getHostState ()

Renvoie
CommandScheduler.HostState

getInvocationInfo

public String getInvocationInfo (int invocationId)

Renvoyez les informations sur une invocation en spécifiant l'ID d'invocation.

Paramètres
invocationId int: ID de suivi de l'appel.

Renvoie
String String contenant des informations sur l'appel.

getLastInvocationExitCode

public CommandRunner.ExitCode getLastInvocationExitCode ()

Renvoie le code d'erreur de la dernière invocation exécutée. Renvoie 0 (aucune erreur) si aucune invocation n'a encore été exécutée.

Renvoie
CommandRunner.ExitCode

getLastInvocationThrowable

public Throwable getLastInvocationThrowable ()

Renvoie le Throwable de la dernière invocation exécutée. Renvoie la valeur "null" si aucun throwable n'est disponible.

Renvoie
Throwable

getReadyCommandCount

public int getReadyCommandCount ()

Renvoie le nombre de commandes prêtes dans la file d'attente.

Renvoie
int

getShutdownTimeout

public long getShutdownTimeout ()

Renvoie
long

isDeviceInInvocationThread

public boolean isDeviceInInvocationThread (ITestDevice device)

Renvoie la valeur "true" si l'appareil est utilisé par un thread d'invocation actif.

Paramètres
device ITestDevice

Renvoie
boolean

isShuttingDown

public boolean isShuttingDown ()

Renvoie
boolean

notifyFileChanged

public void notifyFileChanged (File cmdFile, 
                 extraArgs)

Paramètres
cmdFile File

extraArgs

removeAllCommands

public void removeAllCommands ()

Supprimer toutes les commandes du planificateur

Exécuter

public void run ()

Bloc d'exécution principal de ce thread.

setClearcutClient

public void setClearcutClient (ClearcutClient client)

Configurer le client pour générer des rapports sur les données du faisceau

Paramètres
client ClearcutClient

shouldShutdownOnCmdfileError

public boolean shouldShutdownOnCmdfileError ()

Renvoie la valeur "true" si nous devons arrêter le planificateur en cas d'erreur de commande.

Renvoie
boolean

arrêt

public void shutdown (boolean notifyStop)

Essayez d'arrêter de manière appropriée le planificateur de commandes.

Paramètres
notifyStop boolean: si la valeur est "true", informe les appels de l'arrêt de TF.

shutdownHard

public void shutdownHard (boolean killAdb)

Tentative d'arrêt forcé du planificateur de commandes.

Semblable à shutdown(), mais peut également fermer la connexion adb, dans le but d''inspirer' les invocations en cours pour qu'elles soient effectuées plus rapidement.

Paramètres
killAdb boolean

shutdownHard

public void shutdownHard ()

Tentative d'arrêt forcé du planificateur de commandes. Identique à shutdownHard(true).

shutdownOnEmpty

public void shutdownOnEmpty ()

Semblable à shutdown(), mais attend que toutes les commandes soient exécutées avant de se fermer.

Notez que si des commandes sont en mode boucle, le planificateur ne s'arrêtera jamais.

départ

public void start ()

Démarre le planificateur, y compris la configuration de la journalisation, l'initialisation de DeviceManager, etc.

stopInvocation

public boolean stopInvocation (ITestInvocation invocation)

Arrêtez une invocation en cours d'exécution.

Paramètres
invocation ITestInvocation

Renvoie
boolean "true" si l'appel a été arrêté, "false" dans le cas contraire

stopInvocation

public boolean stopInvocation (int invocationId, 
                String cause)

Arrêtez une invocation en cours d'exécution en spécifiant son ID.

Paramètres
invocationId int: ID de suivi de l'appel.

cause String: cause de l'arrêt de l'appel.

Renvoie
boolean "true" si l'appel a été arrêté, "false" dans le cas contraire

stopScheduling

public void stopScheduling ()

Arrêt de la planification et de l'acceptation de nouveaux tests, mais Tradefed continue de fonctionner. Cela permet d'effectuer un arrêt en deux étapes, où nous vidons d'abord tous les tests en cours d'exécution, puis arrêtons le processus Tradefed.

Méthodes protégées

cleanUp

protected void cleanUp ()

Ferme les journaux et effectue tout nettoyage nécessaire avant de quitter.

Exposé pour que les tests unitaires puissent simuler.

createConfiguration

protected IConfiguration createConfiguration (String[] args)

Paramètres
args String

Renvoie
IConfiguration

Génère
ConfigurationException

createInvocationContext

protected IInvocationContext createInvocationContext ()

Renvoie
IInvocationContext

dryRunCommandReporting

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

Détermine si une commande donnée est une simulation. Si la commande est une simulation, validez-la. En cas de problème de configuration, une exception ConfigurationException est générée.

Paramètres
handler ICommandScheduler.IScheduledInvocationListener: ERROR(/InvocationEventHandler) pour signaler les événements à des fins de validation à blanc.

config IConfiguration

Renvoie
void "true" si la commande est un "test", "false" dans le cas contraire.

Génère
com.android.tradefed.config.ConfigurationException
ConfigurationException

execCommand

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

Paramètres
context IInvocationContext

listener ICommandScheduler.IScheduledInvocationListener

reservedDevices

args String

Renvoie
long

Génère
ConfigurationException

getConfigFactory

protected IConfigurationFactory getConfigFactory ()

Méthode de fabrique permettant d'obtenir une référence à IConfigurationFactory

Renvoie
IConfigurationFactory le IConfigurationFactory à utiliser

getDeviceManagementServer

protected DeviceManagementGrpcServer getDeviceManagementServer ()

Renvoie
DeviceManagementGrpcServer

getDeviceManager

protected IDeviceManager getDeviceManager ()

Méthode de fabrique permettant d'obtenir une référence à IDeviceManager

Renvoie
IDeviceManager le IDeviceManager à utiliser

getFeatureServer

protected TradefedFeatureServer getFeatureServer ()

Renvoie
TradefedFeatureServer

getHostOptions

protected IHostOptions getHostOptions ()

Renvoie
IHostOptions

getKeyStoreClient

protected IKeyStoreClient getKeyStoreClient ()

Récupère un IKeyStoreClient à l'aide du IKeyStoreFactory déclaré dans IGlobalConfiguration ou de la valeur nulle si aucun n'est défini.

Renvoie
IKeyStoreClient IKeyStoreClient

getTestInvocationManagementServer

protected TestInvocationManagementServer getTestInvocationManagementServer ()

Renvoie
TestInvocationManagementServer

initLogging

protected void initLogging ()

Initialise le journal ddmlib.

Exposé pour que les tests unitaires puissent simuler.

isShutdown

protected boolean isShutdown ()

Renvoie
boolean

processReadyCommands

protected void processReadyCommands (IDeviceManager manager)

Paramètres
manager IDeviceManager