private synchronized Path getWritePath ( ) throws IOException { if ( pathToWriteTo == null ) { // If we have not yet written before, check existence of files. final boolean originalExists = fileSystem . exists ( changeLogPath ) ; final boolean altExists = fileSystem . exists ( changeLogAltPath ) ; if ( originalExists && altExists ) { final FileStatus originalStatus = fileSystem . getFileStatus ( changeLogPath ) ; final FileStatus altStatus = fileSystem . getFileStatus ( changeLogAltPath ) ; // Return the shorter file. // TODO[JIRA REEF-1413]: This approach will not be able to work in REEF-1413. // TODO[JIRA REEF-1413]: Note that we cannot use last modified time because Azure blob's HDFS API only // TODO[JIRA REEF-1413]: supports time resolution up to a second. final long originalLen = originalStatus . getLen ( ) ; final long altLen = altStatus . getLen ( ) ; if ( originalLen < altLen ) { pathToWriteTo = changeLogPath ; } else { pathToWriteTo = changeLogAltPath ; } } else if ( originalExists ) { // Return the file that does not exist. pathToWriteTo = changeLogAltPath ; } else { pathToWriteTo = changeLogPath ; } } final Path returnPath = pathToWriteTo ; pathToWriteTo = getAlternativePath ( pathToWriteTo ) ; return returnPath ; }
Gets the path to write to .