1 8 9 package com.sleepycat.je.log; 10 11 import java.io.IOException ; 12 import java.io.RandomAccessFile ; 13 14 import com.sleepycat.je.DatabaseException; 15 import com.sleepycat.je.dbi.EnvironmentImpl; 16 import com.sleepycat.je.latch.Latch; 17 import com.sleepycat.je.latch.LatchSupport; 18 19 22 class FileHandle { 23 private RandomAccessFile file; 24 private Latch fileLatch; 25 private boolean oldHeaderVersion; 26 27 FileHandle(RandomAccessFile file, 28 String fileName, 29 EnvironmentImpl env, 30 boolean oldHeaderVersion) { 31 this.file = file; 32 this.oldHeaderVersion = oldHeaderVersion; 33 fileLatch = LatchSupport.makeLatch(fileName + "_fileHandle", env); 34 } 35 36 RandomAccessFile getFile() { 37 return file; 38 } 39 40 boolean isOldHeaderVersion() { 41 return oldHeaderVersion; 42 } 43 44 void latch() 45 throws DatabaseException { 46 47 fileLatch.acquire(); 48 } 49 50 boolean latchNoWait() 51 throws DatabaseException { 52 53 return fileLatch.acquireNoWait(); 54 } 55 56 void release() 57 throws DatabaseException { 58 59 fileLatch.release(); 60 } 61 62 void close() 63 throws IOException { 64 65 if (file != null) { 66 file.close(); 67 file = null; 68 } 69 } 70 } 71 | Popular Tags |