Class DeclarativeSlotPoolService
java.lang.Object
org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolService
- All Implemented Interfaces:
AutoCloseable,SlotPoolService
- Direct Known Subclasses:
DeclarativeSlotPoolBridge
SlotPoolService implementation for the DeclarativeSlotPool.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorprotected final org.slf4j.Logger -
Constructor Summary
ConstructorsConstructorDescriptionDeclarativeSlotPoolService(org.apache.flink.api.common.JobID jobId, DeclarativeSlotPoolFactory declarativeSlotPoolFactory, org.apache.flink.util.clock.Clock clock, Duration idleSlotTimeout, Duration rpcTimeout, Duration slotRequestMaxInterval, org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor componentMainThreadExecutor) -
Method Summary
Modifier and TypeMethodDescriptionprotected void<T> Optional<T>Tries to cast this slot pool service into the given clazz.final voidclose()Close the slot pool service.voidconnectToResourceManager(ResourceManagerGateway resourceManagerGateway) Connects the SlotPool to the given ResourceManager.createAllocatedSlotReport(ResourceID taskManagerId) Create report about the allocated slots belonging to the specified task manager.voidDisconnects the slot pool from its current Resource Manager.failAllocation(ResourceID taskManagerId, AllocationID allocationId, Exception cause) Fails the allocation with the given allocationId.protected DeclarativeSlotPoolprotected longprotected StringofferSlots(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.booleanregisterTaskManager(ResourceID taskManagerId) Registers a TaskExecutor with the givenResourceIDatSlotPoolService.voidreleaseFreeSlotsOnTaskManager(ResourceID taskManagerId, Exception cause) Releases all free slots belonging to the owning TaskExecutor if it has been registered.booleanreleaseTaskManager(ResourceID taskManagerId, Exception cause) Releases a TaskExecutor with the givenResourceIDfrom theSlotPoolService.final voidstart(JobMasterId jobMasterId, String address) Start the encapsulated slot pool implementation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.flink.runtime.jobmaster.slotpool.SlotPoolService
notifyNotEnoughResourcesAvailable
-
Field Details
-
log
protected final org.slf4j.Logger log -
componentMainThreadExecutor
protected final org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor componentMainThreadExecutor
-
-
Constructor Details
-
DeclarativeSlotPoolService
public DeclarativeSlotPoolService(org.apache.flink.api.common.JobID jobId, DeclarativeSlotPoolFactory declarativeSlotPoolFactory, org.apache.flink.util.clock.Clock clock, Duration idleSlotTimeout, Duration rpcTimeout, Duration slotRequestMaxInterval, @Nonnull org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor componentMainThreadExecutor)
-
-
Method Details
-
getDeclarativeSlotPool
-
getRelativeTimeMillis
protected long getRelativeTimeMillis() -
castInto
Description copied from interface:SlotPoolServiceTries to cast this slot pool service into the given clazz.- Specified by:
castIntoin interfaceSlotPoolService- 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()
-
start
Description copied from interface:SlotPoolServiceStart the encapsulated slot pool implementation.- Specified by:
startin interfaceSlotPoolService- Parameters:
jobMasterId- jobMasterId to start the service withaddress- address of the owner- Throws:
Exception- if the service cannot be started
-
onStart
protected void onStart()This method is called when the slot pool service is started. It can be overridden by subclasses. -
assertHasBeenStarted
protected void assertHasBeenStarted() -
close
public final void close()Description copied from interface:SlotPoolServiceClose the slot pool service.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSlotPoolService
-
onClose
protected void onClose()This method is called when the slot pool service is closed. It can be overridden by subclasses. -
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 interfaceSlotPoolService- 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.
-
failAllocation
public Optional<ResourceID> failAllocation(@Nullable ResourceID taskManagerId, AllocationID allocationId, Exception cause) Description copied from interface:SlotPoolServiceFails the allocation with the given allocationId.- Specified by:
failAllocationin interfaceSlotPoolService- Parameters:
taskManagerId- taskManagerId is non-null if the signal comes from a TaskManager; if the signal comes from the ResourceManager, then it is nullallocationId- allocationId identifies which allocation to failcause- cause why the allocation failed- Returns:
- Optional task executor if it has no more slots registered
-
onFailAllocation
This method is called when an allocation fails. It can be overridden by subclasses.- Parameters:
previouslyFulfilledRequirements- previouslyFulfilledRequirements by the failed allocation
-
registerTaskManager
Description copied from interface:SlotPoolServiceRegisters a TaskExecutor with the givenResourceIDatSlotPoolService.- Specified by:
registerTaskManagerin interfaceSlotPoolService- Parameters:
taskManagerId- identifying the TaskExecutor to register- Returns:
- true iff a new resource id was registered
-
releaseTaskManager
Description copied from interface:SlotPoolServiceReleases a TaskExecutor with the givenResourceIDfrom theSlotPoolService.- Specified by:
releaseTaskManagerin interfaceSlotPoolService- Parameters:
taskManagerId- 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
-
releaseFreeSlotsOnTaskManager
Description copied from interface:SlotPoolServiceReleases all free slots belonging to the owning TaskExecutor if it has been registered.- Specified by:
releaseFreeSlotsOnTaskManagerin interfaceSlotPoolService- Parameters:
taskManagerId- identifying the TaskExecutorcause- cause for failing the slots
-
onReleaseTaskManager
This method is called when a TaskManager is released. It can be overridden by subclasses.- Parameters:
previouslyFulfilledRequirement- previouslyFulfilledRequirement by the released TaskManager
-
connectToResourceManager
Description copied from interface:SlotPoolServiceConnects the SlotPool to the given ResourceManager. After this method is called, the SlotPool will be able to request resources from the given ResourceManager.- Specified by:
connectToResourceManagerin interfaceSlotPoolService- Parameters:
resourceManagerGateway- The RPC gateway for the resource manager.
-
disconnectResourceManager
public void disconnectResourceManager()Description copied from interface:SlotPoolServiceDisconnects 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.
- Specified by:
disconnectResourceManagerin interfaceSlotPoolService
-
createAllocatedSlotReport
Description copied from interface:SlotPoolServiceCreate report about the allocated slots belonging to the specified task manager.- Specified by:
createAllocatedSlotReportin interfaceSlotPoolService- Parameters:
taskManagerId- identifies the task manager- Returns:
- the allocated slots on the task manager
-
getSlotServiceStatus
-