HBASE-6067 HBase won't start when hbase.rootdir uses ViewFileSystem
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1345727 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
181d2ea889
commit
968479a34d
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue