Class DeclarativeSlotPoolService
- java.lang.Object
-
- org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolService
-
- All Implemented Interfaces:
AutoCloseable
,SlotPoolService
- Direct Known Subclasses:
DeclarativeSlotPoolBridge
public class DeclarativeSlotPoolService extends Object implements SlotPoolService
SlotPoolService
implementation for theDeclarativeSlotPool
.
-
-
Field Summary
Fields Modifier and Type Field Description protected ComponentMainThreadExecutor
componentMainThreadExecutor
protected org.slf4j.Logger
log
-
Constructor Summary
Constructors Constructor Description DeclarativeSlotPoolService(JobID jobId, DeclarativeSlotPoolFactory declarativeSlotPoolFactory, Clock clock, Duration idleSlotTimeout, Duration rpcTimeout, Duration slotRequestMaxInterval, ComponentMainThreadExecutor componentMainThreadExecutor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
assertHasBeenStarted()
<T> Optional<T>
castInto(Class<T> clazz)
Tries to cast this slot pool service into the given clazz.void
close()
Close the slot pool service.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
disconnectResourceManager()
Disconnects the slot pool from its current Resource Manager.Optional<ResourceID>
failAllocation(ResourceID taskManagerId, AllocationID allocationId, Exception cause)
Fails the allocation with the given allocationId.protected DeclarativeSlotPool
getDeclarativeSlotPool()
protected long
getRelativeTimeMillis()
protected String
getSlotServiceStatus()
Collection<SlotOffer>
offerSlots(TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, Collection<SlotOffer> offers)
Offers multiple slots to theSlotPoolService
.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()
This method is called when the slot pool service is started.boolean
registerTaskManager(ResourceID taskManagerId)
Registers a TaskExecutor with the givenResourceID
atSlotPoolService
.void
releaseFreeSlotsOnTaskManager(ResourceID taskManagerId, Exception cause)
Releases all free slots belonging to the owning TaskExecutor if it has been registered.boolean
releaseTaskManager(ResourceID taskManagerId, Exception cause)
Releases a TaskExecutor with the givenResourceID
from theSlotPoolService
.void
start(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, wait
-
Methods inherited from interface org.apache.flink.runtime.jobmaster.slotpool.SlotPoolService
notifyNotEnoughResourcesAvailable
-
-
-
-
Field Detail
-
log
protected final org.slf4j.Logger log
-
componentMainThreadExecutor
protected final ComponentMainThreadExecutor componentMainThreadExecutor
-
-
Constructor Detail
-
DeclarativeSlotPoolService
public DeclarativeSlotPoolService(JobID jobId, DeclarativeSlotPoolFactory declarativeSlotPoolFactory, Clock clock, Duration idleSlotTimeout, Duration rpcTimeout, Duration slotRequestMaxInterval, @Nonnull ComponentMainThreadExecutor componentMainThreadExecutor)
-
-
Method Detail
-
getDeclarativeSlotPool
protected DeclarativeSlotPool getDeclarativeSlotPool()
-
getRelativeTimeMillis
protected long getRelativeTimeMillis()
-
castInto
public <T> Optional<T> castInto(Class<T> clazz)
Description copied from interface:SlotPoolService
Tries to cast this slot pool service into the given clazz.- Specified by:
castInto
in 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
public final void start(JobMasterId jobMasterId, String address) throws Exception
Description copied from interface:SlotPoolService
Start the encapsulated slot pool implementation.- Specified by:
start
in 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:SlotPoolService
Close the slot pool service.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in 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:SlotPoolService
Offers multiple slots to theSlotPoolService
. The slot offerings can be individually accepted or rejected by returning the collection of accepted slot offers.- Specified by:
offerSlots
in 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:SlotPoolService
Fails the allocation with the given allocationId.- Specified by:
failAllocation
in 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
protected void onFailAllocation(ResourceCounter previouslyFulfilledRequirements)
This method is called when an allocation fails. It can be overridden by subclasses.- Parameters:
previouslyFulfilledRequirements
- previouslyFulfilledRequirements by the failed allocation
-
registerTaskManager
public boolean registerTaskManager(ResourceID taskManagerId)
Description copied from interface:SlotPoolService
Registers a TaskExecutor with the givenResourceID
atSlotPoolService
.- Specified by:
registerTaskManager
in interfaceSlotPoolService
- Parameters:
taskManagerId
- identifying the TaskExecutor to register- Returns:
- true iff a new resource id was registered
-
releaseTaskManager
public boolean releaseTaskManager(ResourceID taskManagerId, Exception cause)
Description copied from interface:SlotPoolService
Releases a TaskExecutor with the givenResourceID
from theSlotPoolService
.- Specified by:
releaseTaskManager
in 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
public void releaseFreeSlotsOnTaskManager(ResourceID taskManagerId, Exception cause)
Description copied from interface:SlotPoolService
Releases all free slots belonging to the owning TaskExecutor if it has been registered.- Specified by:
releaseFreeSlotsOnTaskManager
in interfaceSlotPoolService
- Parameters:
taskManagerId
- identifying the TaskExecutorcause
- cause for failing the slots
-
onReleaseTaskManager
protected void onReleaseTaskManager(ResourceCounter previouslyFulfilledRequirement)
This method is called when a TaskManager is released. It can be overridden by subclasses.- Parameters:
previouslyFulfilledRequirement
- previouslyFulfilledRequirement by the released TaskManager
-
connectToResourceManager
public void connectToResourceManager(ResourceManagerGateway resourceManagerGateway)
Description copied from interface:SlotPoolService
Connects 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:
connectToResourceManager
in interfaceSlotPoolService
- Parameters:
resourceManagerGateway
- The RPC gateway for the resource manager.
-
disconnectResourceManager
public void disconnectResourceManager()
Description copied from interface:SlotPoolService
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.
- Specified by:
disconnectResourceManager
in interfaceSlotPoolService
-
createAllocatedSlotReport
public AllocatedSlotReport createAllocatedSlotReport(ResourceID taskManagerId)
Description copied from interface:SlotPoolService
Create report about the allocated slots belonging to the specified task manager.- Specified by:
createAllocatedSlotReport
in interfaceSlotPoolService
- Parameters:
taskManagerId
- identifies the task manager- Returns:
- the allocated slots on the task manager
-
getSlotServiceStatus
protected String getSlotServiceStatus()
-
-