Search in sources :

Example 1 with ThreadingPatternNotSupportedException

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

the class LoadQueueFactory method createLoadQueue.

/**
     * Create an action task load queue based on the threading pattern selected
     * 
     * @param queueName name of the queue
     * @param actionRequests the action requests to execute with this queue
     * @param threadingPattern the threading pattern
     * @return
     * @throws NoSuchComponentException there is no registered component for one of the requested actions
     * @throws NoSuchActionException one of the actions requested does not exist
     * @throws NoCompatibleMethodFoundException if no action method is found, which corresponds to this request
     * @throws ThreadingPatternNotSupportedException if the supplied threading pattern is not supported
     */
public static final QueueLoader createLoadQueue(String queueName, List<ActionRequest> actionRequests, ThreadingPattern threadingPattern, List<ParameterDataProvider> parameterDataProviders, List<QueueLoaderListener> listeners) throws NoSuchComponentException, NoSuchActionException, NoCompatibleMethodFoundException, ThreadingPatternNotSupportedException {
    if (listeners == null) {
        listeners = new ArrayList<QueueLoaderListener>();
    }
    if (threadingPattern.getClass() == AllAtOncePattern.class) {
        //convert the "all at once" to "ramp up pattern"
        AllAtOncePattern allAtOncePattern = (AllAtOncePattern) threadingPattern;
        RampUpPattern rampUpPattern = new RampUpPattern(allAtOncePattern.getThreadCount(), allAtOncePattern.isBlockUntilCompletion(), allAtOncePattern.getIterationCount(), allAtOncePattern.getIntervalBetweenIterations());
        rampUpPattern.setMinIntervalBetweenIterations(allAtOncePattern.getMinIntervalBetweenIterations());
        rampUpPattern.setMaxIntervalBetweenIterations(allAtOncePattern.getMaxIntervalBetweenIterations());
        rampUpPattern.setIterationTimeout(allAtOncePattern.getIterationTimeout());
        return new RampUpQueueLoader(queueName, actionRequests, rampUpPattern, allAtOncePattern, parameterDataProviders, listeners);
    } else if (threadingPattern.getClass() == FixedDurationAllAtOncePattern.class) {
        //convert the "fixed duration all at once" to "fixed duration ramp up pattern"
        FixedDurationAllAtOncePattern allAtOncePattern = (FixedDurationAllAtOncePattern) threadingPattern;
        FixedDurationRampUpPattern rampUpPattern = new FixedDurationRampUpPattern(allAtOncePattern.getThreadCount(), allAtOncePattern.isBlockUntilCompletion(), allAtOncePattern.getDuration(), allAtOncePattern.getIntervalBetweenIterations());
        rampUpPattern.setMinIntervalBetweenIterations(allAtOncePattern.getMinIntervalBetweenIterations());
        rampUpPattern.setMaxIntervalBetweenIterations(allAtOncePattern.getMaxIntervalBetweenIterations());
        rampUpPattern.setIterationTimeout(threadingPattern.getIterationTimeout());
        return new RampUpQueueLoader(queueName, actionRequests, rampUpPattern, allAtOncePattern, parameterDataProviders, listeners);
    } else if (threadingPattern.getClass() == RampUpPattern.class || threadingPattern.getClass() == FixedDurationRampUpPattern.class) {
        //this is a real ramp-up pattern
        return new RampUpQueueLoader(queueName, actionRequests, (RampUpStartPattern) threadingPattern, (ExecutionPattern) threadingPattern, parameterDataProviders, listeners);
    } else {
        throw new ThreadingPatternNotSupportedException(threadingPattern.getClass().getSimpleName());
    }
}
Also used : ThreadingPatternNotSupportedException(com.axway.ats.agent.core.threading.exceptions.ThreadingPatternNotSupportedException) QueueLoaderListener(com.axway.ats.agent.core.threading.listeners.QueueLoaderListener) AllAtOncePattern(com.axway.ats.agent.core.threading.patterns.AllAtOncePattern) FixedDurationAllAtOncePattern(com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern) FixedDurationRampUpPattern(com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern) RampUpPattern(com.axway.ats.agent.core.threading.patterns.RampUpPattern) FixedDurationRampUpPattern(com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern) FixedDurationAllAtOncePattern(com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern)

Example 2 with ThreadingPatternNotSupportedException

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

the class ActionTaskFactory method createTask.

