You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2012/06/03 20:00:22 UTC
svn commit: r1345727 -
/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
Author: tedyu
Date: Sun Jun 3 18:00:22 2012
New Revision: 1345727
URL: http://svn.apache.org/viewvc?rev=1345727&view=rev
Log:
HBASE-6067 HBase won't start when hbase.rootdir uses ViewFileSystem
Modified:
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java?rev=1345727&r1=1345726&r2=1345727&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java Sun Jun 3 18:00:22 2012
@@ -385,7 +385,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;
@@ -396,7 +396,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);
@@ -443,6 +443,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.