Class JobChunkScope

java.lang.Object
com.kingsrook.qqq.backend.core.jobs.plans.JobChunkScope
All Implemented Interfaces:
AutoCloseable

public final class JobChunkScope extends Object implements AutoCloseable
What a durable job chunk hands to the process steps it runs, on the thread that runs them: - a provided transaction: StreamedETLExecuteStep loads into it instead of opening (and committing) its own, so the chunk's rows and its DONE mark commit together (SAME_TRANSACTION: exactly once); - a row-error sink: transform and load steps report each failed row (file row number or record key, field, code, message) so the job can record them in jobs_row_error. Outside a job (no scope open) everything behaves as before.
  • Method Details

    • open

      public static JobChunkScope open(QBackendTransaction transaction)
      Open a scope on this thread (close it when the chunk ends).
    • open

      public static JobChunkScope open(QBackendTransaction transaction, JobChunkScope.PageCheck pageCheck)
      Open a scope on this thread with a cooperative check that page-wise steps (such as the streamed ETL execute step) run between pages.
    • open

      public static JobChunkScope open(QBackendTransaction transaction, JobChunkScope.PageCheck pageCheck, JobChunkScope.ChunkIdentity identity)
      Open a scope for an identified job chunk: side effects emitted in it (JobEffects.emit) are buffered here and written to the outbox with the chunk's progress.
    • checkBetweenPages

      public static void checkBetweenPages() throws QException
      Between pages: run the chunk's cooperative check, if a job chunk with one is running on this thread (no-op otherwise). Pause and cancel then stop a chunk at the next page instead of at its end.
      Throws:
      QException
    • current

      public static Optional<JobChunkScope> current()
      The scope open on this thread, if any.
    • providedTransaction

      public static Optional<QBackendTransaction> providedTransaction()
      The transaction a durable chunk provides on this thread, if any.
    • reportRowError

      public static void reportRowError(JobChunkScope.RowError rowError)
      Report a failed row (no-op outside a job).
    • reportRecordErrors

      public static void reportRecordErrors(QRecord record, List<Integer> fileRowNumbers, Serializable recordPk)
      Report each error on a record that failed (no-op outside a job). Rows of a bulk-load file are reported by file row number.
    • getRowErrors

      public List<JobChunkScope.RowError> getRowErrors()
      The rows reported so far.
    • close

      public void close()
      Restore whatever scope was open before.
      Specified by:
      close in interface AutoCloseable
    • getIdentity

      public JobChunkScope.ChunkIdentity getIdentity()
      Getter for identity (null for a scope that is not a job chunk).
    • addEffect

      public void addEffect(QRecord effect)
      Buffer an outbox effect row; the same idempotency key twice keeps one.
    • drainEffects

      public List<QRecord> drainEffects()
      Take the buffered effects (the buffer is emptied: a STEPS job writes them at each step boundary).
    • getProgress

      public JobProgress getProgress()
      Getter for progress
    • setProgress

      public void setProgress(JobProgress progress)
      Setter for progress
    • withProgress

      public JobChunkScope withProgress(JobProgress progress)
      Fluent setter for progress