public class SlotManager extends Object implements AutoCloseable
ResourceActions.allocateResource(ResourceProfile)
.
In order to free resources and avoid resource leaks, idling task managers (task managers whose slots are currently not used) and pending slot requests time out triggering their release and failure, respectively.
Constructor and Description |
---|
SlotManager(ScheduledExecutor scheduledExecutor,
Time taskManagerRequestTimeout,
Time slotRequestTimeout,
Time taskManagerTimeout) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the slot manager.
|
protected PendingSlotRequest |
findMatchingRequest(ResourceProfile slotResourceProfile)
Finds a matching slot request for a given resource profile.
|
protected TaskManagerSlot |
findMatchingSlot(ResourceProfile requestResourceProfile)
Finds a matching slot for a given resource profile.
|
void |
freeSlot(SlotID slotId,
AllocationID allocationId)
Free the given slot from the given allocation.
|
int |
getNumberFreeSlots() |
int |
getNumberFreeSlotsOf(InstanceID instanceId) |
int |
getNumberPendingSlotRequests() |
int |
getNumberRegisteredSlots() |
int |
getNumberRegisteredSlotsOf(InstanceID instanceId) |
boolean |
registerSlotRequest(SlotRequest slotRequest)
Requests a slot with the respective resource profile.
|
void |
registerTaskManager(TaskExecutorConnection taskExecutorConnection,
SlotReport initialSlotReport)
Registers a new task manager at the slot manager.
|
boolean |
reportSlotStatus(InstanceID instanceId,
SlotReport slotReport)
Reports the current slot allocations for a task manager identified by the given instance id.
|
void |
start(ResourceManagerId newResourceManagerId,
Executor newMainThreadExecutor,
ResourceActions newResourceActions)
Starts the slot manager with the given leader id and resource manager actions.
|
void |
suspend()
Suspends the component.
|
boolean |
unregisterSlotRequest(AllocationID allocationId)
Cancels and removes a pending slot request with the given allocation id.
|
boolean |
unregisterTaskManager(InstanceID instanceId)
Unregisters the task manager identified by the given instance id and its associated slots
from the slot manager.
|
void |
unregisterTaskManagersAndReleaseResources() |
public SlotManager(ScheduledExecutor scheduledExecutor, Time taskManagerRequestTimeout, Time slotRequestTimeout, Time taskManagerTimeout)
public int getNumberRegisteredSlots()
public int getNumberRegisteredSlotsOf(InstanceID instanceId)
public int getNumberFreeSlots()
public int getNumberFreeSlotsOf(InstanceID instanceId)
public int getNumberPendingSlotRequests()
public void start(ResourceManagerId newResourceManagerId, Executor newMainThreadExecutor, ResourceActions newResourceActions)
newResourceManagerId
- to use for communication with the task managersnewMainThreadExecutor
- to use to run code in the ResourceManager's main threadnewResourceActions
- to use for resource (de-)allocationspublic void suspend()
public void close() throws Exception
close
in interface AutoCloseable
Exception
- if the close operation failspublic boolean registerSlotRequest(SlotRequest slotRequest) throws SlotManagerException
slotRequest
- specifying the requested slot specsSlotManagerException
- if the slot request failed (e.g. not enough resources left)public boolean unregisterSlotRequest(AllocationID allocationId)
allocationId
- identifying the pending slot requestpublic void registerTaskManager(TaskExecutorConnection taskExecutorConnection, SlotReport initialSlotReport)
taskExecutorConnection
- for the new task managerinitialSlotReport
- for the new task managerpublic boolean unregisterTaskManager(InstanceID instanceId)
instanceId
- identifying the task manager to unregisterpublic boolean reportSlotStatus(InstanceID instanceId, SlotReport slotReport)
instanceId
- identifying the task manager for which to report the slot statusslotReport
- containing the status for all of its slotspublic void freeSlot(SlotID slotId, AllocationID allocationId)
slotId
- identifying the slot to freeallocationId
- with which the slot is presumably allocatedprotected PendingSlotRequest findMatchingRequest(ResourceProfile slotResourceProfile)
Note: If you want to change the behaviour of the slot manager wrt slot allocation and request fulfillment, then you should override this method.
slotResourceProfile
- defining the resources of an available slotprotected TaskManagerSlot findMatchingSlot(ResourceProfile requestResourceProfile)
Note: If you want to change the behaviour of the slot manager wrt slot allocation and request fulfillment, then you should override this method.
requestResourceProfile
- specifying the resource requirements for the a slot request@VisibleForTesting public void unregisterTaskManagersAndReleaseResources()
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.