public class DeclarativeSlotPoolBridge extends DeclarativeSlotPoolService implements SlotPool
SlotPool
implementation which uses the DeclarativeSlotPool
to allocate slots.log
Constructor and Description |
---|
DeclarativeSlotPoolBridge(JobID jobId,
DeclarativeSlotPoolFactory declarativeSlotPoolFactory,
Clock clock,
Time rpcTimeout,
Time idleSlotTimeout,
Time batchSlotTimeout,
RequestSlotMatchingStrategy requestSlotMatchingStrategy) |
Modifier and Type | Method and 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.
|
void |
disableBatchSlotRequestTimeoutCheck()
Disables batch slot request timeout check.
|
Collection<SlotInfo> |
getAllocatedSlotsInformation()
Returns a list of
SlotInfo objects about all slots that are currently allocated in
the slot pool. |
FreeSlotInfoTracker |
getFreeSlotInfoTracker()
Returns all free slot tracker.
|
int |
getNumPendingRequests() |
void |
notifyNotEnoughResourcesAvailable(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 the
SlotPoolService . |
protected void |
onClose()
This method is called when the slot pool service is closed.
|
protected void |
onFailAllocation(ResourceCounter previouslyFulfilledRequirements)
This method is called when an allocation fails.
|
protected void |
onReleaseTaskManager(ResourceCounter previouslyFulfilledRequirement)
This method is called when a TaskManager is released.
|
protected void |
onStart(ComponentMainThreadExecutor componentMainThreadExecutor)
This method is called when the slot pool service is started.
|
void |
releaseSlot(SlotRequestId slotRequestId,
Throwable cause)
Releases the slot with the given
SlotRequestId . |
CompletableFuture<PhysicalSlot> |
requestNewAllocatedBatchSlot(SlotRequestId slotRequestId,
ResourceProfile resourceProfile,
Collection<AllocationID> preferredAllocations) |
CompletableFuture<PhysicalSlot> |
requestNewAllocatedSlot(SlotRequestId slotRequestId,
ResourceProfile resourceProfile,
Collection<AllocationID> preferredAllocations,
Time timeout)
Request the allocation of a new slot from the resource manager.
|
void |
setIsJobRestarting(boolean isJobRestarting)
To set whether the underlying is currently restarting or not.
|
assertHasBeenStarted, close, connectToResourceManager, createAllocatedSlotReport, disconnectResourceManager, failAllocation, getDeclarativeSlotPool, getRelativeTimeMillis, getSlotServiceStatus, registerTaskManager, releaseFreeSlotsOnTaskManager, releaseTaskManager, start
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, connectToResourceManager, createAllocatedSlotReport, disconnectResourceManager, registerTaskManager, releaseTaskManager, requestNewAllocatedBatchSlot, requestNewAllocatedSlot, start
public DeclarativeSlotPoolBridge(JobID jobId, DeclarativeSlotPoolFactory declarativeSlotPoolFactory, Clock clock, Time rpcTimeout, Time idleSlotTimeout, Time batchSlotTimeout, RequestSlotMatchingStrategy requestSlotMatchingStrategy)
public <T> Optional<T> castInto(Class<T> clazz)
SlotPoolService
castInto
in interface SlotPoolService
castInto
in class DeclarativeSlotPoolService
T
- type of clazzclazz
- to cast the slot pool service intoOptional.of(T)
the target type if it can be cast; otherwise Optional.empty()
protected void onStart(ComponentMainThreadExecutor componentMainThreadExecutor)
DeclarativeSlotPoolService
onStart
in class DeclarativeSlotPoolService
componentMainThreadExecutor
- componentMainThreadExecutor used by this slot pool serviceprotected void onClose()
DeclarativeSlotPoolService
onClose
in class DeclarativeSlotPoolService
public void setIsJobRestarting(boolean isJobRestarting)
setIsJobRestarting
in interface SlotPool
isJobRestarting
- whether this is restarting or notpublic Collection<SlotOffer> offerSlots(TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, Collection<SlotOffer> offers)
SlotPoolService
SlotPoolService
. The slot offerings can be individually
accepted or rejected by returning the collection of accepted slot offers.offerSlots
in interface SlotPool
offerSlots
in interface SlotPoolService
offerSlots
in class DeclarativeSlotPoolService
taskManagerLocation
- from which the slot offers originatetaskManagerGateway
- to talk to the slot offereroffers
- slot offers which are offered to the SlotPoolService
protected void onReleaseTaskManager(ResourceCounter previouslyFulfilledRequirement)
DeclarativeSlotPoolService
onReleaseTaskManager
in class DeclarativeSlotPoolService
previouslyFulfilledRequirement
- previouslyFulfilledRequirement by the released
TaskManagerpublic Optional<PhysicalSlot> allocateAvailableSlot(@Nonnull SlotRequestId slotRequestId, @Nonnull AllocationID allocationID, @Nonnull ResourceProfile requirementProfile)
SlotPool
IllegalStateException
will be thrown.allocateAvailableSlot
in interface SlotPool
slotRequestId
- identifying the requested slotallocationID
- the allocation id of the requested available slotrequirementProfile
- resource profile of the requirement for which to allocate the slot@Nonnull public CompletableFuture<PhysicalSlot> requestNewAllocatedSlot(@Nonnull SlotRequestId slotRequestId, @Nonnull ResourceProfile resourceProfile, @Nonnull Collection<AllocationID> preferredAllocations, @Nullable Time timeout)
SlotPool
requestNewAllocatedSlot
in interface SlotPool
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@Nonnull public CompletableFuture<PhysicalSlot> requestNewAllocatedBatchSlot(@Nonnull SlotRequestId slotRequestId, @Nonnull ResourceProfile resourceProfile, @Nonnull Collection<AllocationID> preferredAllocations)
requestNewAllocatedBatchSlot
in interface SlotPool
protected void onFailAllocation(ResourceCounter previouslyFulfilledRequirements)
DeclarativeSlotPoolService
onFailAllocation
in class DeclarativeSlotPoolService
previouslyFulfilledRequirements
- previouslyFulfilledRequirements by the failed
allocationpublic void releaseSlot(@Nonnull SlotRequestId slotRequestId, @Nullable Throwable cause)
AllocatedSlotActions
SlotRequestId
. Additionally, one can provide a cause
for the slot release.releaseSlot
in interface AllocatedSlotActions
slotRequestId
- identifying the slot to releasecause
- of the slot release, null if nonepublic void notifyNotEnoughResourcesAvailable(Collection<ResourceRequirement> acquiredResources)
SlotPoolService
notifyNotEnoughResourcesAvailable
in interface SlotPoolService
acquiredResources
- the resources that have been acquiredpublic Collection<SlotInfo> getAllocatedSlotsInformation()
SlotPool
SlotInfo
objects about all slots that are currently allocated in
the slot pool.getAllocatedSlotsInformation
in interface SlotPool
SlotInfo
objects about all slots that are currently allocated in
the slot pool.public FreeSlotInfoTracker getFreeSlotInfoTracker()
SlotPool
getFreeSlotInfoTracker
in interface SlotPool
public void disableBatchSlotRequestTimeoutCheck()
SlotPool
disableBatchSlotRequestTimeoutCheck
in interface SlotPool
@VisibleForTesting public int getNumPendingRequests()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.