TisonKun commented on a change in pull request #10251: 
[FLINK-14851][FLINK-14850] Implement Executors and wire them to the 
ContextEnvironment
URL: https://github.com/apache/flink/pull/10251#discussion_r347919590
 
 

 ##########
 File path: 
flink-clients/src/main/java/org/apache/flink/client/deployment/JobClientImpl.java
 ##########
 @@ -0,0 +1,105 @@
+/*
+ * 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.client.deployment;
+
+import org.apache.flink.api.common.JobExecutionResult;
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.client.program.ClusterClient;
+import org.apache.flink.client.program.DetachedJobExecutionResult;
+import org.apache.flink.client.program.ProgramInvocationException;
+import org.apache.flink.core.execution.JobClient;
+import org.apache.flink.runtime.client.JobExecutionException;
+import org.apache.flink.runtime.jobmaster.JobResult;
+import org.apache.flink.util.ExceptionUtils;
+import org.apache.flink.util.ShutdownHookUtil;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nonnull;
+
+import java.io.IOException;
+import java.util.concurrent.CompletableFuture;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * An implementation of the {@link JobClient} interface.
+ */
+public class JobClientImpl<ClusterID> implements JobClient {
+
+       private static final Logger LOG = 
LoggerFactory.getLogger(JobClientImpl.class);
+
+       private final ClusterClient<ClusterID> clusterClient;
+
+       private final JobID jobID;
+
+       private final Thread shutdownHook;
+
+       public JobClientImpl(final ClusterClient<ClusterID> clusterClient, 
final JobID jobID, final boolean withShutdownHook) {
+               this.jobID = checkNotNull(jobID);
+               this.clusterClient = checkNotNull(clusterClient);
+
+               if (withShutdownHook) {
+                       shutdownHook = ShutdownHookUtil.addShutdownHook(
+                                       clusterClient::shutDownCluster, 
clusterClient.getClass().getSimpleName(), LOG);
+               } else {
+                       shutdownHook = null;
+               }
+       }
+
+       @Override
+       public JobID getJobID() {
+               return jobID;
+       }
+
+       @Override
+       public CompletableFuture<JobExecutionResult> getJobSubmissionResult() {
 
 Review comment:
   I don't like this method since a `JobClient` already means submission 
successfully. If we anyway have a function for b/w comp. where a 
JobSubmissionResult is required, I'd like to implement it as
   
   ```java
   public enum JobClientUtils {
     public static CompletableFuture<JobExecutionResult> 
getJobSubmissionResult(JobClient jobClient) {
       return CompletableFuture.completedFuture(new 
DetachedJobExecutionResult(jobClient.getJobID));
     }
   }
   ```
   
   this way, with proper document, we are clear that it is not a desirable 
method in `JobClient`, but for b/w comp. only. When we move from here, we don't 
have to change anything in `JobClient`, instead removing the method in utils 
and its usages.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to