Package at.jku.dke.etutor.task_app.test
Class SubmissionThread
java.lang.Object
java.lang.Thread
at.jku.dke.etutor.task_app.test.SubmissionThread
- All Implemented Interfaces:
Runnable
A thread that simulates a user submitting a request to the task app.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final String
The API key to use for the requests.protected static final org.slf4j.Logger
The logger.protected final Random
The random generator.static final String
The statistic type for asynchronous submissions.static final String
The statistic type for synchronous submissions.protected final String
The URL of the task app.Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SubmissionThread
(String name, String url, String apiKey, int initialSleep, int totalAmountOfRequests, int pauseBetweenRequestsInMs) Creates a new instance of the load test thread. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract String
buildAdditionalDataJson
(int iteration, long taskId) Builds the type-specific submission data JSON for the submit request.protected String
buildSubmissionRequestBody
(int iteration) Builds the request body for the submit request.Returns the list of request statistics.protected abstract long
getTaskId
(int iteration) Returns the task ID for the given iteration.void
Prints the statistics of the thread.void
run()
Submits requests to the task app.protected RequestStatistic
submitAsyncRequest
(int iteration) Submits an asynchronous request to the task app.protected RequestStatistic
submitSyncRequest
(int iteration) Submits a synchronous request to the task app.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
STATISTIC_SYNC
The statistic type for synchronous submissions.- See Also:
-
STATISTIC_ASYNC
The statistic type for asynchronous submissions.- See Also:
-
LOG
protected static final org.slf4j.Logger LOGThe logger. -
url
The URL of the task app. -
apiKey
The API key to use for the requests. -
random
The random generator.
-
-
Constructor Details
-
SubmissionThread
protected SubmissionThread(String name, String url, String apiKey, int initialSleep, int totalAmountOfRequests, int pauseBetweenRequestsInMs) Creates a new instance of the load test thread.- Parameters:
name
- The name of the thread. This is used for logging.url
- The URL of the task app. This should not contain a trailing slash.apiKey
- The API key to use for the requests.initialSleep
- The initial sleep time in milliseconds.totalAmountOfRequests
- The total amount of requests to submit.pauseBetweenRequestsInMs
- The pause between requests in milliseconds.
-
-
Method Details
-
run
public void run()Submits requests to the task app. -
getStatisticList
Returns the list of request statistics.- Returns:
- The list of request statistics.
-
printStatistics
public void printStatistics()Prints the statistics of the thread. -
buildSubmissionRequestBody
Builds the request body for the submit request.- Parameters:
iteration
- The iteration number.- Returns:
- The request body.
-
buildAdditionalDataJson
Builds the type-specific submission data JSON for the submit request.- Parameters:
iteration
- The iteration number.taskId
- The task identifier.- Returns:
- The additional data JSON.
-
getTaskId
protected abstract long getTaskId(int iteration) Returns the task ID for the given iteration.- Parameters:
iteration
- The iteration number.- Returns:
- The task ID.
-
submitSyncRequest
Submits a synchronous request to the task app.- Parameters:
iteration
- The iteration number.- Returns:
- The request statistic.
-
submitAsyncRequest
Submits an asynchronous request to the task app.- Parameters:
iteration
- The iteration number.- Returns:
- The request statistic.
-