public class SlotPool extends RpcEndpoint implements SlotPoolGateway
All the allocation or the slot offering will be identified by self generated AllocationID, we will use it to eliminate ambiguities. TODO : Make pending requests location preference aware TODO : Make pass location preferences to ResourceManager when sending a slot request
RpcEndpoint.MainThreadExecutor
log, rpcServer
Constructor and Description |
---|
SlotPool(RpcService rpcService,
JobID jobId) |
SlotPool(RpcService rpcService,
JobID jobId,
Clock clock,
Time slotRequestTimeout,
Time resourceManagerAllocationTimeout,
Time resourceManagerRequestTimeout) |
Modifier and Type | Method and Description |
---|---|
CompletableFuture<SimpleSlot> |
allocateSlot(ScheduledUnit task,
ResourceProfile resources,
Iterable<TaskManagerLocation> locationPreferences,
Time timeout) |
void |
connectToResourceManager(ResourceManagerGateway resourceManagerGateway)
Connects the SlotPool to the given ResourceManager.
|
void |
disconnectResourceManager()
Disconnects the slot pool from its current Resource Manager.
|
void |
failAllocation(AllocationID allocationID,
Exception cause)
Fail the specified allocation and release the corresponding slot if we have one.
|
SlotOwner |
getSlotOwner()
Gets the slot owner implementation for this pool.
|
SlotProvider |
getSlotProvider()
Gets the slot provider implementation for this pool.
|
CompletableFuture<Boolean> |
offerSlot(AllocatedSlot slot)
Slot offering by TaskManager with AllocationID.
|
CompletableFuture<Collection<SlotOffer>> |
offerSlots(Collection<Tuple2<AllocatedSlot,SlotOffer>> offers) |
void |
registerTaskManager(ResourceID resourceID)
Register TaskManager to this pool, only those slots come from registered TaskManager will be considered valid.
|
CompletableFuture<Acknowledge> |
releaseTaskManager(ResourceID resourceID)
Unregister TaskManager from this pool, all the related slots will be released and tasks be canceled.
|
void |
returnAllocatedSlot(Slot slot) |
void |
start()
Starts the rpc endpoint.
|
void |
start(JobMasterId jobMasterId,
String newJobManagerAddress)
Start the slot pool to accept RPC calls.
|
void |
suspend()
Suspends this pool, meaning it has lost its authority to accept and distribute slots.
|
callAsync, getAddress, getEndpointId, getHostname, getMainThreadExecutor, getRpcService, getSelfGateway, getTerminationFuture, postStop, runAsync, scheduleRunAsync, scheduleRunAsync, shutDown, stop, validateRunsInMainThread
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAddress, getHostname
public SlotPool(RpcService rpcService, JobID jobId)
public void start()
RpcEndpoint
start
in class RpcEndpoint
public void start(JobMasterId jobMasterId, String newJobManagerAddress) throws Exception
jobMasterId
- The necessary leader id for running the job.newJobManagerAddress
- for the slot requests which are sent to the resource managerException
public void suspend()
suspend
in interface SlotPoolGateway
public SlotOwner getSlotOwner()
This method does not mutate state and can be called directly (no RPC indirection)
public SlotProvider getSlotProvider()
This method does not mutate state and can be called directly (no RPC indirection)
public void connectToResourceManager(ResourceManagerGateway resourceManagerGateway)
SlotPoolGateway
connectToResourceManager
in interface SlotPoolGateway
resourceManagerGateway
- The RPC gateway for the resource manager.public void disconnectResourceManager()
SlotPoolGateway
The slot pool will still be able to serve slots from its internal pool.
disconnectResourceManager
in interface SlotPoolGateway
public CompletableFuture<SimpleSlot> allocateSlot(ScheduledUnit task, ResourceProfile resources, Iterable<TaskManagerLocation> locationPreferences, Time timeout)
allocateSlot
in interface SlotPoolGateway
public void returnAllocatedSlot(Slot slot)
returnAllocatedSlot
in interface SlotPoolGateway
public CompletableFuture<Collection<SlotOffer>> offerSlots(Collection<Tuple2<AllocatedSlot,SlotOffer>> offers)
offerSlots
in interface SlotPoolGateway
public CompletableFuture<Boolean> offerSlot(AllocatedSlot slot)
offerSlot
in interface SlotPoolGateway
slot
- The offered slotpublic void failAllocation(AllocationID allocationID, Exception cause)
failAllocation
in interface SlotPoolGateway
allocationID
- Represents the allocation which should be failedcause
- The cause of the failurepublic void registerTaskManager(ResourceID resourceID)
registerTaskManager
in interface SlotPoolGateway
resourceID
- The id of the TaskManagerpublic CompletableFuture<Acknowledge> releaseTaskManager(ResourceID resourceID)
releaseTaskManager
in interface SlotPoolGateway
resourceID
- The id of the TaskManagerCopyright © 2014–2018 The Apache Software Foundation. All rights reserved.