public class DeclarativeSlotPoolService extends Object implements SlotPoolService
SlotPoolService
implementation for the DeclarativeSlotPool
.Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
log |
Constructor and Description |
---|
DeclarativeSlotPoolService(JobID jobId,
DeclarativeSlotPoolFactory declarativeSlotPoolFactory,
Clock clock,
Time idleSlotTimeout,
Time rpcTimeout) |
Modifier and Type | Method and 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 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.
|
boolean |
registerTaskManager(ResourceID taskManagerId)
Registers a TaskExecutor with the given
ResourceID at SlotPoolService . |
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 given
ResourceID from the SlotPoolService . |
void |
start(JobMasterId jobMasterId,
String address,
ComponentMainThreadExecutor mainThreadExecutor)
Start the encapsulated slot pool implementation.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
notifyNotEnoughResourcesAvailable
public DeclarativeSlotPoolService(JobID jobId, DeclarativeSlotPoolFactory declarativeSlotPoolFactory, Clock clock, Time idleSlotTimeout, Time rpcTimeout)
protected DeclarativeSlotPool getDeclarativeSlotPool()
protected long getRelativeTimeMillis()
public <T> Optional<T> castInto(Class<T> clazz)
SlotPoolService
castInto
in interface SlotPoolService
T
- type of clazzclazz
- to cast the slot pool service intoOptional.of(T)
the target type if it can be cast; otherwise Optional.empty()
public final void start(JobMasterId jobMasterId, String address, ComponentMainThreadExecutor mainThreadExecutor) throws Exception
SlotPoolService
start
in interface SlotPoolService
jobMasterId
- jobMasterId to start the service withaddress
- address of the ownermainThreadExecutor
- mainThreadExecutor to run actions in the main threadException
- if the service cannot be startedprotected void onStart(ComponentMainThreadExecutor componentMainThreadExecutor)
componentMainThreadExecutor
- componentMainThreadExecutor used by this slot pool serviceprotected void assertHasBeenStarted()
public final void close()
SlotPoolService
close
in interface AutoCloseable
close
in interface SlotPoolService
protected void onClose()
public 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 SlotPoolService
taskManagerLocation
- from which the slot offers originatetaskManagerGateway
- to talk to the slot offereroffers
- slot offers which are offered to the SlotPoolService
public Optional<ResourceID> failAllocation(@Nullable ResourceID taskManagerId, AllocationID allocationId, Exception cause)
SlotPoolService
failAllocation
in interface SlotPoolService
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 failedprotected void onFailAllocation(ResourceCounter previouslyFulfilledRequirements)
previouslyFulfilledRequirements
- previouslyFulfilledRequirements by the failed
allocationpublic boolean registerTaskManager(ResourceID taskManagerId)
SlotPoolService
ResourceID
at SlotPoolService
.registerTaskManager
in interface SlotPoolService
taskManagerId
- identifying the TaskExecutor to registerpublic boolean releaseTaskManager(ResourceID taskManagerId, Exception cause)
SlotPoolService
ResourceID
from the SlotPoolService
.releaseTaskManager
in interface SlotPoolService
taskManagerId
- identifying the TaskExecutor which shall be released from the SlotPoolcause
- for the releasing of the TaskManagerpublic void releaseFreeSlotsOnTaskManager(ResourceID taskManagerId, Exception cause)
SlotPoolService
releaseFreeSlotsOnTaskManager
in interface SlotPoolService
taskManagerId
- identifying the TaskExecutorcause
- cause for failing the slotsprotected void onReleaseTaskManager(ResourceCounter previouslyFulfilledRequirement)
previouslyFulfilledRequirement
- previouslyFulfilledRequirement by the released
TaskManagerpublic void connectToResourceManager(ResourceManagerGateway resourceManagerGateway)
SlotPoolService
connectToResourceManager
in interface SlotPoolService
resourceManagerGateway
- The RPC gateway for the resource manager.public void disconnectResourceManager()
SlotPoolService
The slot pool will still be able to serve slots from its internal pool.
disconnectResourceManager
in interface SlotPoolService
public AllocatedSlotReport createAllocatedSlotReport(ResourceID taskManagerId)
SlotPoolService
createAllocatedSlotReport
in interface SlotPoolService
taskManagerId
- identifies the task managerprotected String getSlotServiceStatus()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.