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) |
boolean |
existsActiveSlot(JobID jobId,
AllocationID allocationId)
Check whether there exists an active slot for the given job and allocation id.
|
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.
|
AllocationID |
getCurrentAllocation(int index)
Get the current allocation for the task slot with the given index.
|
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.
|
public TaskSlotTable(Collection<ResourceProfile> resourceProfiles, TimerService<AllocationID> timerService)
public void start(SlotActions initialSlotActions)
initialSlotActions
- to use for slot actionspublic void stop()
public 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 existsActiveSlot(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 slotspublic 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–2018 The Apache Software Foundation. All rights reserved.