CommandScheduler

public class CommandScheduler
extends Object implements ICommandScheduler

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


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

Tente de hiérarchiser les commandes à exécuter en fonction de la durée totale de leur exécution. Par exemple, les commandes peu fréquentes ou rapides seront privilégiées par rapport aux commandes longues.

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

Résumé

Constructeurs publics

CommandScheduler()

Crée un 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 que le transfert de l'ancien TF se termine, le cas échéant.

static TradefedDelegator checkDelegation(String[] args)

Créez un délégateur 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 correctement.

ISandbox createSandbox()

Créez un ISandbox que l'invocation 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 la liste des commandes actuelles.

void displayInvocationsInfo(PrintWriter printWriter)

Affiche la liste des invocations actuelles.

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 actuelles.

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

Exécutez directement une commande sur un appareil déjà attribué.

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

Exécutez directement une commande sur des appareils déjà attribué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 des 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 des commandes.

CommandFileWatcher getCommandFileWatcher()

Obtenir le CommandFileWatcher approprié pour ce planificateur

int getExecutingCommandCount()

Renvoie le nombre de commandes à l'état d'exécution.

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

Renvoie les informations sur un appel en spécifiant l'ID d'appel.

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 à l'état "Prêt" 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 programmateur

void run()

Bloc d'exécution principal de ce thread.

void setClearcutClient(ClearcutClient client)

Configurer le client pour qu'il signale les données du harnais

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

Renvoie la valeur "true" si le planificateur doit être arrêté en cas d'erreur de commande.

void shutdown(boolean notifyStop)

Tentative d'arrêt progressif du 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ête la planification et l'acceptation de nouveaux tests, mais n'arrête pas Tradefed.

Méthodes protégées

void cleanUp()

Ferme les journaux et effectue tout autre 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 null 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 CommandScheduler.

Remarque : start doit être appelé avant utilisation.

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 sera 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 valeur est un booléen true si la commande a été ajoutée avec succès. La deuxième valeur correspond à l'ID du suivi de 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, et -1 dans le cas contraire.

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 du fichier de commandes dans le système de fichiers

extraArgs  : ERROR(/List) d'arguments String à ajouter à chaque commande analysée à partir du 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 que le transfert de l'ancien TF se termine, le cas échéant.

checkDelegation

public static TradefedDelegator checkDelegation (String[] args)

Créez un délégateur 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 correctement.

Paramètres
context IInvocationContext

e Throwable

Renvoie

createSandbox

public ISandbox createSandbox ()

Créez un ISandbox que l'invocation 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 la liste des commandes actuelles.

Paramètres
printWriter PrintWriter : ERROR(/PrintWriter) vers lequel la sortie doit être envoyée.

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

displayInvocationsInfo

public void displayInvocationsInfo (PrintWriter printWriter)

Affiche la liste des invocations actuelles.

Paramètres
printWriter PrintWriter : ERROR(/PrintWriter) vers lequel la sortie doit être envoyée.

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 actuelles.

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

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

execCommand

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

Exécutez directement une commande sur un appareil déjà attribué.

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

device ITestDevice : ITestDevice à utiliser

args String : arguments de la commande

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

Génère
ConfigurationException

execCommand

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

Exécutez directement une commande sur des appareils déjà attribués.

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

reservedDevices  : ERROR(/List) à utiliser

args String : arguments de la commande

Renvoie
long ID d'invocation 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 des 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 des commandes.

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

args String : arguments de la commande

Renvoie
long ID d'invocation 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 à l'état d'exécution.

Renvoie
int

getHostState

public CommandScheduler.HostState getHostState ()

Renvoie
CommandScheduler.HostState

getInvocationInfo

public String getInvocationInfo (int invocationId)

Renvoie les informations sur un appel en spécifiant l'ID d'appel.

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

Renvoie
String Un 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 aucune exception n'est disponible.

Renvoie
Throwable

getReadyCommandCount

public int getReadyCommandCount ()

Renvoie le nombre de commandes à l'état "Prêt" 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 programmateur

Exécuter

public void run ()

Bloc d'exécution principal de ce thread.

setClearcutClient

public void setClearcutClient (ClearcutClient client)

Configurer le client pour qu'il signale les données du harnais

Paramètres
client ClearcutClient

setMaxPollTime

public void setMaxPollTime (long polling)

Paramètres
polling long

setPrintSchedulingWarning

public void setPrintSchedulingWarning (boolean print)

Paramètres
print boolean

shouldShutdownOnCmdfileError

public boolean shouldShutdownOnCmdfileError ()

Renvoie la valeur "true" si le planificateur doit être arrêté en cas d'erreur de commande.

Renvoie
boolean

arrêt

public void shutdown (boolean notifyStop)

Tentative d'arrêt progressif du planificateur de commandes.

Paramètres
notifyStop boolean : si la valeur est "true", les appels sont informés 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'inciter les invocations en cours à se terminer 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 se fermera 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'invocation a été arrêtée, "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'invocation.

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

stopScheduling

public void stopScheduling ()

Arrête la planification et l'acceptation de nouveaux tests, mais n'arrête pas Tradefed. L'objectif est d'activer un arrêt en deux étapes : d'abord, nous vidons tous les tests en cours d'exécution, puis nous mettons fin au processus Tradefed.

Méthodes protégées

cleanUp

protected void cleanUp ()

Ferme les journaux et effectue tout autre 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 sera générée.

Paramètres
handler ICommandScheduler.IScheduledInvocationListener : ERROR(/InvocationEventHandler) pour signaler les événements de validation en mode test.

config IConfiguration

Renvoie
void "true" si la commande est un test à blanc, "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 null 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