Class DeclarativeSlotPoolBridge
- java.lang.Object
-
- org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolService
-
- org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolBridge
-
- All Implemented Interfaces:
AutoCloseable,AllocatedSlotActions,SlotPool,SlotPoolService
public class DeclarativeSlotPoolBridge extends DeclarativeSlotPoolService implements SlotPool
SlotPoolimplementation which uses theDeclarativeSlotPoolto allocate slots.
-
-
Field Summary
-
Fields inherited from class org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolService
componentMainThreadExecutor, log
-
-
Constructor Summary
Constructors Constructor Description DeclarativeSlotPoolBridge(org.apache.flink.api.common.JobID jobId, DeclarativeSlotPoolFactory declarativeSlotPoolFactory, org.apache.flink.util.clock.Clock clock, Duration rpcTimeout, Duration idleSlotTimeout, Duration batchSlotTimeout, RequestSlotMatchingStrategy requestSlotMatchingStrategy, Duration slotRequestMaxInterval, boolean slotBatchAllocatable, org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor componentMainThreadExecutor)
-
Method Summary
All Methods Instance Methods Concrete 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.<T> Optional<T>castInto(Class<T> clazz)Tries to cast this slot pool service into the given clazz.voiddisableBatchSlotRequestTimeoutCheck()Disables batch slot request timeout check.Collection<SlotInfo>getAllocatedSlotsInformation()Returns a list ofSlotInfoobjects about all slots that are currently allocated in the slot pool.FreeSlotTrackergetFreeSlotTracker()Returns all free slot tracker.intgetNumPendingRequests()voidnotifyNotEnoughResourcesAvailable(Collection<ResourceRequirement> acquiredResources)Notifies that not enough resources are available to fulfill the resource requirements.Collection<SlotOffer>offerSlots(TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, Collection<SlotOffer> offers)Offers multiple slots to theSlotPoolService.protected voidonClose()This method is called when the slot pool service is closed.protected voidonFailAllocation(ResourceCounter previouslyFulfilledRequirements)This method is called when an allocation fails.protected voidonReleaseTaskManager(ResourceCounter previouslyFulfilledRequirement)This method is called when a TaskManager is released.protected voidonStart()This method is called when the slot pool service is started.voidreleaseSlot(SlotRequestId slotRequestId, Throwable cause)Releases the slot with the givenSlotRequestId.CompletableFuture<PhysicalSlot>requestNewAllocatedBatchSlot(SlotRequestId slotRequestId, ResourceProfile resourceProfile, Collection<AllocationID> preferredAllocations)CompletableFuture<PhysicalSlot>requestNewAllocatedSlot(SlotRequestId slotRequestId, ResourceProfile resourceProfile, Collection<AllocationID> preferredAllocations, Duration timeout)Request the allocation of a new slot from the resource manager.voidsetIsJobRestarting(boolean isJobRestarting)To set whether the underlying is currently restarting or not.-
Methods inherited from class org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolService
assertHasBeenStarted, close, connectToResourceManager, createAllocatedSlotReport, disconnectResourceManager, failAllocation, getDeclarativeSlotPool, getRelativeTimeMillis, getSlotServiceStatus, registerTaskManager, releaseFreeSlotsOnTaskManager, releaseTaskManager, start
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.runtime.jobmaster.slotpool.SlotPool
close, connectToResourceManager, createAllocatedSlotReport, disconnectResourceManager, registerTaskManager, releaseTaskManager, requestNewAllocatedBatchSlot, requestNewAllocatedSlot, start
-
-
-
-
Constructor Detail
-
DeclarativeSlotPoolBridge
public DeclarativeSlotPoolBridge(org.apache.flink.api.common.JobID jobId, DeclarativeSlotPoolFactory declarativeSlotPoolFactory, org.apache.flink.util.clock.Clock clock, Duration rpcTimeout, Duration idleSlotTimeout, Duration batchSlotTimeout, RequestSlotMatchingStrategy requestSlotMatchingStrategy, Duration slotRequestMaxInterval, boolean slotBatchAllocatable, @Nonnull org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor componentMainThreadExecutor)
-
-
Method Detail
-
castInto
public <T> Optional<T> castInto(Class<T> clazz)
Description copied from interface:SlotPoolServiceTries to cast this slot pool service into the given clazz.- Specified by:
castIntoin interfaceSlotPoolService- Overrides:
castIntoin classDeclarativeSlotPoolService- Type Parameters:
T- type of clazz- Parameters:
clazz- to cast the slot pool service into- Returns:
Optional.of(T)the target type if it can be cast; otherwiseOptional.empty()
-
onStart
protected void onStart()
Description copied from class:DeclarativeSlotPoolServiceThis method is called when the slot pool service is started. It can be overridden by subclasses.- Overrides:
onStartin classDeclarativeSlotPoolService
-
onClose
protected void onClose()
Description copied from class:DeclarativeSlotPoolServiceThis method is called when the slot pool service is closed. It can be overridden by subclasses.- Overrides:
onClosein classDeclarativeSlotPoolService
-
setIsJobRestarting
public void setIsJobRestarting(boolean isJobRestarting)
To set whether the underlying is currently restarting or not. In the former case the slot pool bridge will accept all incoming slot offers.- Specified by:
setIsJobRestartingin interfaceSlotPool- Parameters:
isJobRestarting- whether this is restarting or not
-
offerSlots
public Collection<SlotOffer> offerSlots(TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, Collection<SlotOffer> offers)
Description copied from interface:SlotPoolServiceOffers multiple slots to theSlotPoolService. The slot offerings can be individually accepted or rejected by returning the collection of accepted slot offers.- Specified by:
offerSlotsin interfaceSlotPool- Specified by:
offerSlotsin interfaceSlotPoolService- Overrides:
offerSlotsin classDeclarativeSlotPoolService- Parameters:
taskManagerLocation- from which the slot offers originatetaskManagerGateway- to talk to the slot offereroffers- slot offers which are offered to theSlotPoolService- Returns:
- A collection of accepted slot offers. The remaining slot offers are implicitly rejected.
-
onReleaseTaskManager
protected void onReleaseTaskManager(ResourceCounter previouslyFulfilledRequirement)
Description copied from class:DeclarativeSlotPoolServiceThis method is called when a TaskManager is released. It can be overridden by subclasses.- Overrides:
onReleaseTaskManagerin classDeclarativeSlotPoolService- Parameters:
previouslyFulfilledRequirement- previouslyFulfilledRequirement by the released TaskManager
-
allocateAvailableSlot
public Optional<PhysicalSlot> allocateAvailableSlot(@Nonnull SlotRequestId slotRequestId, @Nonnull AllocationID allocationID, @Nonnull ResourceProfile requirementProfile)
Description copied from interface:SlotPoolAllocates 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 anIllegalStateExceptionwill be thrown.- Specified by:
allocateAvailableSlotin interfaceSlotPool- 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
@Nonnull public CompletableFuture<PhysicalSlot> requestNewAllocatedSlot(@Nonnull SlotRequestId slotRequestId, @Nonnull ResourceProfile resourceProfile, @Nonnull Collection<AllocationID> preferredAllocations, @Nullable Duration timeout)
Description copied from interface:SlotPoolRequest 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.- Specified by:
requestNewAllocatedSlotin interfaceSlotPool- 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
@Nonnull public CompletableFuture<PhysicalSlot> requestNewAllocatedBatchSlot(@Nonnull SlotRequestId slotRequestId, @Nonnull ResourceProfile resourceProfile, @Nonnull Collection<AllocationID> preferredAllocations)
- Specified by:
requestNewAllocatedBatchSlotin interfaceSlotPool
-
onFailAllocation
protected void onFailAllocation(ResourceCounter previouslyFulfilledRequirements)
Description copied from class:DeclarativeSlotPoolServiceThis method is called when an allocation fails. It can be overridden by subclasses.- Overrides:
onFailAllocationin classDeclarativeSlotPoolService- Parameters:
previouslyFulfilledRequirements- previouslyFulfilledRequirements by the failed allocation
-
releaseSlot
public void releaseSlot(@Nonnull SlotRequestId slotRequestId, @Nullable Throwable cause)Description copied from interface:AllocatedSlotActionsReleases the slot with the givenSlotRequestId. Additionally, one can provide a cause for the slot release.- Specified by:
releaseSlotin interfaceAllocatedSlotActions- Parameters:
slotRequestId- identifying the slot to releasecause- of the slot release, null if none
-
notifyNotEnoughResourcesAvailable
public void notifyNotEnoughResourcesAvailable(Collection<ResourceRequirement> acquiredResources)
Description copied from interface:SlotPoolServiceNotifies that not enough resources are available to fulfill the resource requirements.- Specified by:
notifyNotEnoughResourcesAvailablein interfaceSlotPoolService- Parameters:
acquiredResources- the resources that have been acquired
-
getAllocatedSlotsInformation
public Collection<SlotInfo> getAllocatedSlotsInformation()
Description copied from interface:SlotPoolReturns a list ofSlotInfoobjects about all slots that are currently allocated in the slot pool.- Specified by:
getAllocatedSlotsInformationin interfaceSlotPool- Returns:
- a list of
SlotInfoobjects about all slots that are currently allocated in the slot pool.
-
getFreeSlotTracker
public FreeSlotTracker getFreeSlotTracker()
Description copied from interface:SlotPoolReturns all free slot tracker.- Specified by:
getFreeSlotTrackerin interfaceSlotPool- Returns:
- all free slot tracker
-
disableBatchSlotRequestTimeoutCheck
public void disableBatchSlotRequestTimeoutCheck()
Description copied from interface:SlotPoolDisables batch slot request timeout check. Invoked when someone else wants to take over the timeout check responsibility.- Specified by:
disableBatchSlotRequestTimeoutCheckin interfaceSlotPool
-
getNumPendingRequests
@VisibleForTesting public int getNumPendingRequests()
-
-