Interface ResourceManagerDriver<WorkerType extends ResourceIDRetrievable>
-
- All Known Implementing Classes:
AbstractResourceManagerDriver
,KubernetesResourceManagerDriver
,YarnResourceManagerDriver
public interface ResourceManagerDriver<WorkerType extends ResourceIDRetrievable>
AResourceManagerDriver
is responsible for requesting and releasing resources from/to a particular external resource manager.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
deregisterApplication(ApplicationStatus finalStatus, String optionalDiagnostics)
The deployment specific code to deregister the application.void
initialize(ResourceEventHandler<WorkerType> resourceEventHandler, ScheduledExecutor mainThreadExecutor, Executor ioExecutor, BlockedNodeRetriever blockedNodeRetriever)
Initialize the deployment specific components.void
releaseResource(WorkerType worker)
Release resource to the external resource manager.CompletableFuture<WorkerType>
requestResource(TaskExecutorProcessSpec taskExecutorProcessSpec)
Request resource from the external resource manager.void
terminate()
Terminate the deployment specific components.
-
-
-
Method Detail
-
initialize
void initialize(ResourceEventHandler<WorkerType> resourceEventHandler, ScheduledExecutor mainThreadExecutor, Executor ioExecutor, BlockedNodeRetriever blockedNodeRetriever) throws Exception
Initialize the deployment specific components.- Parameters:
resourceEventHandler
- Handler that handles resource events.mainThreadExecutor
- Rpc main thread executor.ioExecutor
- IO executor.blockedNodeRetriever
- To retrieve all blocked nodes- Throws:
Exception
-
terminate
void terminate() throws Exception
Terminate the deployment specific components.- Throws:
Exception
-
deregisterApplication
void deregisterApplication(ApplicationStatus finalStatus, @Nullable String optionalDiagnostics) throws Exception
The deployment specific code to deregister the application. This should report the application's final status.This method also needs to make sure all pending containers that are not registered yet are returned.
- Parameters:
finalStatus
- The application status to report.optionalDiagnostics
- A diagnostics message ornull
.- Throws:
Exception
- if the application could not be deregistered.
-
requestResource
CompletableFuture<WorkerType> requestResource(TaskExecutorProcessSpec taskExecutorProcessSpec)
Request resource from the external resource manager.This method request a new resource from the external resource manager, and tries to launch a task manager inside the allocated resource, with respect to the provided taskExecutorProcessSpec. The returned future will be completed with a worker node in the deployment specific type, or exceptionally if the allocation has failed.
Note: The returned future could be cancelled by ResourceManager. This means ResourceManager don't need this resource anymore, Driver should try to cancel this request from the external resource manager.
Note: Completion of the returned future does not necessarily mean the success of resource allocation and task manager launching. Allocation and launching failures can still happen after the future completion. In such cases,
ResourceEventHandler.onWorkerTerminated(org.apache.flink.runtime.clusterframework.types.ResourceID, java.lang.String)
will be called.The future is guaranteed to be completed in the rpc main thread, before trying to launch the task manager, thus before the task manager registration. It is also guaranteed that
ResourceEventHandler.onWorkerTerminated(org.apache.flink.runtime.clusterframework.types.ResourceID, java.lang.String)
will not be called on the requested worker, until the returned future is completed successfully.- Parameters:
taskExecutorProcessSpec
- Resource specification of the requested worker.- Returns:
- Future that wraps worker node of the requested resource, in the deployment specific type.
-
releaseResource
void releaseResource(WorkerType worker)
Release resource to the external resource manager.- Parameters:
worker
- Worker node to be released, in the deployment specific type.
-
-