public class TaskSlot extends Object
Task
belonging to the same slot. A TaskSlot
can be in one
of the following states:
A task slot can only be allocated if it is in state free. An allocated task slot can transition to state active.
An active slot allows to add tasks from the respective job and with the correct allocation id. An active slot can be marked as inactive which sets the state back to allocated.
An allocated or active slot can only be freed if it is empty. If it is not empty, then it's state can be set to releasing indicating that it can be freed once it becomes empty.
Modifier and Type | Method and Description |
---|---|
boolean |
add(Task task)
Add the given task to the task slot.
|
boolean |
allocate(JobID newJobId,
AllocationID newAllocationId)
Allocate the task slot for the given job and allocation id.
|
void |
clear()
Removes all tasks from this task slot.
|
SlotOffer |
generateSlotOffer()
Generate the slot offer from this TaskSlot.
|
AllocationID |
getAllocationId() |
int |
getIndex() |
JobID |
getJobId() |
ResourceProfile |
getResourceProfile() |
Iterator<Task> |
getTasks()
Get all tasks running in this task slot.
|
boolean |
isActive(JobID activeJobId,
AllocationID activeAllocationId) |
boolean |
isAllocated(JobID jobIdToCheck,
AllocationID allocationIDToCheck) |
boolean |
isEmpty() |
boolean |
isFree() |
boolean |
isReleasing() |
boolean |
markActive()
Mark this slot as active.
|
boolean |
markFree()
Mark the slot as free.
|
boolean |
markInactive()
Mark the slot as inactive/allocated.
|
boolean |
markReleasing()
Mark this slot as releasing.
|
Task |
remove(ExecutionAttemptID executionAttemptId)
Remove the task identified by the given execution attempt id.
|
String |
toString() |
public int getIndex()
public ResourceProfile getResourceProfile()
public JobID getJobId()
public AllocationID getAllocationId()
public boolean isEmpty()
public boolean isFree()
public boolean isActive(JobID activeJobId, AllocationID activeAllocationId)
public boolean isAllocated(JobID jobIdToCheck, AllocationID allocationIDToCheck)
public boolean isReleasing()
public Iterator<Task> getTasks()
public boolean add(Task task)
IllegalStateException
is thrown.
In case that the task's job id and allocation id don't match with the job id and allocation
id for which the task slot has been allocated, an IllegalArgumentException
is thrown.task
- to be added to the task slotIllegalStateException
- if the task slot is not in state activepublic Task remove(ExecutionAttemptID executionAttemptId)
executionAttemptId
- identifying the task to be removedpublic void clear()
public boolean allocate(JobID newJobId, AllocationID newAllocationId)
newJobId
- to allocate the slot fornewAllocationId
- to identify the slot allocationpublic boolean markActive()
public boolean markInactive()
public boolean markFree()
public boolean markReleasing()
public SlotOffer generateSlotOffer()
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.