You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/01/06 08:45:17 UTC

[GitHub] [flink] yuruguo commented on a change in pull request #14538: [FLINK-20681][yarn] Support remote path for shipping archives and files

yuruguo commented on a change in pull request #14538:
URL: https://github.com/apache/flink/pull/14538#discussion_r552440385



##########
File path: flink-yarn/src/main/java/org/apache/flink/yarn/YarnClusterDescriptor.java
##########
@@ -292,26 +292,39 @@ public void addShipFiles(List<File> shipFiles) {
         this.shipFiles.addAll(shipFiles);
     }
 
-    private void addShipArchives(List<File> shipArchives) {
+    private void addShipArchives(List<Path> shipArchives) {
         checkArgument(
-                isArchiveOnlyIncludedInShipArchiveFiles(shipArchives),
+                isArchiveOnlyIncludedInShipArchiveFiles(shipArchives, yarnConfiguration),
                 "Non-archive files are included.");
         this.shipArchives.addAll(shipArchives);
     }
 
-    private static boolean isArchiveOnlyIncludedInShipArchiveFiles(List<File> shipFiles) {
-        return shipFiles.stream()
-                .filter(File::isFile)
-                .map(File::getName)
-                .map(String::toLowerCase)
-                .allMatch(
-                        name ->
-                                name.endsWith(".tar.gz")
-                                        || name.endsWith(".tar")
-                                        || name.endsWith(".tgz")
-                                        || name.endsWith(".dst")
-                                        || name.endsWith(".jar")
-                                        || name.endsWith(".zip"));
+    private static boolean isArchiveOnlyIncludedInShipArchiveFiles(List<Path> shipFiles, YarnConfiguration yarnConfig) {
+        for (Path shipFile : shipFiles) {
+            try {
+                if (Utils.isRemotePath(shipFile.toString())) {
+                    final FileSystem fs = shipFile.getFileSystem(yarnConfig);
+                    final String name = shipFile.getName().toLowerCase();
+                    if (fs.isFile(shipFile) && !(name.endsWith(".tar.gz") || name.endsWith(".tar") || name.endsWith(
+                        ".tgz") || name.endsWith(".dst") || name.endsWith(".jar") || name.endsWith(".zip"))) {
+                        return false;
+                    }
+                } else {
+                    final File localFile = new File(shipFile.toUri().getPath());
+                    final String name = localFile.getName().toLowerCase();
+                    if (localFile.isFile() && !(name.endsWith(".tar.gz") || name.endsWith(".tar") || name.endsWith(
+                        ".tgz") || name.endsWith(".dst") || name.endsWith(".jar") || name.endsWith(".zip"))) {
+                        return false;
+                    }

Review comment:
       Ok, I will simplify the code.




----------------------------------------------------------------
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:
users@infra.apache.org