TisonKun commented on a change in pull request #9788: [FLINK-14259] Introduce 
JobManagerRunner interface
URL: https://github.com/apache/flink/pull/9788#discussion_r329351146
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobManagerRunnerImpl.java
 ##########
 @@ -0,0 +1,445 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.jobmaster;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.client.JobExecutionException;
+import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.execution.librarycache.LibraryCacheManager;
+import org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph;
+import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
+import org.apache.flink.runtime.highavailability.RunningJobsRegistry;
+import 
org.apache.flink.runtime.highavailability.RunningJobsRegistry.JobSchedulingStatus;
+import org.apache.flink.runtime.jobgraph.JobGraph;
+import org.apache.flink.runtime.jobmanager.OnCompletionActions;
+import org.apache.flink.runtime.jobmaster.factories.JobMasterServiceFactory;
+import org.apache.flink.runtime.leaderelection.LeaderContender;
+import org.apache.flink.runtime.leaderelection.LeaderElectionService;
+import org.apache.flink.runtime.messages.Acknowledge;
+import org.apache.flink.runtime.rpc.FatalErrorHandler;
+import org.apache.flink.util.ExceptionUtils;
+import org.apache.flink.util.FlinkException;
+import org.apache.flink.util.function.FunctionUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nonnull;
+
+import java.io.IOException;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.Executor;
+
+import static org.apache.flink.util.Preconditions.checkArgument;
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * The runner for the job manager. It deals with job level leader election and 
make underlying job manager
+ * properly reacted.
+ */
+public class JobManagerRunnerImpl implements LeaderContender, 
OnCompletionActions, JobManagerRunner {
+
+       private static final Logger log = 
LoggerFactory.getLogger(JobManagerRunnerImpl.class);
+
+       // 
------------------------------------------------------------------------
+
+       /** Lock to ensure that this runner can deal with leader election event 
and job completion notifies simultaneously. */
+       private final Object lock = new Object();
+
+       /** The job graph needs to run. */
+       private final JobGraph jobGraph;
+
+       /** Used to check whether a job needs to be run. */
+       private final RunningJobsRegistry runningJobsRegistry;
+
+       /** Leader election for this job. */
+       private final LeaderElectionService leaderElectionService;
+
+       private final LibraryCacheManager libraryCacheManager;
+
+       private final Executor executor;
+
+       private final JobMasterService jobMasterService;
+
+       private final FatalErrorHandler fatalErrorHandler;
+
+       private final CompletableFuture<ArchivedExecutionGraph> resultFuture;
+
+       private final CompletableFuture<Void> terminationFuture;
+
+       private CompletableFuture<Void> leadershipOperation;
+
+       /** flag marking the runner as shut down. */
+       private volatile boolean shutdown;
+
+       private volatile CompletableFuture<JobMasterGateway> 
leaderGatewayFuture;
+
+       // 
------------------------------------------------------------------------
+
+       /**
+        * Exceptions that occur while creating the JobManager or 
JobManagerRunner are directly
+        * thrown and not reported to the given {@code FatalErrorHandler}.
+        *
+        * @throws Exception Thrown if the runner cannot be set up, because 
either one of the
+        *                   required services could not be started, or the Job 
could not be initialized.
+        */
+       public JobManagerRunnerImpl(
+                       final JobGraph jobGraph,
 
 Review comment:
   Yes I could start a discussion tomorrow :-)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to