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 the DeclarativeSlotPool.
  • 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

      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 interface SlotPoolService
      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; otherwise Optional.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 interface SlotPoolService
      Parameters:
      jobMasterId - jobMasterId to start the service with
      address - 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 interface AutoCloseable
      Specified by:
      close in interface SlotPoolService
    • 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 the SlotPoolService. The slot offerings can be individually accepted or rejected by returning the collection of accepted slot offers.
      Specified by:
      offerSlots in interface SlotPoolService
      Parameters:
      taskManagerLocation - from which the slot offers originate
      taskManagerGateway - to talk to the slot offerer
      offers - slot offers which are offered to the SlotPoolService
      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 interface SlotPoolService
      Parameters:
      taskManagerId - taskManagerId is non-null if the signal comes from a TaskManager; if the signal comes from the ResourceManager, then it is null
      allocationId - allocationId identifies which allocation to fail
      cause - 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 given ResourceID at SlotPoolService.
      Specified by:
      registerTaskManager in interface SlotPoolService
      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 given ResourceID from the SlotPoolService.
      Specified by:
      releaseTaskManager in interface SlotPoolService
      Parameters:
      taskManagerId - identifying the TaskExecutor which shall be released from the SlotPool
      cause - 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 interface SlotPoolService
      Parameters:
      taskManagerId - identifying the TaskExecutor
      cause - 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 interface SlotPoolService
      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 interface SlotPoolService
    • 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 interface SlotPoolService
      Parameters:
      taskManagerId - identifies the task manager
      Returns:
      the allocated slots on the task manager
    • getSlotServiceStatus

      protected String getSlotServiceStatus()