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 Modifier and Type Method Description Optional<PhysicalSlot>allocateAvailableSlot(AllocationID allocationID, PhysicalSlotRequest physicalSlotRequest)Allocates the available slot with the given physical slot request.voidclose()voidconnectToResourceManager(ResourceManagerGateway resourceManagerGateway)Connects the SlotPool to the given ResourceManager.AllocatedSlotReportcreateAllocatedSlotReport(ResourceID taskManagerId)Create report about the allocated slots belonging to the specified task manager.voiddisableBatchSlotRequestTimeoutCheck()Disables batch slot request timeout check.voiddisconnectResourceManager()Disconnects the slot pool from its current Resource Manager.Collection<SlotInfo>getAllocatedSlotsInformation()Returns a list ofSlotInfoobjects about all slots that are currently allocated in the slot pool.FreeSlotTrackergetFreeSlotTracker()Returns all free slot tracker.Collection<SlotOffer>offerSlots(TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, Collection<SlotOffer> offers)Offers multiple slots to theSlotPool.booleanregisterTaskManager(ResourceID resourceID)Registers a TaskExecutor with the givenResourceIDatSlotPool.booleanreleaseTaskManager(ResourceID resourceId, Exception cause)Releases a TaskExecutor with the givenResourceIDfrom theSlotPool.CompletableFuture<PhysicalSlot>requestNewAllocatedBatchSlot(PhysicalSlotRequest physicalSlotRequest)Requests the allocation of a new batch slot from the resource manager.CompletableFuture<PhysicalSlot>requestNewAllocatedSlot(PhysicalSlotRequest physicalSlotRequest, Duration timeout)Request the allocation of a new slot from the resource manager.voidsetIsJobRestarting(boolean isJobRestarting)Sets whether the underlying job is currently restarting or not.voidstart(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:
closein 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 givenResourceIDatSlotPool.- 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 givenResourceIDfrom 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 ofSlotInfoobjects about all slots that are currently allocated in the slot pool.- Returns:
- a list of
SlotInfoobjects about all slots that are currently allocated in the slot pool.
-
allocateAvailableSlot
Optional<PhysicalSlot> allocateAvailableSlot(AllocationID allocationID, PhysicalSlotRequest physicalSlotRequest)
Allocates the available slot with the given physical slot request. The slot must be able to fulfill the requirement profile, otherwise anIllegalStateExceptionwill be thrown.- Parameters:
allocationID- the allocation id of the requested available slotphysicalSlotRequest- the physical slot request.- Returns:
- the previously available slot with the given allocation id, if a slot with this allocation id exists
-
requestNewAllocatedSlot
CompletableFuture<PhysicalSlot> requestNewAllocatedSlot(PhysicalSlotRequest physicalSlotRequest, @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:
physicalSlotRequest- the physical slot request descriptor.timeout- timeout for the allocation procedure- Returns:
- a newly allocated slot that was previously not available.
-
requestNewAllocatedBatchSlot
CompletableFuture<PhysicalSlot> requestNewAllocatedBatchSlot(PhysicalSlotRequest physicalSlotRequest)
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:
physicalSlotRequest- the physical slot request descriptor.- Returns:
- a future which is completed with newly allocated batch slot
-
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
-
-