HDFS-5051. nn fails to download checkpointed image from snn in some setups. Contributed by Vinay and Suresh Srinivas.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1514110 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2013-08-15 00:45:48 +00:00
parent 49a892056d
commit b32ace11f1
2 changed files with 17 additions and 6 deletions

View File

@ -315,6 +315,9 @@ Release 2.1.1-beta - UNRELEASED
HDFS-5091. Support for spnego keytab separate from the JournalNode keytab HDFS-5091. Support for spnego keytab separate from the JournalNode keytab
for secure HA. (jing9) for secure HA. (jing9)
HDFS-5051. nn fails to download checkpointed image from snn in some
setups. (Vinay and suresh via suresh)
Release 2.1.0-beta - 2013-08-06 Release 2.1.0-beta - 2013-08-06
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -310,11 +310,14 @@ public class GetImageServlet extends HttpServlet {
static String getParamStringToPutImage(long txid, static String getParamStringToPutImage(long txid,
InetSocketAddress imageListenAddress, Storage storage) { InetSocketAddress imageListenAddress, Storage storage) {
String machine = !imageListenAddress.isUnresolved()
&& imageListenAddress.getAddress().isAnyLocalAddress() ? null
: imageListenAddress.getHostName();
return "putimage=1" + return "putimage=1" +
"&" + TXID_PARAM + "=" + txid + "&" + TXID_PARAM + "=" + txid +
"&port=" + imageListenAddress.getPort() + "&port=" + imageListenAddress.getPort() +
"&" + STORAGEINFO_PARAM + "=" + (machine != null ? "&machine=" + machine : "")
+ "&" + STORAGEINFO_PARAM + "=" +
storage.toColonSeparatedString(); storage.toColonSeparatedString();
} }
@ -341,10 +344,6 @@ public class GetImageServlet extends HttpServlet {
Map<String, String[]> pmap = request.getParameterMap(); Map<String, String[]> pmap = request.getParameterMap();
isGetImage = isGetEdit = isPutImage = fetchLatest = false; isGetImage = isGetEdit = isPutImage = fetchLatest = false;
remoteport = 0; remoteport = 0;
machineName = request.getRemoteHost();
if (InetAddresses.isInetAddress(machineName)) {
machineName = NetUtils.getHostNameOfIP(machineName);
}
for (Map.Entry<String, String[]> entry : pmap.entrySet()) { for (Map.Entry<String, String[]> entry : pmap.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
@ -369,11 +368,20 @@ public class GetImageServlet extends HttpServlet {
txId = ServletUtil.parseLongParam(request, TXID_PARAM); txId = ServletUtil.parseLongParam(request, TXID_PARAM);
} else if (key.equals("port")) { } else if (key.equals("port")) {
remoteport = new Integer(val[0]).intValue(); remoteport = new Integer(val[0]).intValue();
} else if (key.equals("machine")) {
machineName = val[0];
} else if (key.equals(STORAGEINFO_PARAM)) { } else if (key.equals(STORAGEINFO_PARAM)) {
storageInfoString = val[0]; storageInfoString = val[0];
} }
} }
if (machineName == null) {
machineName = request.getRemoteHost();
if (InetAddresses.isInetAddress(machineName)) {
machineName = NetUtils.getHostNameOfIP(machineName);
}
}
int numGets = (isGetImage?1:0) + (isGetEdit?1:0); int numGets = (isGetImage?1:0) + (isGetEdit?1:0);
if ((numGets > 1) || (numGets == 0) && !isPutImage) { if ((numGets > 1) || (numGets == 0) && !isPutImage) {
throw new IOException("Illegal parameters to TransferFsImage"); throw new IOException("Illegal parameters to TransferFsImage");