Interface WorkerWorkload<T>

Type Parameters:
T - caller specific context data
All Known Subinterfaces:
Worker<T>

public interface WorkerWorkload<T>
Interface for running a workload (@link{io.narayana.perf.Measurement#measure})
  • Method Summary

    Modifier and Type
    Method
    Description
    doWork(T context, int batchSize, Measurement<T> measurement)
    Perform a batch of work units.
    void
    finishWork(Measurement<T> measurement)
    Notify the worker that the @link{doWork} method will not be called again on the current thread (but it may still be called from other threads).
  • Method Details

    • doWork

      T doWork(T context, int batchSize, Measurement<T> measurement)
      Perform a batch of work units. @see Measurement#measure begins a number of threads and each thread then invokes the doWork method in parallel until there is no more remaining work. If work throws an exception then whole test is cancelled and exception is reported via the (@link{Measurement.exception}) property
      Parameters:
      context - a thread specific instance that may have been returned by a previous invocation of the doWork method by this thread. This may be useful if the worker needs to save thread specific data for use by later invocations on the same thread
      batchSize - the number of work iterations to perform in this batch
      measurement - config parameters for the work that triggered this call
      Returns:
      A thread specific instance that will be passed to subsequent calls to the doWork method by the thread
    • finishWork

      void finishWork(Measurement<T> measurement)
      Notify the worker that the @link{doWork} method will not be called again on the current thread (but it may still be called from other threads).
      Parameters:
      measurement - config parameters for the work that triggered this call - each worker thread gets its own copy of the config. NB: Any context object associated with the last call to the @link{doWork} call is available by calling @link{measurement.getContext} on this parameter.