public static boolean unblock ( final UnsafeBuffer [ ] termBuffers , final UnsafeBuffer logMetaDataBuffer , final long blockedPosition , final int termLength ) { final int positionBitsToShift = LogBufferDescriptor . positionBitsToShift ( termLength ) ; final int blockedTermCount = ( int ) ( blockedPosition >> positionBitsToShift ) ; final int blockedOffset = ( int ) blockedPosition & ( termLength - 1 ) ; final int activeTermCount = activeTermCount ( logMetaDataBuffer ) ; if ( activeTermCount == ( blockedTermCount - 1 ) && blockedOffset == 0 ) { final int currentTermId = termId ( rawTailVolatile ( logMetaDataBuffer , indexByTermCount ( activeTermCount ) ) ) ; return rotateLog ( logMetaDataBuffer , activeTermCount , currentTermId ) ; } final int blockedIndex = indexByTermCount ( blockedTermCount ) ; final long rawTail = rawTailVolatile ( logMetaDataBuffer , blockedIndex ) ; final int termId = termId ( rawTail ) ; final int tailOffset = termOffset ( rawTail , termLength ) ; final UnsafeBuffer termBuffer = termBuffers [ blockedIndex ] ; switch ( TermUnblocker . unblock ( logMetaDataBuffer , termBuffer , blockedOffset , tailOffset , termId ) ) { case UNBLOCKED_TO_END : rotateLog ( logMetaDataBuffer , blockedTermCount , termId ) ; // fall through case UNBLOCKED : return true ; } return false ; }
Attempt to unblock a log buffer at given position