Search in sources :

Example 1 with QueueLoader

use of com.axway.ats.agent.core.threading.QueueLoader in project ats-framework by Axway.

the class MultiThreadedActionHandler method resumeQueue.

public void resumeQueue(String actionQueueName) throws NoSuchLoadQueueException, ActionExecutionException, ActionTaskLoaderException {
    //first cleanup the queues
    cleanupFinishedQueues();
    QueueLoader queueLoader = queueLoadersMap.get(actionQueueName);
    if (queueLoader == null) {
        throw new NoSuchLoadQueueException(actionQueueName);
    }
    //resume the queue
    queueLoader.resume();
}
Also used : QueueLoader(com.axway.ats.agent.core.threading.QueueLoader) AbstractQueueLoader(com.axway.ats.agent.core.threading.AbstractQueueLoader) NoSuchLoadQueueException(com.axway.ats.agent.core.threading.exceptions.NoSuchLoadQueueException)

Example 2 with QueueLoader

use of com.axway.ats.agent.core.threading.QueueLoader in project ats-framework by Axway.

the class MultiThreadedActionHandler method scheduleActions.

/**
     * @param caller
     * @param queueName
     * @param actionRequests
     * @param threadingPattern
     * @throws NoSuchComponentException
     * @throws NoSuchActionException
     * @throws NoCompatibleMethodFoundException
     * @throws ThreadingPatternNotSupportedException
     * @throws ActionExecutionException
     * @throws ActionTaskLoaderException
     * @throws LoadQueueAlreadyExistsException
     * @throws ParameterDataProviderNotSupportedException
     * @throws ParameterDataProviderInitalizationException
     */
public void scheduleActions(String caller, String queueName, int queueId, List<ActionRequest> actionRequests, ThreadingPattern threadingPattern, LoaderDataConfig loaderDataConfig, boolean isUseSynchronizedIterations) throws NoSuchComponentException, NoSuchActionException, NoCompatibleMethodFoundException, ThreadingPatternNotSupportedException, ActionExecutionException, ActionTaskLoaderException, LoadQueueAlreadyExistsException, ParameterDataProviderNotSupportedException, ParameterDataProviderInitalizationException {
    //first cleanup the queues
    cleanupFinishedQueues();
    //check if we already have this queue and it has not finished yet
    //if the queue has finished, we can simply discard it
    QueueLoader queueLoader = queueLoadersMap.get(queueName);
    if (queueLoader != null) {
        throw new LoadQueueAlreadyExistsException(queueName, queueLoader.getState());
    }
    //create the data providers
    List<ParameterDataProvider> parameterDataProviders = new ArrayList<ParameterDataProvider>();
    for (ParameterDataConfig paramDataConfigs : loaderDataConfig.getParameterConfigurations()) {
        parameterDataProviders.add(ParameterDataProviderFactory.createDataProvider(paramDataConfigs));
    }
    //create the loader
    queueLoader = LoadQueueFactory.createLoadQueue(queueName, actionRequests, threadingPattern, parameterDataProviders, listeners);
    log.rememberLoadQueueState(queueName, queueId, threadingPattern.getPatternDescription(), threadingPattern.getThreadCount());
    //start the queue
    queueLoader.scheduleThreads(caller, isUseSynchronizedIterations);
    queueLoadersMap.put(queueName, queueLoader);
    log.info("Scheduled queue '" + queueName + "'");
}
Also used : QueueLoader(com.axway.ats.agent.core.threading.QueueLoader) AbstractQueueLoader(com.axway.ats.agent.core.threading.AbstractQueueLoader) LoadQueueAlreadyExistsException(com.axway.ats.agent.core.threading.exceptions.LoadQueueAlreadyExistsException) ParameterDataProvider(com.axway.ats.agent.core.threading.data.ParameterDataProvider) ParameterDataConfig(com.axway.ats.agent.core.threading.data.config.ParameterDataConfig) ArrayList(java.util.ArrayList)

Example 3 with QueueLoader

use of com.axway.ats.agent.core.threading.QueueLoader in project ats-framework by Axway.

the class MultiThreadedActionHandler method waitUntilAllQueuesFinish.

/**
     * Wait until a all started queues finish
     */
public void waitUntilAllQueuesFinish() {
    Set<QueueLoader> queueLoadersClone = new HashSet<QueueLoader>(queueLoadersMap.values());
    for (QueueLoader queueLoader : queueLoadersClone) {
        //wait until the queue finishes
        queueLoader.waitUntilFinished();
    }
    // cleanup the FINISHED queues
    cleanupFinishedQueues();
}
Also used : QueueLoader(com.axway.ats.agent.core.threading.QueueLoader) AbstractQueueLoader(com.axway.ats.agent.core.threading.AbstractQueueLoader) HashSet(java.util.HashSet)

Example 4 with QueueLoader

use of com.axway.ats.agent.core.threading.QueueLoader in project ats-framework by Axway.

the class MultiThreadedActionHandler method cancelQueue.

/**
     * Cancel queue
     */
public void cancelQueue(String queueName) {
    //cancel queue
    for (QueueLoader queueLoader : queueLoadersMap.values()) {
        if ((queueLoader instanceof AbstractQueueLoader) && ((AbstractQueueLoader) queueLoader).getName().equals(queueName)) {
            queueLoader.cancel();
        }
    }
    log.info("Cancelled execution of queue '" + queueName + "'");
    // cleanup the FINISHED queues
    cleanupFinishedQueues();
}
Also used : QueueLoader(com.axway.ats.agent.core.threading.QueueLoader) AbstractQueueLoader(com.axway.ats.agent.core.threading.AbstractQueueLoader) AbstractQueueLoader(com.axway.ats.agent.core.threading.AbstractQueueLoader)

Example 5 with QueueLoader

use of com.axway.ats.agent.core.threading.QueueLoader in project ats-framework by Axway.

the class MultiThreadedActionHandler method waitUntilQueueFinish.

/**
     * Wait until a given queue finishes
     *
     * @param queueName name of the queue
     * @throws NoSuchLoadQueueException if such queue has not been started
     */
public void waitUntilQueueFinish(String queueName) throws NoSuchLoadQueueException {
    QueueLoader queueLoader = queueLoadersMap.get(queueName);
    if (queueLoader == null) {
        log.warn("We will not wait for queue with name '" + queueName + "' to finish as such queue is not present");
    } else {
        //wait until the queue finishes
        queueLoader.waitUntilFinished();
        // cleanup the FINISHED queues
        cleanupFinishedQueues();
    }
}
Also used : QueueLoader(com.axway.ats.agent.core.threading.QueueLoader) AbstractQueueLoader(com.axway.ats.agent.core.threading.AbstractQueueLoader)

Aggregations

AbstractQueueLoader (com.axway.ats.agent.core.threading.AbstractQueueLoader)6 QueueLoader (com.axway.ats.agent.core.threading.QueueLoader)6 NoSuchLoadQueueException (com.axway.ats.agent.core.threading.exceptions.NoSuchLoadQueueException)2 ParameterDataProvider (com.axway.ats.agent.core.threading.data.ParameterDataProvider)1 ParameterDataConfig (com.axway.ats.agent.core.threading.data.config.ParameterDataConfig)1 LoadQueueAlreadyExistsException (com.axway.ats.agent.core.threading.exceptions.LoadQueueAlreadyExistsException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1