Interface WorkloadScheduler
- All Superinterfaces:
AutoCloseable
Implementations must be thread-safe. The baseline API intentionally does not require durable storage, consensus, distributed transactions, or exactly-once execution. Authorization, resource policy, overload, and audit behavior are implementation responsibilities.
-
Method Summary
Modifier and TypeMethodDescriptionacquireLease(TaskId taskId, LeaseOwner owner, Duration duration) Acquires task ownership under a new fencing generation.voidRequests cancellation.checkpoint(TaskId taskId, LeaseOwner owner, FencingToken token, Map<String, String> metadata) Records explicit recoverable task metadata under current lease authority.voidclose()voidcomplete(TaskId taskId, LeaseOwner owner, FencingToken token, Object result) Publishes the task result under current lease authority and selects terminal completion.voidfail(TaskId taskId, LeaseOwner owner, FencingToken token, TaskFailure failure) Fails a task.fanOut(FanOutRequest request, CandidateInvoker invoker) Invokes a function over fan-out candidates.Lists local task status snapshots.voidreleaseLease(TaskId taskId, LeaseOwner owner, FencingToken token) Releases a live lease.renewLease(TaskId taskId, LeaseOwner owner, FencingToken token, Duration duration) Extends an existing live lease while retaining its fencing generation.voidreportProgress(TaskId taskId, LeaseOwner owner, FencingToken token, TaskProgress progress) Reports task progress.scatterGather(ScatterGatherRequest request, CandidateInvoker invoker) Invokes a function over scatter-gather candidates.Returns the scheduler id.Returns current task status.<T> StreamHandle<T> stream(TaskSubmission submission, StreamProducer<T> producer) Starts a bounded server-style stream.submit(TaskSubmission submission) Submits a task.submitAsync(TaskSubmission submission, WorkloadExecutor executor) Executes a task asynchronously.submitOneWay(TaskSubmission submission, WorkloadExecutor executor) Enqueues a one-way task and returns after local acceptance.
-
Method Details
-
schedulerId
-
submit
Submits a task.- Parameters:
submission- submission request- Returns:
- task handle
-
acquireLease
Acquires task ownership under a new fencing generation.A live lease held by another owner can prevent acquisition. A granted lease identifies the owner and expiry; it does not itself fence an external database or establish durable recovery. Those guarantees belong to the implementation.
- Parameters:
taskId- task idowner- lease ownerduration- requested lease lifetime; null selects the implementation default- Returns:
- new lease
-
renewLease
Extends an existing live lease while retaining its fencing generation.The owner and token must match current authority. Renewal must not revive an expired or superseded owner; obtain fresh authority after ownership loss.
- Parameters:
taskId- task idowner- lease ownertoken- fencing token supplied by ownerduration- renewed lifetime measured from renewal; null selects the implementation default- Returns:
- renewed lease
-
releaseLease
Releases a live lease.- Parameters:
taskId- task idowner- lease ownertoken- fencing token
-
reportProgress
Reports task progress.- Parameters:
taskId- task idowner- lease ownertoken- fencing tokenprogress- progress snapshot
-
checkpoint
TaskCheckpoint checkpoint(TaskId taskId, LeaseOwner owner, FencingToken token, Map<String, String> metadata) Records explicit recoverable task metadata under current lease authority.This is an application safe point, not a serialized Java stack. The implementation determines storage durability, retention, metadata limits and redaction. A stale owner must not replace the current checkpoint.
- Parameters:
taskId- task idowner- lease ownertoken- fencing tokenmetadata- checkpoint metadata- Returns:
- checkpoint snapshot
-
complete
Publishes the task result under current lease authority and selects terminal completion.Result size/type limits belong to the scheduler profile. Completion is not atomic with unrelated external effects. A cancelled or timed-out caller does not establish that physical work has stopped or that this result was absent.
- Parameters:
taskId- task idowner- lease ownertoken- fencing tokenresult- result value
-
fail
Fails a task.- Parameters:
taskId- task idowner- lease ownertoken- fencing tokenfailure- failure descriptor
-
cancel
-
status
Returns current task status.- Parameters:
taskId- task id- Returns:
- status snapshot
-
listTasks
-
submitAsync
Executes a task asynchronously.- Parameters:
submission- submission requestexecutor- executor- Returns:
- future-like result
-
submitOneWay
Enqueues a one-way task and returns after local acceptance.- Parameters:
submission- submission requestexecutor- executor- Returns:
- task reference
-
stream
Starts a bounded server-style stream.- Type Parameters:
T- item type- Parameters:
submission- submission requestproducer- producer callback- Returns:
- stream handle
-
fanOut
Invokes a function over fan-out candidates.- Parameters:
request- requestinvoker- per-candidate invoker- Returns:
- fan-out result
-
scatterGather
Invokes a function over scatter-gather candidates.- Parameters:
request- requestinvoker- per-candidate invoker- Returns:
- scatter-gather result
-
close
void close()- Specified by:
closein interfaceAutoCloseable
-