public class TaskSlotTable extends Object implements TimeoutListener<AllocationID>
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)
method.
Constructor and Description |
---|
TaskSlotTable(Collection<ResourceProfile> resourceProfiles,
TimerService<AllocationID> timerService) |
Modifier and Type | Method and Description |
---|---|
boolean |
addTask(Task task)
Add the given task to the slot identified by the task's allocation id.
|
boolean |
allocateSlot(int index,
JobID jobId,
AllocationID allocationId,
Time slotTimeout)
Allocate the slot with the given index for the given job and allocation id.
|
SlotReport |
createSlotReport(ResourceID resourceId) |
int |
freeSlot(AllocationID allocationId)
Try to free the slot.
|
int |
freeSlot(AllocationID allocationId,
Throwable cause)
Tries to free the slot.
|
Iterator<AllocationID> |
getActiveSlots(JobID jobId)
Return an iterator of active slots (their application ids) for the given job id.
|
Iterator<TaskSlot> |
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 . |
Task |
getTask(ExecutionAttemptID executionAttemptID)
Get the task for the given execution attempt id.
|
Iterator<Task> |
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,
Time slotTimeout)
Marks the slot under the given allocation id as inactive.
|
void |
notifyTimeout(AllocationID key,
UUID ticket)
Notify the listener about the timeout for an event identified by key.
|
Task |
removeTask(ExecutionAttemptID executionAttemptID)
Remove the task with the given execution attempt id from its task slot.
|
void |
start(SlotActions initialSlotActions)
Start the task slot table with the given slot actions and slot timeout value.
|
void |
stop()
Stop the task slot table.
|
boolean |
tryMarkSlotActive(JobID jobId,
AllocationID allocationId)
Try to mark the specified slot as active if it has been allocated by the given job.
|
public TaskSlotTable(Collection<ResourceProfile> resourceProfiles, TimerService<AllocationID> timerService)
public void start(SlotActions initialSlotActions)
initialSlotActions
- to use for slot actionspublic void stop()
public Set<AllocationID> getAllocationIdsPerJob(JobID jobId)
AllocationID
for the given job.jobId
- for which to return the set of AllocationID
.AllocationID
for the given jobpublic SlotReport createSlotReport(ResourceID resourceId)
public boolean allocateSlot(int index, JobID jobId, AllocationID allocationId, Time slotTimeout)
index
- of the task slot to allocatejobId
- to allocate the task slot forallocationId
- identifying the allocationslotTimeout
- until the slot times outpublic boolean 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 idpublic boolean markSlotInactive(AllocationID allocationId, Time 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 idpublic int freeSlot(AllocationID allocationId) throws SlotNotFoundException
allocationId
- identifying the task slot to be freedSlotNotFoundException
- if there is not task slot for the given allocation idpublic int 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 idpublic boolean isValidTimeout(AllocationID allocationId, UUID ticket)
allocationId
- to check againstticket
- of the timeoutpublic boolean 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 idpublic boolean tryMarkSlotActive(JobID jobId, AllocationID allocationId)
jobId
- of the allocated slotallocationId
- identifying the allocationpublic boolean isSlotFree(int index)
index
- of the task slotpublic boolean hasAllocatedSlots(JobID jobId)
jobId
- for which to check for allocated slotspublic Iterator<TaskSlot> getAllocatedSlots(JobID jobId)
jobId
- for which to return the allocated slotspublic Iterator<AllocationID> getActiveSlots(JobID jobId)
jobId
- for which to return the active slots@Nullable public 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 assignedpublic boolean addTask(Task 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 idpublic Task removeTask(ExecutionAttemptID executionAttemptID)
executionAttemptID
- identifying the task to removepublic Task getTask(ExecutionAttemptID executionAttemptID)
executionAttemptID
- identifying the requested taskpublic Iterator<Task> getTasks(JobID jobId)
jobId
- identifying the job of the requested taskspublic AllocationID getCurrentAllocation(int index)
index
- identifying the slot for which the allocation id shall be retrievedpublic void notifyTimeout(AllocationID key, UUID ticket)
TimeoutListener
notifyTimeout
in interface TimeoutListener<AllocationID>
key
- identifying the timed out eventticket
- used to check whether the timeout is still validCopyright © 2014–2020 The Apache Software Foundation. All rights reserved.