guoweiM commented on a change in pull request #9950: [FLINK-14464][runtime] Introduce the AbstractUserClassPathJobGraphRetriever URL: https://github.com/apache/flink/pull/9950#discussion_r339632191
########## 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: 1. Using `List` is because the `JobGraph.classpaths` is using the `List`. So I prefer to keep it. 2. I think it might be not a good way to depend on a specific classpath order. If there is some requirements for the classpath order I think we can do it at that time. And I also think this is not a suitable place for it because there might be other user classpaths except for the local files. for example the remote URLs and blob files. ---------------------------------------------------------------- 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