private void updateState ( FSEditLogOp op , boolean checkTxnId ) throws IOException { InjectionHandler . processEvent ( InjectionEvent . SERVERLOGREADER_UPDATE , op ) ; if ( checkTxnId ) { mostRecentlyReadTransactionTxId = ServerLogReaderUtil . checkTransactionId ( mostRecentlyReadTransactionTxId , op ) ; } updateStreamPosition ( ) ; // read a valid operation core . getMetrics ( ) . readOperations . inc ( ) ; mostRecentlyReadTransactionTime = now ( ) ; // current log segment ends normally if ( op . opCode == FSEditLogOpCodes . OP_END_LOG_SEGMENT ) { LOG . info ( "Segment - ending log segment start txid: " + currentSegmentTxId + ", end txid: " + op . getTransactionId ( ) ) ; // move forward with next segment currentSegmentTxId = op . getTransactionId ( ) + 1 ; // set the stream to null so the next getNotification() // will recreate it currentEditLogInputStream = null ; // indicate that a new stream will be opened currentEditLogInputStreamPosition = - 1 ; } else if ( op . opCode == FSEditLogOpCodes . OP_START_LOG_SEGMENT ) { LOG . info ( "Segment - starting log segment start txid: " + currentSegmentTxId ) ; } }
For each operation read from the stream check if this is a closing transaction . If so we are sure we need to move to the next segment .