Class JobMasterServiceLeadershipRunner
java.lang.Object
org.apache.flink.runtime.jobmaster.JobMasterServiceLeadershipRunner
- All Implemented Interfaces:
AutoCloseable,JobManagerRunner,LeaderContender,org.apache.flink.util.AutoCloseableAsync
public class JobMasterServiceLeadershipRunner
extends Object
implements JobManagerRunner, LeaderContender
Leadership runner for the
JobMasterServiceProcess.
The responsibility of this component is to manage the leadership of the JobMasterServiceProcess. This means that the runner will create an instance of the process when
it obtains the leadership. The process is stopped once the leadership is revoked.
This component only accepts signals (job result completion, initialization failure) as long as it is running and as long as the signals are coming from the current leader process. This ensures that only the current leader can affect this component.
All leadership operations are serialized. This means that granting the leadership has to complete before the leadership can be revoked and vice versa.
The resultFuture can be completed with the following values: * *
JobManagerRunnerResultto signal an initialization failure of theJobMasterServiceor the completion of a jobExceptionto signal an unexpected failure
-
Constructor Summary
ConstructorsConstructorDescriptionJobMasterServiceLeadershipRunner(JobMasterServiceProcessFactory jobMasterServiceProcessFactory, LeaderElection leaderElection, JobResultStore jobResultStore, LibraryCacheManager.ClassLoaderLease classLoaderLease, org.apache.flink.runtime.rpc.FatalErrorHandler fatalErrorHandler) -
Method Summary
Modifier and TypeMethodDescriptionCancels the currently executed job.org.apache.flink.api.common.JobIDgetJobID()Get the job id of the executed job.Get theJobMasterGatewayof theJobMaster.Get the result future of this runner.voidgrantLeadership(UUID leaderSessionID) Callback method which is called by theLeaderElectionServiceupon selecting this instance as the new leader.voidhandleError(Exception exception) Callback method which is called byLeaderElectionServicein case of an error in the service thread.booleanFlag indicating if the JobManagerRunner has been initialized.requestJob(Duration timeout) Requests theExecutionGraphInfoof the executed job.requestJobDetails(Duration timeout) Request the details of the executed job.CompletableFuture<org.apache.flink.api.common.JobStatus>requestJobStatus(Duration timeout) Requests the current job status.voidCallback method which is called by theLeaderElectionServiceupon revoking the leadership of a former leader.voidstart()Start the execution of theJobMaster.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.flink.util.AutoCloseableAsync
close
-
Constructor Details
-
JobMasterServiceLeadershipRunner
public JobMasterServiceLeadershipRunner(JobMasterServiceProcessFactory jobMasterServiceProcessFactory, LeaderElection leaderElection, JobResultStore jobResultStore, LibraryCacheManager.ClassLoaderLease classLoaderLease, org.apache.flink.runtime.rpc.FatalErrorHandler fatalErrorHandler)
-
-
Method Details
-
closeAsync
- Specified by:
closeAsyncin interfaceorg.apache.flink.util.AutoCloseableAsync
-
start
Description copied from interface:JobManagerRunnerStart the execution of theJobMaster.- Specified by:
startin interfaceJobManagerRunner- Throws:
Exception- if the JobMaster cannot be started
-
getJobMasterGateway
Description copied from interface:JobManagerRunnerGet theJobMasterGatewayof theJobMaster. The future is only completed if the JobMaster becomes leader.- Specified by:
getJobMasterGatewayin interfaceJobManagerRunner- Returns:
- Future with the JobMasterGateway once the underlying JobMaster becomes leader
-
getResultFuture
Description copied from interface:JobManagerRunnerGet the result future of this runner. The future is completed once the executed job reaches a globally terminal state or if the initialization of theJobMasterfails. If the result future is completed exceptionally viaJobNotFinishedException, then this signals that the job has not been completed successfully. All other exceptional completions denote an unexpected exception which leads to a process restart.- Specified by:
getResultFuturein interfaceJobManagerRunner- Returns:
- Future which is completed with the job result
-
getJobID
public org.apache.flink.api.common.JobID getJobID()Description copied from interface:JobManagerRunnerGet the job id of the executed job.- Specified by:
getJobIDin interfaceJobManagerRunner- Returns:
- job id of the executed job
-
cancel
Description copied from interface:JobManagerRunnerCancels the currently executed job.- Specified by:
cancelin interfaceJobManagerRunner- Parameters:
timeout- of this operation- Returns:
- Future acknowledge of the operation
-
requestJobStatus
Description copied from interface:JobManagerRunnerRequests the current job status.- Specified by:
requestJobStatusin interfaceJobManagerRunner- Parameters:
timeout- for the rpc call- Returns:
- Future containing the current job status
-
requestJobDetails
Description copied from interface:JobManagerRunnerRequest the details of the executed job.- Specified by:
requestJobDetailsin interfaceJobManagerRunner- Parameters:
timeout- for the rpc call- Returns:
- Future details of the executed job
-
requestJob
Description copied from interface:JobManagerRunnerRequests theExecutionGraphInfoof the executed job.- Specified by:
requestJobin interfaceJobManagerRunner- Parameters:
timeout- for the rpc call- Returns:
- Future which is completed with the
ExecutionGraphInfoof the executed job
-
isInitialized
public boolean isInitialized()Description copied from interface:JobManagerRunnerFlag indicating if the JobManagerRunner has been initialized.- Specified by:
isInitializedin interfaceJobManagerRunner- Returns:
- true if the JobManagerRunner has been initialized.
-
grantLeadership
Description copied from interface:LeaderContenderCallback method which is called by theLeaderElectionServiceupon selecting this instance as the new leader. The method is called with the new leader session ID.- Specified by:
grantLeadershipin interfaceLeaderContender- Parameters:
leaderSessionID- New leader session ID
-
revokeLeadership
public void revokeLeadership()Description copied from interface:LeaderContenderCallback method which is called by theLeaderElectionServiceupon revoking the leadership of a former leader. This might happen in case that multiple contenders have been granted leadership.- Specified by:
revokeLeadershipin interfaceLeaderContender
-
handleError
Description copied from interface:LeaderContenderCallback method which is called byLeaderElectionServicein case of an error in the service thread.- Specified by:
handleErrorin interfaceLeaderContender- Parameters:
exception- Caught exception
-