tillrohrmann commented on a change in pull request #9950: 
[FLINK-14464][runtime] Introduce the AbstractUserClassPathJobGraphRetriever
URL: https://github.com/apache/flink/pull/9950#discussion_r341167377
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/entrypoint/component/AbstractUserClassPathJobGraphRetriever.java
 ##########
 @@ -0,0 +1,57 @@
+/*
+ * 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.entrypoint.component;
+
+import org.apache.flink.util.FileUtils;
+
+import javax.annotation.Nullable;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *  Abstract class for the JobGraphRetriever, which wants to get classpath 
user's code depends on.
+ */
+public abstract class AbstractUserClassPathJobGraphRetriever implements 
JobGraphRetriever {
+
+       /* A collection of relative jar paths to the working directory */
+       private final List<URL> userClassPaths;
+
+       protected AbstractUserClassPathJobGraphRetriever(@Nullable final File 
jobDir) throws IOException {
+               if (jobDir == null) {
+                       userClassPaths = Collections.emptyList();
+               } else {
+                       final Collection<File> jarFiles = 
FileUtils.listFilesInPath(jobDir, file -> file.getName().endsWith(".jar"));
+                       final Collection<File> relativeFiles = 
FileUtils.relativizeToWorkingDir(jarFiles);
+                       this.userClassPaths = new 
ArrayList<>(FileUtils.toRelativeURLs(relativeFiles));
 
 Review comment:
   I'd be slightly in favour of @zhuzhurk proposal. That way, we say that this 
class returns a `Collection<URL>` and whoever expects a `List<URL>` will have 
to transform it. I think this way gives a bit more flexibility because this 
class, as you've said, does not impose any particular order.

----------------------------------------------------------------
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