private URI findFile ( final String filePath , final boolean upload ) { try { URI fileURI ; try { fileURI = _hadoopDefaultFS . getUri ( ) . resolve ( filePath ) ; } catch ( final Exception e ) { fileURI = null ; } if ( ( fileURI == null || ! _hadoopDefaultFS . exists ( new Path ( fileURI ) ) ) && upload ) { final File file = new File ( filePath ) ; if ( ! file . isFile ( ) ) { throw new IllegalArgumentException ( "'" + filePath + " does not exist, or is not a file" ) ; } final String fileName = file . toPath ( ) . getFileName ( ) . toString ( ) ; return _applicationDriver . copyFileToHdfs ( file , DATACLEANER_TEMP_DIR + "/" + UUID . randomUUID ( ) + fileName ) ; } return fileURI ; } catch ( final IOException e ) { throw new IllegalArgumentException ( "Path '" + filePath + "' is not a proper file path" ) ; } }
Tries to find a file on HDFS and optionally uploads it if not found .