private long paddingReserveLogSpace ( long spaceToReserve ) throws ObjectManagerException { if ( trace . isEntryEnabled ( ) ) trace . entry ( this , cclass , "paddingReserveLogSpace" , new Object [ ] { new Long ( spaceToReserve ) } ) ; synchronized ( paddingSpaceLock ) { // adjust the padding space paddingSpaceAvailable -= spaceToReserve ; // is this a reserve or unreserve if ( spaceToReserve > 0 ) { // space being reserved // if paddingSpaceAvailable has gone negative we should do a real reserve for the // difference. Don't let paddingSpaceAvailable go negative! // Also cut an FFDC because this should not happen! if ( paddingSpaceAvailable < 0 ) { NegativePaddingSpaceException exception = new NegativePaddingSpaceException ( this , paddingSpaceAvailable ) ; ObjectManager . ffdc . processException ( this , cclass , "paddingReserveLogSpace" , exception , "1:1088:1.52" ) ; spaceToReserve = - paddingSpaceAvailable ; paddingSpaceAvailable = 0 ; } else { // success case - we don't need to reserve any more spaceToReserve = 0 ; } } else { // its an unreserve. if ( paddingSpaceAvailable > PADDING_SPACE_TARGET ) { // space being unreserved and we have exceeded our target so need to give some back spaceToReserve = PADDING_SPACE_TARGET - paddingSpaceAvailable ; paddingSpaceAvailable = PADDING_SPACE_TARGET ; } else { // space being unreserved and we will keep it all spaceToReserve = 0 ; } } } // drop lock before giving back any space if ( spaceToReserve != 0 ) { // this can throw ObjectManagerException, only if spaceToReserve is positive. // This is good, because not only should spaceToReserve never be positive, // we must stop now because we are about to write into space that we don't have. reserve ( spaceToReserve ) ; } if ( trace . isEntryEnabled ( ) ) trace . exit ( this , cclass , "paddingReserveLogSpace" , new Object [ ] { new Long ( spaceToReserve ) } ) ; return spaceToReserve ; }
Reserve or unreserve log space but keep back an amount used for padding . This method is used to ensure there is always enough padding space by keeping back space returned by add delete and replace operations committing or backing out which was reserved up front . This never fails . It gives space even if not available .