hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1345753 - /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
Date Sun, 03 Jun 2012 20:02:55 GMT
Author: tedyu
Date: Sun Jun  3 20:02:54 2012
New Revision: 1345753

URL: http://svn.apache.org/viewvc?rev=1345753&view=rev
Log:
HBASE-6067 HBase won't start when hbase.rootdir uses ViewFileSystem

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java?rev=1345753&r1=1345752&r2=1345753&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java Sun
Jun  3 20:02:54 2012
@@ -383,7 +383,7 @@ public class HLog implements Syncable {
   public HLog(final FileSystem fs, final Path dir, final Path oldLogDir,
       final Configuration conf, final List<WALActionsListener> listeners,
       final boolean failIfLogDirExists, final String prefix)
- throws IOException {
+  throws IOException {
     super();
     this.fs = fs;
     this.dir = dir;
@@ -394,7 +394,7 @@ public class HLog implements Syncable {
       }
     }
     this.blocksize = conf.getLong("hbase.regionserver.hlog.blocksize",
-      this.fs.getDefaultBlockSize());
+        getDefaultBlockSize());
     // Roll at 95% of block size.
     float multi = conf.getFloat("hbase.regionserver.logroll.multiplier", 0.95f);
     this.logrollsize = (long)(this.blocksize * multi);
@@ -441,6 +441,34 @@ public class HLog implements Syncable {
         Thread.currentThread().getName() + ".logSyncer");
     coprocessorHost = new WALCoprocessorHost(this, conf);
   }
+  
+  // use reflection to search for getDefaultBlockSize(Path f)
+  // if the method doesn't exist, fall back to using getDefaultBlockSize()
+  private long getDefaultBlockSize() throws IOException {
+    Method m = null;
+    Class<? extends FileSystem> cls = this.fs.getClass();
+    try {
+      m = cls.getDeclaredMethod("getDefaultBlockSize",
+          new Class<?>[] { Path.class });
+      m.setAccessible(true);
+    } catch (NoSuchMethodException e) {
+      LOG.info("FileSystem doesn't support getDefaultBlockSize");
+    } catch (SecurityException e) {
+      LOG.info("Doesn't have access to getDefaultBlockSize on "
+          + "FileSystems", e);
+      m = null; // could happen on setAccessible()
+    }
+    if (null == m) {
+      return this.fs.getDefaultBlockSize();
+    } else {
+      try {
+        Object ret = m.invoke(this.fs, this.dir);
+        return ((Long)ret).longValue();
+      } catch (Exception e) {
+        throw new IOException(e);
+      }
+    }
+  }
 
   /**
    * Find the 'getNumCurrentReplicas' on the passed <code>os</code> stream.
@@ -1886,4 +1914,4 @@ public class HLog implements Syncable {
       System.exit(-1);
     }
   }
-}
\ No newline at end of file
+}



Mime
View raw message