public interface TaskSlotTable<T extends TaskSlotPayload> extends TimeoutListener<AllocationID>, AutoCloseableAsync
TaskSlot
instances. Additionally, it maintains multiple indices
for faster access to tasks and sets of allocated slots.
The task slot table automatically registers timeouts for allocated slots which cannot be assigned to a job manager.
Before the task slot table can be used, it must be started via the start(org.apache.flink.runtime.taskexecutor.slot.SlotActions, org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor)
method.
Modifier and Type | Method and Description |
---|---|
boolean |
addTask(T task)
Add the given task to the slot identified by the task's allocation id.
|
boolean |
allocateSlot(int index,
JobID jobId,
AllocationID allocationId,
java.time.Duration slotTimeout)
Allocate the slot with the given index for the given job and allocation id.
|
boolean |
allocateSlot(int index,
JobID jobId,
AllocationID allocationId,
ResourceProfile resourceProfile,
java.time.Duration slotTimeout)
Allocate the slot with the given index for the given job and allocation id.
|
SlotReport |
createSlotReport(ResourceID resourceId) |
default int |
freeSlot(AllocationID allocationId)
Try to free the slot.
|
int |
freeSlot(AllocationID allocationId,
Throwable cause)
Tries to free the slot.
|
Set<AllocationID> |
getActiveTaskSlotAllocationIds()
Returns the
AllocationID of any active task listed in this TaskSlotTable . |
Set<AllocationID> |
getActiveTaskSlotAllocationIdsPerJob(JobID jobId)
|
Iterator<TaskSlot<T>> |
getAllocatedSlots(JobID jobId)
Return an iterator of allocated slots for the given job id.
|
Set<AllocationID> |
getAllocationIdsPerJob(JobID jobId)
Returns the all
AllocationID for the given job. |
AllocationID |
getCurrentAllocation(int index)
Get the current allocation for the task slot with the given index.
|
JobID |
getOwningJob(AllocationID allocationId)
Returns the owning job of the
TaskSlot identified by the given AllocationID . |
T |
getTask(ExecutionAttemptID executionAttemptID)
Get the task for the given execution attempt id.
|
MemoryManager |
getTaskMemoryManager(AllocationID allocationID)
Get the memory manager of the slot allocated for the task.
|
Iterator<T> |
getTasks(JobID jobId)
Return an iterator over all tasks for a given job.
|
boolean |
hasAllocatedSlots(JobID jobId)
Check whether the job has allocated (not active) slots.
|
boolean |
isAllocated(int index,
JobID jobId,
AllocationID allocationId)
Check whether the slot for the given index is allocated for the given job and allocation id.
|
boolean |
isSlotFree(int index)
Check whether the task slot with the given index is free.
|
boolean |
isValidTimeout(AllocationID allocationId,
UUID ticket)
Check whether the timeout with ticket is valid for the given allocation id.
|
boolean |
markSlotActive(AllocationID allocationId)
Marks the slot under the given allocation id as active.
|
boolean |
markSlotInactive(AllocationID allocationId,
java.time.Duration slotTimeout)
Marks the slot under the given allocation id as inactive.
|
T |
removeTask(ExecutionAttemptID executionAttemptID)
Remove the task with the given execution attempt id from its task slot.
|
void |
start(SlotActions initialSlotActions,
ComponentMainThreadExecutor mainThreadExecutor)
Start the task slot table with the given slot actions.
|
boolean |
tryMarkSlotActive(JobID jobId,
AllocationID allocationId)
Try to mark the specified slot as active if it has been allocated by the given job.
|
notifyTimeout
close, closeAsync
void start(SlotActions initialSlotActions, ComponentMainThreadExecutor mainThreadExecutor)
initialSlotActions
- to use for slot actionsmainThreadExecutor
- ComponentMainThreadExecutor
to schedule internal calls to
the main threadSet<AllocationID> getAllocationIdsPerJob(JobID jobId)
AllocationID
for the given job.jobId
- for which to return the set of AllocationID
.AllocationID
for the given jobSet<AllocationID> getActiveTaskSlotAllocationIds()
AllocationID
of any active task listed in this TaskSlotTable
.AllocationID
of any active task.Set<AllocationID> getActiveTaskSlotAllocationIdsPerJob(JobID jobId)
jobId
- The JobID
of the job for which the AllocationID
s of the attached
active TaskSlot
s shall be returned.AllocationID
s that belong to active TaskSlot
s having the
passed JobID
.SlotReport createSlotReport(ResourceID resourceId)
@VisibleForTesting boolean allocateSlot(int index, JobID jobId, AllocationID allocationId, java.time.Duration slotTimeout)
index
- of the task slot to allocate, use negative value for dynamic slot allocationjobId
- to allocate the task slot forallocationId
- identifying the allocationslotTimeout
- until the slot times outboolean allocateSlot(int index, JobID jobId, AllocationID allocationId, ResourceProfile resourceProfile, java.time.Duration slotTimeout)
index
- of the task slot to allocate, use negative value for dynamic slot allocationjobId
- to allocate the task slot forallocationId
- identifying the allocationresourceProfile
- of the requested slot, used only for dynamic slot allocation and will
be ignored otherwiseslotTimeout
- until the slot times outboolean markSlotActive(AllocationID allocationId) throws SlotNotFoundException
SlotNotFoundException
is thrown.allocationId
- to identify the task slot to mark as activeSlotNotFoundException
- if the slot could not be found for the given allocation idboolean markSlotInactive(AllocationID allocationId, java.time.Duration slotTimeout) throws SlotNotFoundException
SlotNotFoundException
is thrown.allocationId
- to identify the task slot to mark as inactiveslotTimeout
- until the slot times outSlotNotFoundException
- if the slot could not be found for the given allocation iddefault int freeSlot(AllocationID allocationId) throws SlotNotFoundException
allocationId
- identifying the task slot to be freedSlotNotFoundException
- if there is not task slot for the given allocation idint freeSlot(AllocationID allocationId, Throwable cause) throws SlotNotFoundException
allocationId
- identifying the task slot to be freedcause
- to fail the tasks with if slot is not emptySlotNotFoundException
- if there is not task slot for the given allocation idboolean isValidTimeout(AllocationID allocationId, UUID ticket)
allocationId
- to check againstticket
- of the timeoutboolean isAllocated(int index, JobID jobId, AllocationID allocationId)
index
- of the task slotjobId
- for which the task slot should be allocatedallocationId
- which should match the task slot's allocation idboolean tryMarkSlotActive(JobID jobId, AllocationID allocationId)
jobId
- of the allocated slotallocationId
- identifying the allocationboolean isSlotFree(int index)
index
- of the task slotboolean hasAllocatedSlots(JobID jobId)
jobId
- for which to check for allocated slotsIterator<TaskSlot<T>> getAllocatedSlots(JobID jobId)
jobId
- for which to return the allocated slots@Nullable JobID getOwningJob(AllocationID allocationId)
TaskSlot
identified by the given AllocationID
.allocationId
- identifying the slot for which to retrieve the owning jobTaskSlot
or null if there is no slot for the
given allocation id or if the slot has no owning job assignedboolean addTask(T task) throws SlotNotFoundException, SlotNotActiveException
task
- to add to the task slot with the respective allocation idSlotNotFoundException
- if there was no slot for the given allocation idSlotNotActiveException
- if there was no slot active for task's job and allocation idT removeTask(ExecutionAttemptID executionAttemptID)
executionAttemptID
- identifying the task to removeT getTask(ExecutionAttemptID executionAttemptID)
executionAttemptID
- identifying the requested taskIterator<T> getTasks(JobID jobId)
jobId
- identifying the job of the requested tasksAllocationID getCurrentAllocation(int index)
index
- identifying the slot for which the allocation id shall be retrievedMemoryManager getTaskMemoryManager(AllocationID allocationID) throws SlotNotFoundException
allocationID
- allocation id of the slot allocated for the taskSlotNotFoundException
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.