You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by nk...@apache.org on 2014/05/14 18:59:32 UTC

svn commit: r1594640 - /hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java

Author: nkeywal
Date: Wed May 14 16:59:31 2014
New Revision: 1594640

URL: http://svn.apache.org/r1594640
Log:
HBASE-11098 Improve documentation around our blockcache options - addendum

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java?rev=1594640&r1=1594639&r2=1594640&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java Wed May 14 16:59:31 2014
@@ -33,29 +33,29 @@ import org.apache.hadoop.util.StringUtil
  */
 @InterfaceAudience.Private
 public class FileIOEngine implements IOEngine {
-  static final Log LOG = LogFactory.getLog(FileIOEngine.class);
-
-  private FileChannel fileChannel = null;
+  private static final Log LOG = LogFactory.getLog(FileIOEngine.class);
+  private final RandomAccessFile raf;
+  private final FileChannel fileChannel;
 
   public FileIOEngine(String filePath, long fileSize) throws IOException {
-    RandomAccessFile raf = null;
     try {
       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) {
       LOG.error("Can't create bucket cache file " + filePath, fex);
       throw fex;
+    }
+
+    try {
+      raf.setLength(fileSize);
     } catch (IOException ioex) {
       LOG.error("Can't extend bucket cache file; insufficient space for "
           + StringUtils.byteDesc(fileSize), ioex);
-      if (raf != null) raf.close();
+      raf.close();
       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 IOE
     } catch (IOException ex) {
       LOG.error("Can't shutdown cleanly", ex);
     }
+    try {
+      raf.close();
+    } catch (IOException ex) {
+      LOG.error("Can't shutdown cleanly", ex);
+    }
   }
 }