Index: hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java (revision 1345441) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java (working copy) @@ -385,7 +385,7 @@ public HLog(final FileSystem fs, final Path dir, final Path oldLogDir, final Configuration conf, final List listeners, final boolean failIfLogDirExists, final String prefix) - throws IOException { + throws IOException { super(); this.fs = fs; this.dir = dir; @@ -396,7 +396,7 @@ } } 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); @@ -443,6 +443,34 @@ 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 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 os stream.