public class TaskSlotTableImpl<T extends TaskSlotPayload> extends Object implements TaskSlotTable<T>
TaskSlotTable
.Constructor and Description |
---|
TaskSlotTableImpl(int numberSlots,
ResourceProfile totalAvailableResourceProfile,
ResourceProfile defaultSlotResourceProfile,
int memoryPageSize,
TimerService<AllocationID> timerService,
Executor memoryVerificationExecutor) |
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 requestedIndex,
JobID jobId,
AllocationID allocationId,
ResourceProfile resourceProfile,
java.time.Duration slotTimeout)
Allocate the slot with the given index for the given job and allocation id.
|
CompletableFuture<Void> |
closeAsync()
Trigger the closing of the resource and return the corresponding close future.
|
SlotReport |
createSlotReport(ResourceID resourceId) |
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 |
isClosed() |
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.
|
void |
notifyTimeout(AllocationID key,
UUID ticket)
Notify the listener about the timeout for an event identified by key.
|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
freeSlot
close
public TaskSlotTableImpl(int numberSlots, ResourceProfile totalAvailableResourceProfile, ResourceProfile defaultSlotResourceProfile, int memoryPageSize, TimerService<AllocationID> timerService, Executor memoryVerificationExecutor)
public void start(SlotActions initialSlotActions, ComponentMainThreadExecutor mainThreadExecutor)
TaskSlotTable
start
in interface TaskSlotTable<T extends TaskSlotPayload>
initialSlotActions
- to use for slot actionsmainThreadExecutor
- ComponentMainThreadExecutor
to schedule internal calls to
the main threadpublic CompletableFuture<Void> closeAsync()
AutoCloseableAsync
closeAsync
in interface AutoCloseableAsync
@VisibleForTesting public boolean isClosed()
public Set<AllocationID> getAllocationIdsPerJob(JobID jobId)
TaskSlotTable
AllocationID
for the given job.getAllocationIdsPerJob
in interface TaskSlotTable<T extends TaskSlotPayload>
jobId
- for which to return the set of AllocationID
.AllocationID
for the given jobpublic Set<AllocationID> getActiveTaskSlotAllocationIds()
TaskSlotTable
AllocationID
of any active task listed in this TaskSlotTable
.getActiveTaskSlotAllocationIds
in interface TaskSlotTable<T extends TaskSlotPayload>
AllocationID
of any active task.public Set<AllocationID> getActiveTaskSlotAllocationIdsPerJob(JobID jobId)
TaskSlotTable
getActiveTaskSlotAllocationIdsPerJob
in interface TaskSlotTable<T extends TaskSlotPayload>
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
.public SlotReport createSlotReport(ResourceID resourceId)
createSlotReport
in interface TaskSlotTable<T extends TaskSlotPayload>
@VisibleForTesting public boolean allocateSlot(int index, JobID jobId, AllocationID allocationId, java.time.Duration slotTimeout)
TaskSlotTable
allocateSlot
in interface TaskSlotTable<T extends TaskSlotPayload>
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 outpublic boolean allocateSlot(int requestedIndex, JobID jobId, AllocationID allocationId, ResourceProfile resourceProfile, java.time.Duration slotTimeout)
TaskSlotTable
allocateSlot
in interface TaskSlotTable<T extends TaskSlotPayload>
requestedIndex
- 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 outpublic boolean markSlotActive(AllocationID allocationId) throws SlotNotFoundException
TaskSlotTable
SlotNotFoundException
is thrown.markSlotActive
in interface TaskSlotTable<T extends TaskSlotPayload>
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, java.time.Duration slotTimeout) throws SlotNotFoundException
TaskSlotTable
SlotNotFoundException
is thrown.markSlotInactive
in interface TaskSlotTable<T extends TaskSlotPayload>
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, Throwable cause) throws SlotNotFoundException
TaskSlotTable
freeSlot
in interface TaskSlotTable<T extends TaskSlotPayload>
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)
TaskSlotTable
isValidTimeout
in interface TaskSlotTable<T extends TaskSlotPayload>
allocationId
- to check againstticket
- of the timeoutpublic boolean isAllocated(int index, JobID jobId, AllocationID allocationId)
TaskSlotTable
isAllocated
in interface TaskSlotTable<T extends TaskSlotPayload>
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)
TaskSlotTable
tryMarkSlotActive
in interface TaskSlotTable<T extends TaskSlotPayload>
jobId
- of the allocated slotallocationId
- identifying the allocationpublic boolean isSlotFree(int index)
TaskSlotTable
isSlotFree
in interface TaskSlotTable<T extends TaskSlotPayload>
index
- of the task slotpublic boolean hasAllocatedSlots(JobID jobId)
TaskSlotTable
hasAllocatedSlots
in interface TaskSlotTable<T extends TaskSlotPayload>
jobId
- for which to check for allocated slotspublic Iterator<TaskSlot<T>> getAllocatedSlots(JobID jobId)
TaskSlotTable
getAllocatedSlots
in interface TaskSlotTable<T extends TaskSlotPayload>
jobId
- for which to return the allocated slots@Nullable public JobID getOwningJob(AllocationID allocationId)
TaskSlotTable
TaskSlot
identified by the given AllocationID
.getOwningJob
in interface TaskSlotTable<T extends TaskSlotPayload>
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(T task) throws SlotNotFoundException, SlotNotActiveException
TaskSlotTable
addTask
in interface TaskSlotTable<T extends TaskSlotPayload>
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 T removeTask(ExecutionAttemptID executionAttemptID)
TaskSlotTable
removeTask
in interface TaskSlotTable<T extends TaskSlotPayload>
executionAttemptID
- identifying the task to removepublic T getTask(ExecutionAttemptID executionAttemptID)
TaskSlotTable
getTask
in interface TaskSlotTable<T extends TaskSlotPayload>
executionAttemptID
- identifying the requested taskpublic Iterator<T> getTasks(JobID jobId)
TaskSlotTable
getTasks
in interface TaskSlotTable<T extends TaskSlotPayload>
jobId
- identifying the job of the requested taskspublic AllocationID getCurrentAllocation(int index)
TaskSlotTable
getCurrentAllocation
in interface TaskSlotTable<T extends TaskSlotPayload>
index
- identifying the slot for which the allocation id shall be retrievedpublic MemoryManager getTaskMemoryManager(AllocationID allocationID) throws SlotNotFoundException
TaskSlotTable
getTaskMemoryManager
in interface TaskSlotTable<T extends TaskSlotPayload>
allocationID
- allocation id of the slot allocated for the taskSlotNotFoundException
public 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–2024 The Apache Software Foundation. All rights reserved.