Interface SlotPoolService
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
DeclarativeSlotPoolBridge
,DeclarativeSlotPoolService
public interface SlotPoolService extends AutoCloseable
Service used by theJobMaster
to manage a slot pool.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <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.default 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 theSlotPoolService
.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.
-
-
-
Method Detail
-
castInto
default <T> Optional<T> castInto(Class<T> clazz)
Tries to cast this slot pool service into the given clazz.- 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
void start(JobMasterId jobMasterId, String address) throws Exception
Start the encapsulated slot pool implementation.- Parameters:
jobMasterId
- jobMasterId to start the service withaddress
- address of the owner- Throws:
Exception
- if the service cannot be started
-
close
void close()
Close the slot pool service.- Specified by:
close
in interfaceAutoCloseable
-
offerSlots
Collection<SlotOffer> offerSlots(TaskManagerLocation taskManagerLocation, TaskManagerGateway taskManagerGateway, Collection<SlotOffer> offers)
Offers multiple slots to theSlotPoolService
. 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 theSlotPoolService
- Returns:
- A collection of accepted slot offers. The remaining slot offers are implicitly rejected.
-
failAllocation
Optional<ResourceID> failAllocation(@Nullable ResourceID taskManagerId, AllocationID allocationId, Exception cause)
Fails the allocation with the given allocationId.- 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
-
registerTaskManager
boolean registerTaskManager(ResourceID taskManagerId)
Registers a TaskExecutor with the givenResourceID
atSlotPoolService
.- Parameters:
taskManagerId
- identifying the TaskExecutor to register- Returns:
- true iff a new resource id was registered
-
releaseTaskManager
boolean releaseTaskManager(ResourceID taskManagerId, Exception cause)
Releases a TaskExecutor with the givenResourceID
from theSlotPoolService
.- 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
void releaseFreeSlotsOnTaskManager(ResourceID taskManagerId, Exception cause)
Releases all free slots belonging to the owning TaskExecutor if it has been registered.- Parameters:
taskManagerId
- identifying the TaskExecutorcause
- cause for failing the slots
-
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.
-
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
-
notifyNotEnoughResourcesAvailable
default void notifyNotEnoughResourcesAvailable(Collection<ResourceRequirement> acquiredResources)
Notifies that not enough resources are available to fulfill the resource requirements.- Parameters:
acquiredResources
- the resources that have been acquired
-
-