public static EditLogInputStream getInputStream ( JournalManager jm , long txid ) throws IOException { List < EditLogInputStream > streams = new ArrayList < EditLogInputStream > ( ) ; jm . selectInputStreams ( streams , txid , true , false ) ; if ( streams . size ( ) < 1 ) { throw new IOException ( "Cannot obtain stream for txid: " + txid ) ; } Collections . sort ( streams , JournalSet . EDIT_LOG_INPUT_STREAM_COMPARATOR ) ; // we want the "oldest" available stream if ( txid == HdfsConstants . INVALID_TXID ) { return streams . get ( 0 ) ; } // we want a specific stream for ( EditLogInputStream elis : streams ) { if ( elis . getFirstTxId ( ) == txid ) { return elis ; } } // we cannot obtain the stream throw new IOException ( "Cannot obtain stream for txid: " + txid ) ; }
Get input stream from the given journal starting at txid . Does not perform validation of the streams .