Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3388#discussion_r103178916
  
    --- Diff: flink-core/src/main/java/org/apache/flink/util/FileUtils.java ---
    @@ -258,7 +261,82 @@ public static boolean deletePathIfEmpty(FileSystem 
fileSystem, Path path) throws
                        return false;
                }
        }
    -   
    +
    +   /**
    +    * Check whether the two given filesystem is the same or not
    +    *
    +    * @param srcFs
    +    * @param destFs
    +    * @return
    +    */
    +   public static boolean compareFs(FileSystem srcFs, FileSystem destFs) {
    +           URI srcUri = srcFs.getUri();
    +           URI dstUri = destFs.getUri();
    +
    +           // check schema
    +           if (srcUri.getScheme() == null) {
    +                   return false;
    +           }
    +           if (!srcUri.getScheme().equals(dstUri.getScheme())) {
    +                   return false;
    +           }
    +
    +           // check ports
    +           if (srcUri.getPort() != dstUri.getPort()) {
    +                   return false;
    +           }
    +
    +           // check ip
    +           String srcHost = srcUri.getHost();
    +           String dstHost = dstUri.getHost();
    +           if ((srcHost != null) && (dstHost != null)) {
    +                   if (!srcHost.equals(dstHost)) {
    +                           try {
    +                                   srcHost = 
InetAddress.getByName(srcHost).getCanonicalHostName();
    +                                   dstHost = 
InetAddress.getByName(dstHost).getCanonicalHostName();
    +                           } catch (UnknownHostException ue) {
    +                                   return false;
    +                           }
    +                           if (!srcHost.equals(dstHost)) {
    +                                   return false;
    +                           }
    +                   }
    +           } else if (srcHost == null && dstHost != null) {
    +                   return false;
    +           } else if (srcHost != null && dstHost == null) {
    +                   return false;
    +           }
    +           return true;
    +   }
    +
    +   /**
    +    * Check where the original file belongs to the same filesystem as the 
local dir, if not copy the remote file to
    +    * local dir. If the original File uri has a fragment, the fragment 
will be used as local file name.
    +    *
    +    * @param localDir      local directory to store remote files.
    +    * @param originalFile  original file to check
    +    * @return
    +    * @throws IOException
    --- End diff --
    
    description is missing


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to