hive0.11的hive server实现kerberos认证和impersonation中碰到的问题(四)

2014-11-24 08:54:12 · 作者: · 浏览: 2
d3792f06640dd0a187cf506d1
将clientUgi.doAs返回的结果保存下来,在finally环节判断如果返回值为false,也就是执行结果fail的时候可以closeAllForUGI
[java]
finally {
if (!returnCode) {
if (clientUgi != null) {
LOG.info("Start to close filesystem for clientUgi:" + clientUgi.getUserName());
try { FileSystem.closeAllForUGI(clientUgi); }
catch(IOException exception) {
LOG.error("Could not clean up file-system handles for UGI: " + clientUgi, exception);
}
}
}
}
同时在HiveServerHandler的clean方法中(即关闭一个Hive Coonection的时候)加入对于filesystem清理的逻辑
[java]
public void clean() {
if (driver != null) {
driver.close();
driver.destroy();
}
SessionState session = SessionState.get();
if (session.getTmpOutputFile() != null) {
session.getTmpOutputFile().delete();
}
pipeIn = null;
try {
LOG.info("Start to close filesystem for ugi:" + UserGroupInformation.getCurrentUser().getUserName());
ShimLoader.getHadoopShims().closeAllForUGI(UserGroupInformation.getCurrentUser());
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
修改上述代码后重新编译,之前三种case语句都能正常返回结果了,就这个问题折腾了一天,hive的bug不是一般的多啊,所以时不时会踩到坑,不过在发现问题到debug再到解决问题的过程中也学习到了很多。