Class TaskSlotTableImpl<T extends TaskSlotPayload>

    • Method Detail

      • allocateSlot

        @VisibleForTesting
        public boolean allocateSlot​(int index,
                                    JobID jobId,
                                    AllocationID allocationId,
                                    Duration slotTimeout)
        Description copied from interface: TaskSlotTable
        Allocate the slot with the given index for the given job and allocation id. If negative index is given, a new auto increasing index will be generated. Returns true if the slot could be allocated. Otherwise it returns false.
        Specified by:
        allocateSlot in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        index - of the task slot to allocate, use negative value for dynamic slot allocation
        jobId - to allocate the task slot for
        allocationId - identifying the allocation
        slotTimeout - until the slot times out
        Returns:
        True if the task slot could be allocated; otherwise false
      • allocateSlot

        public boolean allocateSlot​(int requestedIndex,
                                    JobID jobId,
                                    AllocationID allocationId,
                                    ResourceProfile resourceProfile,
                                    Duration slotTimeout)
        Description copied from interface: TaskSlotTable
        Allocate the slot with the given index for the given job and allocation id. If negative index is given, a new auto increasing index will be generated. Returns true if the slot could be allocated. Otherwise it returns false.
        Specified by:
        allocateSlot in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        requestedIndex - of the task slot to allocate, use negative value for dynamic slot allocation
        jobId - to allocate the task slot for
        allocationId - identifying the allocation
        resourceProfile - of the requested slot, used only for dynamic slot allocation and will be ignored otherwise
        slotTimeout - until the slot times out
        Returns:
        True if the task slot could be allocated; otherwise false
      • freeSlot

        public int freeSlot​(AllocationID allocationId,
                            Throwable cause)
                     throws SlotNotFoundException
        Description copied from interface: TaskSlotTable
        Tries to free the slot. If the slot is empty it will set the state of the task slot to free and return its index. If the slot is not empty, then it will set the state of the task slot to releasing, fail all tasks and return -1.
        Specified by:
        freeSlot in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        allocationId - identifying the task slot to be freed
        cause - to fail the tasks with if slot is not empty
        Returns:
        Index of the freed slot if the slot could be freed; otherwise -1
        Throws:
        SlotNotFoundException - if there is not task slot for the given allocation id
      • isValidTimeout

        public boolean isValidTimeout​(AllocationID allocationId,
                                      UUID ticket)
        Description copied from interface: TaskSlotTable
        Check whether the timeout with ticket is valid for the given allocation id.
        Specified by:
        isValidTimeout in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        allocationId - to check against
        ticket - of the timeout
        Returns:
        True if the timeout is valid; otherwise false
      • isAllocated

        public boolean isAllocated​(int index,
                                   JobID jobId,
                                   AllocationID allocationId)
        Description copied from interface: TaskSlotTable
        Check whether the slot for the given index is allocated for the given job and allocation id.
        Specified by:
        isAllocated in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        index - of the task slot
        jobId - for which the task slot should be allocated
        allocationId - which should match the task slot's allocation id
        Returns:
        True if the given task slot is allocated for the given job and allocation id
      • tryMarkSlotActive

        public boolean tryMarkSlotActive​(JobID jobId,
                                         AllocationID allocationId)
        Description copied from interface: TaskSlotTable
        Try to mark the specified slot as active if it has been allocated by the given job.
        Specified by:
        tryMarkSlotActive in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        jobId - of the allocated slot
        allocationId - identifying the allocation
        Returns:
        True if the task slot could be marked active.
      • isSlotFree

        public boolean isSlotFree​(int index)
        Description copied from interface: TaskSlotTable
        Check whether the task slot with the given index is free.
        Specified by:
        isSlotFree in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        index - of the task slot
        Returns:
        True if the task slot is free; otherwise false
      • hasAllocatedSlots

        public boolean hasAllocatedSlots​(JobID jobId)
        Description copied from interface: TaskSlotTable
        Check whether the job has allocated (not active) slots.
        Specified by:
        hasAllocatedSlots in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        jobId - for which to check for allocated slots
        Returns:
        True if there are allocated slots for the given job id.
      • getOwningJob

        @Nullable
        public JobID getOwningJob​(AllocationID allocationId)
        Description copied from interface: TaskSlotTable
        Returns the owning job of the TaskSlot identified by the given AllocationID.
        Specified by:
        getOwningJob in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        allocationId - identifying the slot for which to retrieve the owning job
        Returns:
        Owning job of the specified TaskSlot or null if there is no slot for the given allocation id or if the slot has no owning job assigned
      • removeTask

        public T removeTask​(ExecutionAttemptID executionAttemptID)
        Description copied from interface: TaskSlotTable
        Remove the task with the given execution attempt id from its task slot. If the owning task slot is in state releasing and empty after removing the task, the slot is freed via the slot actions.
        Specified by:
        removeTask in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        executionAttemptID - identifying the task to remove
        Returns:
        The removed task if there is any for the given execution attempt id; otherwise null
      • getTask

        public T getTask​(ExecutionAttemptID executionAttemptID)
        Description copied from interface: TaskSlotTable
        Get the task for the given execution attempt id. If none could be found, then return null.
        Specified by:
        getTask in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        executionAttemptID - identifying the requested task
        Returns:
        The task for the given execution attempt id if it exist; otherwise null
      • getTasks

        public Iterator<T> getTasks​(JobID jobId)
        Description copied from interface: TaskSlotTable
        Return an iterator over all tasks for a given job.
        Specified by:
        getTasks in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        jobId - identifying the job of the requested tasks
        Returns:
        Iterator over all task for a given job
      • getCurrentAllocation

        public AllocationID getCurrentAllocation​(int index)
        Description copied from interface: TaskSlotTable
        Get the current allocation for the task slot with the given index.
        Specified by:
        getCurrentAllocation in interface TaskSlotTable<T extends TaskSlotPayload>
        Parameters:
        index - identifying the slot for which the allocation id shall be retrieved
        Returns:
        Allocation id of the specified slot if allocated; otherwise null
      • notifyTimeout

        public void notifyTimeout​(AllocationID key,
                                  UUID ticket)
        Description copied from interface: TimeoutListener
        Notify the listener about the timeout for an event identified by key. Additionally the method is called with the timeout ticket which allows to identify outdated timeout events.
        Specified by:
        notifyTimeout in interface TimeoutListener<T extends TaskSlotPayload>
        Parameters:
        key - identifying the timed out event
        ticket - used to check whether the timeout is still valid