HBASE-11098 Improve documentation around our blockcache options - addendum

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1594640 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
nkeywal 2014-05-14 16:59:31 +00:00
parent 6b1c419445
commit 19f6522e10
1 changed files with 16 additions and 11 deletions

View File

@ -33,29 +33,29 @@ import org.apache.hadoop.util.StringUtils;
*/ */
@InterfaceAudience.Private @InterfaceAudience.Private
public class FileIOEngine implements IOEngine { public class FileIOEngine implements IOEngine {
static final Log LOG = LogFactory.getLog(FileIOEngine.class); private static final Log LOG = LogFactory.getLog(FileIOEngine.class);
private final RandomAccessFile raf;
private FileChannel fileChannel = null; private final FileChannel fileChannel;
public FileIOEngine(String filePath, long fileSize) throws IOException { public FileIOEngine(String filePath, long fileSize) throws IOException {
RandomAccessFile raf = null;
try { try {
raf = new RandomAccessFile(filePath, "rw"); raf = new RandomAccessFile(filePath, "rw");
raf.setLength(fileSize);
fileChannel = raf.getChannel();
LOG.info("Allocating " + StringUtils.byteDesc(fileSize)
+ ", on the path:" + filePath);
} catch (java.io.FileNotFoundException fex) { } catch (java.io.FileNotFoundException fex) {
LOG.error("Can't create bucket cache file " + filePath, fex); LOG.error("Can't create bucket cache file " + filePath, fex);
throw fex; throw fex;
}
try {
raf.setLength(fileSize);
} catch (IOException ioex) { } catch (IOException ioex) {
LOG.error("Can't extend bucket cache file; insufficient space for " LOG.error("Can't extend bucket cache file; insufficient space for "
+ StringUtils.byteDesc(fileSize), ioex); + StringUtils.byteDesc(fileSize), ioex);
if (raf != null) raf.close(); raf.close();
throw ioex; throw ioex;
} finally {
if (raf != null) raf.close();
} }
fileChannel = raf.getChannel();
LOG.info("Allocating " + StringUtils.byteDesc(fileSize) + ", on the path:" + filePath);
} }
/** /**
@ -109,5 +109,10 @@ public class FileIOEngine implements IOEngine {
} catch (IOException ex) { } catch (IOException ex) {
LOG.error("Can't shutdown cleanly", ex); LOG.error("Can't shutdown cleanly", ex);
} }
try {
raf.close();
} catch (IOException ex) {
LOG.error("Can't shutdown cleanly", ex);
}
} }
} }