Class ChunkContext

java.lang.Object
com.kingsrook.qqq.backend.core.jobs.plans.ChunkContext

public class ChunkContext extends Object
What a running chunk can see and do: its job and chunk rows, its lease, the fenced checkpoint write, and the cooperative check (pause, cancel, drain, lost lease) that plans call at safe points - between pages or steps.
  • Constructor Details

  • Method Details

    • checkpoint

      public void checkpoint(String checkpointJson) throws QException
      Save a checkpoint (fenced by the lease). A lost lease stops the chunk.
      Throws:
      QException
    • check

      public void check() throws QException
      The cooperative check: throw JobInterruptedException when the chunk should stop here. Reads the job status at most every 2 seconds.
      Throws:
      QException
    • completeInTransaction

      public void completeInTransaction(ChunkOutcome outcome, List<QRecord> rowErrors, QBackendTransaction transaction) throws QException
      Mark the chunk DONE inside the plan's own transaction (SAME_TRANSACTION: the chunk's writes and its DONE mark commit together, fenced by the lease). Records the row errors in the same transaction first.
      Throws:
      QException
    • completeInTransaction

      public void completeInTransaction(ChunkOutcome outcome, List<QRecord> rowErrors, List<QRecord> effects, QBackendTransaction transaction) throws QException
      Mark the chunk DONE in the plan's transaction, with its row errors and its outbox effects: the chunk's writes, its effects and its DONE mark commit together (spec section 2.13).
      Throws:
      QException
    • recordEffects

      public void recordEffects(List<QRecord> effects) throws QException
      Write outbox effects outside a transaction (keys already written are skipped, so a rerun never doubles them).
      Throws:
      QException
    • identity

      public JobChunkScope.ChunkIdentity identity()
      This chunk's identity for effect keys.
    • isCompletedByPlan

      public boolean isCompletedByPlan()
      Whether the plan already marked the chunk DONE (in its transaction).
    • markLeaseLost

      public void markLeaseLost()
      Mark the lease lost (from the heartbeat thread).
    • isLeaseLost

      public boolean isLeaseLost()
      Whether the heartbeat found the lease gone.
    • getJob

      public QRecord getJob()
      Getter for job
    • getChunk

      public QRecord getChunk()
      Getter for chunk
    • getLease

      public JobLease getLease()
      Getter for lease
    • getStore

      public DurableJobStore getStore()
      Getter for store
    • getProgress

      public JobProgress getProgress()
      One progress reporter per lease attempt.