use of com.axway.ats.agent.core.threading.patterns.model.FixedDurationExecutionPattern 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());
}
}
Aggregations