HDFS-7008. xlator should be closed upon exit from DFSAdmin#genericRefresh(). (ozawa)

This commit is contained in:
Tsuyoshi Ozawa 2015-02-24 23:59:34 +09:00
parent b610c68d44
commit b53fd7163b
2 changed files with 27 additions and 19 deletions

View File

@ -1014,6 +1014,9 @@ Release 2.7.0 - UNRELEASED
HDFS-7805. NameNode recovery prompt should be printed on console (Surendra HDFS-7805. NameNode recovery prompt should be printed on console (Surendra
Singh Lilhore via Colin P. McCabe) Singh Lilhore via Colin P. McCabe)
HDFS-7008. xlator should be closed upon exit from DFSAdmin#genericRefresh().
(ozawa)
BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS
HDFS-7720. Quota by Storage Type API, tools and ClientNameNode HDFS-7720. Quota by Storage Type API, tools and ClientNameNode

View File

@ -1496,30 +1496,35 @@ public class DFSAdmin extends FsShell {
RPC.getProxy(xface, RPC.getProtocolVersion(xface), address, RPC.getProxy(xface, RPC.getProtocolVersion(xface), address,
ugi, conf, NetUtils.getDefaultSocketFactory(conf), 0); ugi, conf, NetUtils.getDefaultSocketFactory(conf), 0);
GenericRefreshProtocol xlator = Collection<RefreshResponse> responses = null;
new GenericRefreshProtocolClientSideTranslatorPB(proxy); try (GenericRefreshProtocolClientSideTranslatorPB xlator =
new GenericRefreshProtocolClientSideTranslatorPB(proxy);) {
// Refresh
responses = xlator.refresh(identifier, args);
// Refresh int returnCode = 0;
Collection<RefreshResponse> responses = xlator.refresh(identifier, args);
int returnCode = 0; // Print refresh responses
System.out.println("Refresh Responses:\n");
for (RefreshResponse response : responses) {
System.out.println(response.toString());
// Print refresh responses if (returnCode == 0 && response.getReturnCode() != 0) {
System.out.println("Refresh Responses:\n"); // This is the first non-zero return code, so we should return this
for (RefreshResponse response : responses) { returnCode = response.getReturnCode();
System.out.println(response.toString()); } else if (returnCode != 0 && response.getReturnCode() != 0) {
// Then now we have multiple non-zero return codes,
if (returnCode == 0 && response.getReturnCode() != 0) { // so we merge them into -1
// This is the first non-zero return code, so we should return this returnCode = - 1;
returnCode = response.getReturnCode(); }
} else if (returnCode != 0 && response.getReturnCode() != 0) { }
// Then now we have multiple non-zero return codes, return returnCode;
// so we merge them into -1 } finally {
returnCode = -1; if (responses == null) {
System.out.println("Failed to get response.\n");
return -1;
} }
} }
return returnCode;
} }
/** /**