public void fileExtend ( int newFileSize ) throws LogAllocationException { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "fileExtend" , new Object [ ] { new Integer ( newFileSize ) , this } ) ; final int fileLength = _fileBuffer . capacity ( ) ; if ( fileLength < newFileSize ) { try { // Expand the file to the new size ensuring that its pointer // remains in its current position. int originalPosition = _fileBuffer . position ( ) ; // TODO // Tr.uncondEvent(tc, "Expanding log file to size of " + newFileSize + " bytes."); Tr . event ( tc , "Expanding log file to size of " + newFileSize + " bytes." ) ; if ( _isMapped ) { _fileBuffer = _fileChannel . map ( FileChannel . MapMode . READ_WRITE , 0 , newFileSize ) ; } else { // The file is not mapped. // Allocate a new DirectByteBuffer, copy the old ByteBuffer into the new one, // then write the new ByteBuffer to the FileChannel (automatically expanding it). if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "File is NOT mapped. Allocating new DirectByteBuffer" ) ; _fileBuffer . position ( 0 ) ; final ByteBuffer newByteBuffer = ByteBuffer . allocateDirect ( newFileSize ) ; newByteBuffer . put ( _fileBuffer ) ; newByteBuffer . position ( 0 ) ; _fileChannel . write ( newByteBuffer , 0 ) ; _fileBuffer = newByteBuffer ; } _fileBuffer . position ( originalPosition ) ; _fileSize = newFileSize ; } catch ( Exception exc ) { FFDCFilter . processException ( exc , "com.ibm.ws.recoverylog.spi.LogFileHandle.fileExtend" , "1266" , this ) ; if ( tc . isEntryEnabled ( ) ) Tr . event ( tc , "Unable to extend file " + _fileName + " to " + newFileSize + " bytes" ) ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "fileExtend" , "LogAllocationException" ) ; throw new LogAllocationException ( exc ) ; } } if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "fileExtend" ) ; }
Extend the physical log file . If newFileSize is larger than the current file size the log file will extended so that it is newFileSize kilobytes long . If newFileSize is equal to or less than the current file size the current log file will be unchanged .