Class Worker

java.lang.Object
io.sbk.api.Worker
Direct Known Subclasses:
SbkCallbackReader, SbkReader, SbkWriter

public abstract class Worker extends Object
Abstract class for Writers and Readers.

This small immutable holder provides per-worker context that is shared with driver implementations for both readers and writers. It centralises three commonly used pieces of information:

  • id - the worker identifier (0-based) used for request logging and per-worker statistics.
  • params - the parsed benchmark parameters that control run behaviour (counts, rates, sizes, etc.).
  • perlChannel - optional PerL channel used to emit timing and throughput events to the metrics/collector subsystem.

Implementation notes and guidelines:

  • The fields are intentionally final to make the Worker instance immutable after construction; driver code may safely read these values concurrently without additional synchronization.
  • Do not add driver-specific mutable state to this class; instead keep per-worker state inside the driver implementation to avoid accidental sharing between workers.
  • Construct Worker instances using the worker id assigned by the harness (writers/readers are created by SbkBenchmark).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
    Worker identifier assigned by the benchmark harness.
    Benchmark parameters shared with this worker.
    final io.perl.api.PerlChannel
    Performance channel used to publish measurements.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Worker(int workerID, Parameters params, io.perl.api.PerlChannel perlChannel)
    Creates a benchmark worker.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Identifies an I/O failure caused solely by active benchmark shutdown.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • id

      public final int id
      Worker identifier assigned by the benchmark harness.
    • params

      public final Parameters params
      Benchmark parameters shared with this worker.
    • perlChannel

      public final io.perl.api.PerlChannel perlChannel
      Performance channel used to publish measurements.
  • Constructor Details

    • Worker

      public Worker(int workerID, Parameters params, io.perl.api.PerlChannel perlChannel)
      Creates a benchmark worker.
      Parameters:
      workerID - worker identifier
      params - benchmark parameters
      perlChannel - performance channel
  • Method Details

    • isShutdownInterruption

      public static boolean isShutdownInterruption(Throwable failure)
      Identifies an I/O failure caused solely by active benchmark shutdown.

      This is invoked only from worker exception handling. A socket timeout remains a benchmark failure even though the JDK models it as an InterruptedIOException.

      Parameters:
      failure - worker failure
      Returns:
      true when interruption or executor rejection caused the failure