HBASE-20839 Fallback to FSHLog if we can not instantiated AsyncFSWAL when user does not specify AsyncFSWAL explicitly
This commit is contained in:
parent
c612642b2b
commit
5ef9d8f451
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
|
|
@ -22,6 +22,9 @@ import java.io.IOException;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
|
import org.apache.hadoop.hbase.io.asyncfs.FanOutOneBlockAsyncDFSOutput;
|
||||||
|
import org.apache.hadoop.hbase.io.asyncfs.FanOutOneBlockAsyncDFSOutputHelper;
|
||||||
|
import org.apache.hadoop.hbase.io.asyncfs.FanOutOneBlockAsyncDFSOutputSaslHelper;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.AsyncFSWAL;
|
import org.apache.hadoop.hbase.regionserver.wal.AsyncFSWAL;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.AsyncProtobufLogWriter;
|
import org.apache.hadoop.hbase.regionserver.wal.AsyncProtobufLogWriter;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.WALUtil;
|
import org.apache.hadoop.hbase.regionserver.wal.WALUtil;
|
||||||
|
@ -123,4 +126,18 @@ public class AsyncFSWALProvider extends AbstractFSWALProvider<AsyncFSWAL> {
|
||||||
throw new IOException("cannot get log writer", e);
|
throw new IOException("cannot get log writer", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether we can load the helper classes for async dfs output.
|
||||||
|
*/
|
||||||
|
public static boolean load() {
|
||||||
|
try {
|
||||||
|
Class.forName(FanOutOneBlockAsyncDFSOutput.class.getName());
|
||||||
|
Class.forName(FanOutOneBlockAsyncDFSOutputHelper.class.getName());
|
||||||
|
Class.forName(FanOutOneBlockAsyncDFSOutputSaslHelper.class.getName());
|
||||||
|
return true;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,19 @@ public class WALFactory {
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public Class<? extends WALProvider> getProviderClass(String key, String defaultValue) {
|
public Class<? extends WALProvider> getProviderClass(String key, String defaultValue) {
|
||||||
try {
|
try {
|
||||||
return Providers.valueOf(conf.get(key, defaultValue)).clazz;
|
Providers provider = Providers.valueOf(conf.get(key, defaultValue));
|
||||||
|
if (provider != Providers.defaultProvider) {
|
||||||
|
// User gives a wal provider explicitly, just use that one
|
||||||
|
return provider.clazz;
|
||||||
|
}
|
||||||
|
// AsyncFSWAL has better performance in most cases, and also uses less resources, we will try
|
||||||
|
// to use it if possible. But it deeply hacks into the internal of DFSClient so will be easily
|
||||||
|
// broken when upgrading hadoop. If it is broken, then we fall back to use FSHLog.
|
||||||
|
if (AsyncFSWALProvider.load()) {
|
||||||
|
return AsyncFSWALProvider.class;
|
||||||
|
} else {
|
||||||
|
return FSHLogProvider.class;
|
||||||
|
}
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
// Fall back to them specifying a class name
|
// Fall back to them specifying a class name
|
||||||
// Note that the passed default class shouldn't actually be used, since the above only fails
|
// Note that the passed default class shouldn't actually be used, since the above only fails
|
||||||
|
|
Loading…
Reference in New Issue