Class JobChunkScope
java.lang.Object
com.kingsrook.qqq.backend.core.jobs.plans.JobChunkScope
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordWhich job chunk this scope runs: the parts of an effect's idempotency key, and the process whose effect declarations apply.static interfaceThe chunk's cooperative check (pause, cancel, drain, lost lease), run between pages; it throws JobInterruptedException to stop the chunk.static final recordOne failed row. -
Method Summary
Modifier and TypeMethodDescriptionvoidBuffer an outbox effect row; the same idempotency key twice keeps one.static voidBetween pages: run the chunk's cooperative check, if a job chunk with one is running on this thread (no-op otherwise).voidclose()Restore whatever scope was open before.static Optional<JobChunkScope> current()The scope open on this thread, if any.Take the buffered effects (the buffer is emptied: a STEPS job writes them at each step boundary).Getter for identity (null for a scope that is not a job chunk).Getter for progressThe rows reported so far.static JobChunkScopeopen(QBackendTransaction transaction) Open a scope on this thread (close it when the chunk ends).static JobChunkScopeopen(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.static JobChunkScopeopen(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.static Optional<QBackendTransaction> The transaction a durable chunk provides on this thread, if any.static voidreportRecordErrors(QRecord record, List<Integer> fileRowNumbers, Serializable recordPk) Report each error on a record that failed (no-op outside a job).static voidreportRowError(JobChunkScope.RowError rowError) Report a failed row (no-op outside a job).voidsetProgress(JobProgress progress) Setter for progresswithProgress(JobProgress progress) Fluent setter for progress
-
Method Details
-
open
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
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
The scope open on this thread, if any. -
providedTransaction
The transaction a durable chunk provides on this thread, if any. -
reportRowError
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
The rows reported so far. -
close
public void close()Restore whatever scope was open before.- Specified by:
closein interfaceAutoCloseable
-
getIdentity
Getter for identity (null for a scope that is not a job chunk). -
addEffect
Buffer an outbox effect row; the same idempotency key twice keeps one. -
drainEffects
-
getProgress
Getter for progress -
setProgress
Setter for progress -
withProgress
Fluent setter for progress
-