Interface SlotPool
-
- All Superinterfaces:
AllocatedSlotActions
,AutoCloseable
- All Known Implementing Classes:
DeclarativeSlotPoolBridge
public interface SlotPool extends AllocatedSlotActions, AutoCloseable
The Interface of a slot pool that manages slots.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Optional<PhysicalSlot>
allocateAvailableSlot(SlotRequestId slotRequestId, AllocationID allocationID, ResourceProfile requirementProfile)
Allocates the available slot with the given allocation id under the given request id for the given requirement profile.void
close()
void
connectToResourceManager(ResourceManagerGateway resourceManagerGateway)
Connects the SlotPool to the given ResourceManager.AllocatedSlotReport
createAllocatedSlotReport(ResourceID taskManagerId)
Create report about the allocated slots belonging to the specified task manager.void
disableBatchSlotRequestTimeoutCheck()
Disables batch slot request timeout check.void
disconnectResourceManager()
Disconnects the slot pool from its current Resource Manager.Collection<SlotInfo>
getAllocatedSlotsInformation()
Returns a list ofSlotInfo
objects about all slots that are currently allocated in the slot pool.FreeSlotTracker
getFreeSlotTracker()
Returns all free slot tracker.Collection<SlotOffer>
offerSlots(TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, Collection<SlotOffer> offers)
Offers multiple slots to theSlotPool
.boolean
registerTaskManager(ResourceID resourceID)
Registers a TaskExecutor with the givenResourceID
atSlotPool
.boolean
releaseTaskManager(ResourceID resourceId, Exception cause)
Releases a TaskExecutor with the givenResourceID
from theSlotPool
.default CompletableFuture<PhysicalSlot>
requestNewAllocatedBatchSlot(SlotRequestId slotRequestId, ResourceProfile resourceProfile)
Requests the allocation of a new batch slot from the resource manager.CompletableFuture<PhysicalSlot>
requestNewAllocatedBatchSlot(SlotRequestId slotRequestId, ResourceProfile resourceProfile, Collection<AllocationID> preferredAllocations)
default CompletableFuture<PhysicalSlot>
requestNewAllocatedSlot(SlotRequestId slotRequestId, ResourceProfile resourceProfile, Duration timeout)
Request the allocation of a new slot from the resource manager.CompletableFuture<PhysicalSlot>
requestNewAllocatedSlot(SlotRequestId slotRequestId, ResourceProfile resourceProfile, Collection<AllocationID> preferredAllocations, Duration timeout)
Request the allocation of a new slot from the resource manager.void
setIsJobRestarting(boolean isJobRestarting)
Sets whether the underlying job is currently restarting or not.void
start(JobMasterId jobMasterId, String newJobManagerAddress)
-
Methods inherited from interface org.apache.flink.runtime.jobmaster.slotpool.AllocatedSlotActions
releaseSlot
-
-
-
-
Method Detail
-
start
void start(JobMasterId jobMasterId, String newJobManagerAddress) throws Exception
- Throws:
Exception
-
close
void close()
- Specified by:
close
in interfaceAutoCloseable
-
connectToResourceManager
void connectToResourceManager(ResourceManagerGateway resourceManagerGateway)
Connects the SlotPool to the given ResourceManager. After this method is called, the SlotPool will be able to request resources from the given ResourceManager.- Parameters:
resourceManagerGateway
- The RPC gateway for the resource manager.
-
disconnectResourceManager
void disconnectResourceManager()
Disconnects the slot pool from its current Resource Manager. After this call, the pool will not be able to request further slots from the Resource Manager, and all currently pending requests to the resource manager will be canceled.The slot pool will still be able to serve slots from its internal pool.
-
registerTaskManager
boolean registerTaskManager(ResourceID resourceID)
Registers a TaskExecutor with the givenResourceID
atSlotPool
.- Parameters:
resourceID
- identifying the TaskExecutor to register- Returns:
- true iff a new resource id was registered
-
releaseTaskManager
boolean releaseTaskManager(ResourceID resourceId, Exception cause)
Releases a TaskExecutor with the givenResourceID
from theSlotPool
.- Parameters:
resourceId
- identifying the TaskExecutor which shall be released from the SlotPoolcause
- for the releasing of the TaskManager- Returns:
- true iff a given registered resource id was removed
-
offerSlots
Collection<SlotOffer> offerSlots(TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, Collection<SlotOffer> offers)
Offers multiple slots to theSlotPool
. The slot offerings can be individually accepted or rejected by returning the collection of accepted slot offers.- Parameters:
taskManagerLocation
- from which the slot offers originatetaskManagerGateway
- to talk to the slot offereroffers
- slot offers which are offered to theSlotPool
- Returns:
- A collection of accepted slot offers. The remaining slot offers are implicitly rejected.
-
getFreeSlotTracker
FreeSlotTracker getFreeSlotTracker()
Returns all free slot tracker.- Returns:
- all free slot tracker
-
getAllocatedSlotsInformation
Collection<SlotInfo> getAllocatedSlotsInformation()
Returns a list ofSlotInfo
objects about all slots that are currently allocated in the slot pool.- Returns:
- a list of
SlotInfo
objects about all slots that are currently allocated in the slot pool.
-
allocateAvailableSlot
Optional<PhysicalSlot> allocateAvailableSlot(SlotRequestId slotRequestId, AllocationID allocationID, ResourceProfile requirementProfile)
Allocates the available slot with the given allocation id under the given request id for the given requirement profile. The slot must be able to fulfill the requirement profile, otherwise anIllegalStateException
will be thrown.- Parameters:
slotRequestId
- identifying the requested slotallocationID
- the allocation id of the requested available slotrequirementProfile
- resource profile of the requirement for which to allocate the slot- Returns:
- the previously available slot with the given allocation id, if a slot with this allocation id exists
-
requestNewAllocatedSlot
default CompletableFuture<PhysicalSlot> requestNewAllocatedSlot(SlotRequestId slotRequestId, ResourceProfile resourceProfile, @Nullable Duration timeout)
Request the allocation of a new slot from the resource manager. This method will not return a slot from the already available slots from the pool, but instead will add a new slot to that pool that is immediately allocated and returned.- Parameters:
slotRequestId
- identifying the requested slotresourceProfile
- resource profile that specifies the resource requirements for the requested slottimeout
- timeout for the allocation procedure- Returns:
- a newly allocated slot that was previously not available.
-
requestNewAllocatedSlot
CompletableFuture<PhysicalSlot> requestNewAllocatedSlot(SlotRequestId slotRequestId, ResourceProfile resourceProfile, Collection<AllocationID> preferredAllocations, @Nullable Duration timeout)
Request the allocation of a new slot from the resource manager. This method will not return a slot from the already available slots from the pool, but instead will add a new slot to that pool that is immediately allocated and returned.- Parameters:
slotRequestId
- identifying the requested slotresourceProfile
- resource profile that specifies the resource requirements for the requested slotpreferredAllocations
- preferred allocations for the new allocated slottimeout
- timeout for the allocation procedure- Returns:
- a newly allocated slot that was previously not available.
-
requestNewAllocatedBatchSlot
default CompletableFuture<PhysicalSlot> requestNewAllocatedBatchSlot(SlotRequestId slotRequestId, ResourceProfile resourceProfile)
Requests the allocation of a new batch slot from the resource manager. Unlike the normal slot, a batch slot will only time out if the slot pool does not contain a suitable slot. Moreover, it won't react to failure signals from the resource manager.- Parameters:
slotRequestId
- identifying the requested slotresourceProfile
- resource profile that specifies the resource requirements for the requested batch slot- Returns:
- a future which is completed with newly allocated batch slot
-
requestNewAllocatedBatchSlot
CompletableFuture<PhysicalSlot> requestNewAllocatedBatchSlot(SlotRequestId slotRequestId, ResourceProfile resourceProfile, Collection<AllocationID> preferredAllocations)
-
disableBatchSlotRequestTimeoutCheck
void disableBatchSlotRequestTimeoutCheck()
Disables batch slot request timeout check. Invoked when someone else wants to take over the timeout check responsibility.
-
createAllocatedSlotReport
AllocatedSlotReport createAllocatedSlotReport(ResourceID taskManagerId)
Create report about the allocated slots belonging to the specified task manager.- Parameters:
taskManagerId
- identifies the task manager- Returns:
- the allocated slots on the task manager
-
setIsJobRestarting
void setIsJobRestarting(boolean isJobRestarting)
Sets whether the underlying job is currently restarting or not.- Parameters:
isJobRestarting
- whether the job is restarting or not
-
-