/**
     * Create an action task based on the provided input data
     * 
     * @param caller the remote caller
     * @param threadingPattern the threading pattern
     * @param threadsManager the thread iterations manager for the task
     * @param actionRequests the action requests
     * @param parameterDataProviders the data providers for the parameters
     * @param listeners the task event listeners
     * @return the created action task
     * @throws NoCompatibleMethodFoundException 
     * @throws NoSuchActionException 
     * @throws NoSuchComponentException 
     * @throws ActionExecutionException 
     * @throws ThreadingPatternNotSupportedException 
     */
public static final Runnable createTask(String caller, String queueName, ExecutionPattern executionPattern, int executionsPerTimeFrame, ThreadsManager threadsManager, IterationTimeoutManager itManager, List<ActionRequest> actionRequests, List<ParameterDataProvider> parameterDataProviders, List<ActionTaskListener> listeners, boolean isUseSynchronizedIterations) throws ActionExecutionException, NoSuchComponentException, NoSuchActionException, NoCompatibleMethodFoundException, ThreadingPatternNotSupportedException {
    if (executionPattern instanceof FixedInvocationsExecutionPattern) {
        FixedInvocationsExecutionPattern fixedInvocationsExecutionPattern = (FixedInvocationsExecutionPattern) executionPattern;
        int iterationCount = fixedInvocationsExecutionPattern.getIterationCount();
        long intervalBetweenIterations = fixedInvocationsExecutionPattern.getIntervalBetweenIterations();
        long minIntervalBetweenIterations = fixedInvocationsExecutionPattern.getMinIntervalBetweenIterations();
        long maxIntervalBetweenIterations = fixedInvocationsExecutionPattern.getMaxIntervalBetweenIterations();
        long timeFrame = fixedInvocationsExecutionPattern.getTimeFrame();
        return new MultipleInvocationsActionTask(caller, queueName, threadsManager, itManager, iterationCount, intervalBetweenIterations, minIntervalBetweenIterations, maxIntervalBetweenIterations, executionsPerTimeFrame, timeFrame, actionRequests, parameterDataProviders, listeners, isUseSynchronizedIterations);
    } else if (executionPattern instanceof FixedDurationExecutionPattern) {
        FixedDurationExecutionPattern fixedDurationExecutionPattern = (FixedDurationExecutionPattern) executionPattern;
        int duration = fixedDurationExecutionPattern.getDuration();
        long intervalBetweenIterations = fixedDurationExecutionPattern.getIntervalBetweenIterations();
        long minIntervalpBetweenIterations = fixedDurationExecutionPattern.getMinIntervalBetweenIterations();
        long maxIntervalBetweenIterations = fixedDurationExecutionPattern.getMaxIntervalBetweenIterations();
        long timeFrame = fixedDurationExecutionPattern.getTimeFrame();
        return new FixedDurationActionTask(caller, queueName, threadsManager, itManager, duration, intervalBetweenIterations, minIntervalpBetweenIterations, maxIntervalBetweenIterations, executionsPerTimeFrame, timeFrame, actionRequests, parameterDataProviders, listeners, isUseSynchronizedIterations);
    } else {
        throw new ThreadingPatternNotSupportedException(executionPattern.getClass().getSimpleName());
    }
}
Also used : FixedInvocationsExecutionPattern(com.axway.ats.agent.core.threading.patterns.model.FixedInvocationsExecutionPattern) ThreadingPatternNotSupportedException(com.axway.ats.agent.core.threading.exceptions.ThreadingPatternNotSupportedException) FixedDurationExecutionPattern(com.axway.ats.agent.core.threading.patterns.model.FixedDurationExecutionPattern)

Aggregations

ThreadingPatternNotSupportedException (com.axway.ats.agent.core.threading.exceptions.ThreadingPatternNotSupportedException)2 QueueLoaderListener (com.axway.ats.agent.core.threading.listeners.QueueLoaderListener)1 AllAtOncePattern (com.axway.ats.agent.core.threading.patterns.AllAtOncePattern)1 FixedDurationAllAtOncePattern (com.axway.ats.agent.core.threading.patterns.FixedDurationAllAtOncePattern)1 FixedDurationRampUpPattern (com.axway.ats.agent.core.threading.patterns.FixedDurationRampUpPattern)1 RampUpPattern (com.axway.ats.agent.core.threading.patterns.RampUpPattern)1 FixedDurationExecutionPattern (com.axway.ats.agent.core.threading.patterns.model.FixedDurationExecutionPattern)1 FixedInvocationsExecutionPattern (com.axway.ats.agent.core.threading.patterns.model.FixedInvocationsExecutionPattern)1