Class SubmissionThread

java.lang.Object
java.lang.Thread
at.jku.dke.etutor.task_app.test.SubmissionThread
All Implemented Interfaces:
Runnable

public abstract class SubmissionThread extends Thread
A thread that simulates a user submitting a request to the task app.
  • Field Details

    • STATISTIC_SYNC

      public static final String STATISTIC_SYNC
      The statistic type for synchronous submissions.
      See Also:
    • STATISTIC_ASYNC

      public static final String STATISTIC_ASYNC
      The statistic type for asynchronous submissions.
      See Also:
    • LOG

      protected static final org.slf4j.Logger LOG
      The logger.
    • url

      protected final String url
      The URL of the task app.
    • apiKey

      protected final String apiKey
      The API key to use for the requests.
    • random

      protected final Random 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.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • getStatisticList

      public List<RequestStatistic> getStatisticList()
      Returns the list of request statistics.
      Returns:
      The list of request statistics.
    • printStatistics

      public void printStatistics()
      Prints the statistics of the thread.
    • buildSubmissionRequestBody

      protected String buildSubmissionRequestBody(int iteration)
      Builds the request body for the submit request.
      Parameters:
      iteration - The iteration number.
      Returns:
      The request body.
    • buildAdditionalDataJson

      protected abstract String buildAdditionalDataJson(int iteration, long taskId)
      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

      protected RequestStatistic submitSyncRequest(int iteration)
      Submits a synchronous request to the task app.
      Parameters:
      iteration - The iteration number.
      Returns:
      The request statistic.
    • submitAsyncRequest

      protected RequestStatistic submitAsyncRequest(int iteration)
      Submits an asynchronous request to the task app.
      Parameters:
      iteration - The iteration number.
      Returns:
      The request statistic.