Search in sources :

Example 1 with LocalLoadExecutor

use of com.axway.ats.agent.webapp.client.executors.LocalLoadExecutor in project ats-framework by Axway.

the class ActionQueue method executeQueuedActions.

/**
    * Execute all queued actions in multiple threads
    *
    * @param atsAgents the hosts to execute to
    * @param threadingPattern the multithreading pattern
    * @param loaderDataConfig the loader variable data configuration
    * @throws AgentException on error
    */
public void executeQueuedActions(List<String> atsAgents, ThreadingPattern threadingPattern, LoaderDataConfig loaderDataConfig) throws AgentException {
    if (threadingPattern == null) {
        throw new AgentException("Threading pattern is not specified. You must specify one");
    }
    isQueueFinished = false;
    //create an empty instance of the config
    if (loaderDataConfig == null) {
        loaderDataConfig = new LoaderDataConfig();
    }
    if (atsAgents == null || atsAgents.size() == 0) {
        //local execution
        LocalLoadExecutor localLoadExecutor = new LocalLoadExecutor(name, sequence, threadingPattern, loaderDataConfig);
        localLoadExecutor.executeActions(queuedActions);
    } else {
        if (threadingPattern.getThreadCount() < atsAgents.size()) {
            String firstHost = atsAgents.get(0);
            log.warn("The total number of threads [" + threadingPattern.getThreadCount() + "] is less than the number of remote execution hosts [" + atsAgents.size() + "], so all threads will be run on just one host [" + firstHost + "]");
            atsAgents = new ArrayList<String>();
            atsAgents.add(firstHost);
        }
        //distributed remote execution
        DistributedLoadExecutor distributedLoadExecutor = new DistributedLoadExecutor(name, sequence, atsAgents, threadingPattern, loaderDataConfig);
        distributedLoadExecutor.executeActions(queuedActions);
    }
    if (threadingPattern.isBlockUntilCompletion()) {
        isQueueFinished = true;
    }
    inQueueMode = false;
}
Also used : DistributedLoadExecutor(com.axway.ats.agent.webapp.client.executors.DistributedLoadExecutor) AgentException(com.axway.ats.agent.core.exceptions.AgentException) LocalLoadExecutor(com.axway.ats.agent.webapp.client.executors.LocalLoadExecutor) LoaderDataConfig(com.axway.ats.agent.core.threading.data.config.LoaderDataConfig)

Aggregations

AgentException (com.axway.ats.agent.core.exceptions.AgentException)1 LoaderDataConfig (com.axway.ats.agent.core.threading.data.config.LoaderDataConfig)1 DistributedLoadExecutor (com.axway.ats.agent.webapp.client.executors.DistributedLoadExecutor)1 LocalLoadExecutor (com.axway.ats.agent.webapp.client.executors.LocalLoadExecutor)1