private void openInputStream ( File txFile ) throws IOException { int ioExceptionRetryCount = 0 , logHeaderCorruptRetryCount = 0 ; LOG . info ( "Trying to load the edit log from " + txFile . getAbsolutePath ( ) ) ; do { try { inputStream = new EditLogFileInputStream ( txFile ) ; editLogFilePosition = inputStream . getPosition ( ) ; curStreamConsumed = false ; curStreamFinished = false ; readNullAfterStreamFinished = false ; LOG . info ( "Successfully loaded the edits log from " + txFile . getAbsolutePath ( ) ) ; break ; } catch ( LogHeaderCorruptException e1 ) { if ( logHeaderCorruptRetryCount == LOG_HEADER_CORRUPT_RETRY_MAX ) { LOG . error ( "Failed to load the edit log. No retries left." , e1 ) ; throw new IOException ( "Could not load the edit log" ) ; } logHeaderCorruptRetryCount ++ ; LOG . warn ( "Failed to load the edit log. Retry " + logHeaderCorruptRetryCount + " ..." , e1 ) ; try { Thread . sleep ( ioExceptionRetryCount * LOG_HEADER_CORRUPT_BASE_SLEEP ) ; } catch ( InterruptedException e ) { throw new IOException ( e ) ; } } catch ( IOException e2 ) { if ( ioExceptionRetryCount == IO_EXCEPTION_RETRY_MAX ) { LOG . error ( "Failed to load the edit log. No retries left." , e2 ) ; throw new IOException ( "Could not load the edit log" ) ; } ioExceptionRetryCount ++ ; LOG . warn ( "Failed to load the edit log. Retry " + ioExceptionRetryCount + " ..." , e2 ) ; try { Thread . sleep ( ioExceptionRetryCount * IO_EXCEPTION_BASE_SLEEP ) ; } catch ( InterruptedException e ) { throw new IOException ( e ) ; } } } while ( true ) ; }
Tries opening the input stream .