HBASE-10029 Proxy created by HFileSystem#createReorderingProxy() should properly close when connecting to HA namenode
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1545792 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3ddf400c2e
commit
5c3bdc9141
|
@ -47,6 +47,7 @@ import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
|||
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
||||
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
||||
import org.apache.hadoop.io.Closeable;
|
||||
import org.apache.hadoop.ipc.RPC;
|
||||
import org.apache.hadoop.util.Progressable;
|
||||
import org.apache.hadoop.util.ReflectionUtils;
|
||||
|
||||
|
@ -262,16 +263,25 @@ public class HFileSystem extends FilterFileSystem {
|
|||
new InvocationHandler() {
|
||||
public Object invoke(Object proxy, Method method,
|
||||
Object[] args) throws Throwable {
|
||||
try {
|
||||
Object res = method.invoke(cp, args);
|
||||
if (res != null && args != null && args.length == 3
|
||||
&& "getBlockLocations".equals(method.getName())
|
||||
&& res instanceof LocatedBlocks
|
||||
&& args[0] instanceof String
|
||||
&& args[0] != null) {
|
||||
lrb.reorderBlocks(conf, (LocatedBlocks) res, (String) args[0]);
|
||||
try {
|
||||
if (args.length == 0 && "close".equals(method.getName())) {
|
||||
if (cp instanceof Closeable) {
|
||||
((Closeable)cp).close();
|
||||
} else {
|
||||
RPC.stopProxy(cp);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
Object res = method.invoke(cp, args);
|
||||
if (res != null && args != null && args.length == 3
|
||||
&& "getBlockLocations".equals(method.getName())
|
||||
&& res instanceof LocatedBlocks
|
||||
&& args[0] instanceof String
|
||||
&& args[0] != null) {
|
||||
lrb.reorderBlocks(conf, (LocatedBlocks) res, (String) args[0]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
} catch (InvocationTargetException ite) {
|
||||
// We will have this for all the exception, checked on not, sent
|
||||
// by any layer, including the functional exception
|
||||
|
|
Loading…
Reference in New Issue