dmvk commented on a change in pull request #18627:
URL: https://github.com/apache/flink/pull/18627#discussion_r799613571
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
##########
@@ -579,23 +624,28 @@ private CleanupJobState jobManagerRunnerFailed(JobID
jobId, Throwable throwable)
return CleanupJobState.LOCAL;
}
- JobManagerRunner createJobManagerRunner(JobGraph jobGraph, long
initializationTimestamp)
- throws Exception {
+ private JobManagerRunner initializeJobManagerRunner(JobGraph jobGraph)
throws Exception {
Review comment:
What is the reason for renaming this method? `createXX` seems more
appropriate here
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
##########
@@ -515,18 +548,30 @@ private boolean isPartialResourceConfigured(JobGraph
jobGraph) {
private void persistAndRunJob(JobGraph jobGraph) throws Exception {
jobGraphWriter.putJobGraph(jobGraph);
- runJob(jobGraph, ExecutionType.SUBMISSION);
+ initializeAndStartJobManagerRunner(jobGraph, ExecutionType.SUBMISSION);
}
- private void runJob(JobGraph jobGraph, ExecutionType executionType) throws
Exception {
+ private void initializeAndStartJobManagerRunner(JobGraph jobGraph,
ExecutionType executionType)
+ throws Exception {
Preconditions.checkState(!jobManagerRunnerRegistry.isRegistered(jobGraph.getJobID()));
- long initializationTimestamp = System.currentTimeMillis();
- JobManagerRunner jobManagerRunner =
- createJobManagerRunner(jobGraph, initializationTimestamp);
+ final JobManagerRunner jobManagerRunner =
initializeJobManagerRunner(jobGraph);
+ runJob(jobManagerRunner, executionType);
+ }
+
+ private void initializeAndStartCheckpointJobDataCleanupRunner(JobResult
jobResult)
+ throws Exception {
+
Preconditions.checkState(!jobManagerRunnerRegistry.isRegistered(jobResult.getJobId()));
+ final JobManagerRunner checkpointJobDataCleanupRunner =
+ initializeCheckpointJobDataCleanupRunner(jobResult);
+ runJob(checkpointJobDataCleanupRunner, ExecutionType.RECOVERY);
Review comment:
```suggestion
final JobManagerRunner runner =
cleanupRunnerFactory.create(
jobResult,
highAvailabilityServices.getCheckpointRecoveryFactory(),
configuration,
ioExecutor);
runJob(runner, ExecutionType.RECOVERY);
```
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
##########
@@ -248,6 +257,8 @@ protected Dispatcher(
this.recoveredJobs = new HashSet<>(recoveredJobs);
+ this.recoveredDirtyJobs = new HashSet<>(recoveredDirtyJobs);
Review comment:
please align the parameter name between constructors;
`globallyTerminatedJobs` -> `recoveredDirtyJobs`
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
##########
@@ -515,18 +548,30 @@ private boolean isPartialResourceConfigured(JobGraph
jobGraph) {
private void persistAndRunJob(JobGraph jobGraph) throws Exception {
jobGraphWriter.putJobGraph(jobGraph);
- runJob(jobGraph, ExecutionType.SUBMISSION);
+ initializeAndStartJobManagerRunner(jobGraph, ExecutionType.SUBMISSION);
}
- private void runJob(JobGraph jobGraph, ExecutionType executionType) throws
Exception {
+ private void initializeAndStartJobManagerRunner(JobGraph jobGraph,
ExecutionType executionType)
+ throws Exception {
Preconditions.checkState(!jobManagerRunnerRegistry.isRegistered(jobGraph.getJobID()));
- long initializationTimestamp = System.currentTimeMillis();
- JobManagerRunner jobManagerRunner =
- createJobManagerRunner(jobGraph, initializationTimestamp);
+ final JobManagerRunner jobManagerRunner =
initializeJobManagerRunner(jobGraph);
+ runJob(jobManagerRunner, executionType);
Review comment:
Would in-lining the JM creation make the code more readable? (and less
fragmented)
```suggestion
final JobManagerRunner runner =
jobManagerRunnerFactory.createJobManagerRunner(
jobGraph,
configuration,
getRpcService(),
highAvailabilityServices,
heartbeatServices,
jobManagerSharedServices,
new
DefaultJobManagerJobMetricGroupFactory(jobManagerMetricGroup),
fatalErrorHandler,
System.currentTimeMillis());
runJob(runner, executionType);
```
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java
##########
@@ -515,18 +548,30 @@ private boolean isPartialResourceConfigured(JobGraph
jobGraph) {
private void persistAndRunJob(JobGraph jobGraph) throws Exception {
jobGraphWriter.putJobGraph(jobGraph);
- runJob(jobGraph, ExecutionType.SUBMISSION);
+ initializeAndStartJobManagerRunner(jobGraph, ExecutionType.SUBMISSION);
}
- private void runJob(JobGraph jobGraph, ExecutionType executionType) throws
Exception {
+ private void initializeAndStartJobManagerRunner(JobGraph jobGraph,
ExecutionType executionType)
+ throws Exception {
Preconditions.checkState(!jobManagerRunnerRegistry.isRegistered(jobGraph.getJobID()));
- long initializationTimestamp = System.currentTimeMillis();
- JobManagerRunner jobManagerRunner =
- createJobManagerRunner(jobGraph, initializationTimestamp);
+ final JobManagerRunner jobManagerRunner =
initializeJobManagerRunner(jobGraph);
+ runJob(jobManagerRunner, executionType);
+ }
+
+ private void initializeAndStartCheckpointJobDataCleanupRunner(JobResult
jobResult)
Review comment:
The naming feels bit inconsistent between methods variables. We can
probably also get rid of some methods and instance variables to make things
less noisy.
Here is how it could look like:
https://gist.github.com/dmvk/af622c1b56a91d8f489a65353e22f1fa
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/cleanup/CheckpointResourcesCleanupRunner.java
##########
@@ -0,0 +1,242 @@
+/*
+ * 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.dispatcher.cleanup;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.api.common.JobStatus;
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.checkpoint.CheckpointIDCounter;
+import org.apache.flink.runtime.checkpoint.CheckpointRecoveryFactory;
+import org.apache.flink.runtime.checkpoint.CheckpointsCleaner;
+import org.apache.flink.runtime.checkpoint.CompletedCheckpointStore;
+import org.apache.flink.runtime.checkpoint.CompletedCheckpointStoreUtils;
+import
org.apache.flink.runtime.dispatcher.UnavailableDispatcherOperationException;
+import org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph;
+import org.apache.flink.runtime.jobmaster.JobManagerRunner;
+import org.apache.flink.runtime.jobmaster.JobManagerRunnerResult;
+import org.apache.flink.runtime.jobmaster.JobMaster;
+import org.apache.flink.runtime.jobmaster.JobMasterGateway;
+import org.apache.flink.runtime.jobmaster.JobResult;
+import org.apache.flink.runtime.messages.Acknowledge;
+import org.apache.flink.runtime.messages.webmonitor.JobDetails;
+import org.apache.flink.runtime.scheduler.ExecutionGraphInfo;
+import org.apache.flink.runtime.state.SharedStateRegistryFactory;
+import org.apache.flink.util.ExceptionUtils;
+import org.apache.flink.util.FlinkException;
+import org.apache.flink.util.Preconditions;
+import org.apache.flink.util.concurrent.FutureUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+import java.util.concurrent.Executor;
+
+/**
+ * {@code CheckpointResourcesCleanupRunner} implements {@link
JobManagerRunner} in a way, that only
+ * the checkpoint-related resources are instantiated. It triggers any
job-specific cleanup that's
+ * usually performed by the {@link JobMaster} without rebuilding the
corresponding {@link
+ * org.apache.flink.runtime.executiongraph.ExecutionGraph}.
+ */
+public class CheckpointResourcesCleanupRunner implements JobManagerRunner {
Review comment:
Can be simplified:
- we don't need to tie all the state with the instance (store + counter
instances)
https://gist.github.com/dmvk/51fd124c4ec4b59e12d1b72c2dd8cba5
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]