Class ChunkContext
java.lang.Object
com.kingsrook.qqq.backend.core.jobs.plans.ChunkContext
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 Summary
ConstructorsConstructorDescriptionChunkContext(QRecord job, QRecord chunk, JobLease lease, DurableJobStore store, BooleanSupplier draining) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidcheck()The cooperative check: throw JobInterruptedException when the chunk should stop here.voidcheckpoint(String checkpointJson) Save a checkpoint (fenced by the lease).voidcompleteInTransaction(ChunkOutcome outcome, List<QRecord> rowErrors, QBackendTransaction transaction) 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).voidcompleteInTransaction(ChunkOutcome outcome, List<QRecord> rowErrors, List<QRecord> effects, QBackendTransaction transaction) 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).getChunk()Getter for chunkgetJob()Getter for jobgetLease()Getter for leaseOne progress reporter per lease attempt.getStore()Getter for storeidentity()This chunk's identity for effect keys.booleanWhether the plan already marked the chunk DONE (in its transaction).booleanWhether the heartbeat found the lease gone.voidMark the lease lost (from the heartbeat thread).voidrecordEffects(List<QRecord> effects) Write outbox effects outside a transaction (keys already written are skipped, so a rerun never doubles them).
-
Constructor Details
-
ChunkContext
public ChunkContext(QRecord job, QRecord chunk, JobLease lease, DurableJobStore store, BooleanSupplier draining) Constructor
-
-
Method Details
-
checkpoint
Save a checkpoint (fenced by the lease). A lost lease stops the chunk.- Throws:
QException
-
check
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
Write outbox effects outside a transaction (keys already written are skipped, so a rerun never doubles them).- Throws:
QException
-
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
Getter for job -
getChunk
Getter for chunk -
getLease
Getter for lease -
getStore
Getter for store -
getProgress
One progress reporter per lease attempt.
-