Fix HDFS-2235 FI test failure.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1156972 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Eli Collins 2011-08-12 05:51:50 +00:00
parent 4673ab17b0
commit 8061bb59c0
3 changed files with 14 additions and 21 deletions

View File

@ -59,7 +59,7 @@ public class FileChecksumServlets {
/** Create a redirection URL */
private URL createRedirectURL(UserGroupInformation ugi, DatanodeID host,
HttpServletRequest request, NameNode nn)
throws IOException, URISyntaxException {
throws IOException {
final String hostname = host instanceof DatanodeInfo
? ((DatanodeInfo)host).getHostName() : host.getHost();
final String scheme = request.getScheme();
@ -94,8 +94,6 @@ public class FileChecksumServlets {
try {
response.sendRedirect(
createRedirectURL(ugi, datanode, request, namenode).toString());
} catch(URISyntaxException e) {
throw new ServletException(e);
} catch (IOException e) {
response.sendError(400, e.getMessage());
}

View File

@ -48,7 +48,7 @@ public class FileDataServlet extends DfsServlet {
/** Create a redirection URL */
private URL createRedirectURL(String path, String encodedPath, HdfsFileStatus status,
UserGroupInformation ugi, ClientProtocol nnproxy, HttpServletRequest request, String dt)
throws IOException, URISyntaxException {
throws IOException {
String scheme = request.getScheme();
final LocatedBlocks blks = nnproxy.getBlockLocations(
status.getFullPath(new Path(path)).toUri().getPath(), 0, 1);
@ -121,12 +121,8 @@ public class FileDataServlet extends DfsServlet {
HdfsFileStatus info = nn.getFileInfo(path);
if (info != null && !info.isDir()) {
try {
response.sendRedirect(createRedirectURL(path, encodedPath,
info, ugi, nn, request, delegationToken).toString());
} catch (URISyntaxException e) {
response.getWriter().println(e.toString());
}
response.sendRedirect(createRedirectURL(path, encodedPath,
info, ugi, nn, request, delegationToken).toString());
} else if (info == null) {
response.sendError(400, "File not found " + path);
} else {

View File

@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hdfs.server.namenode;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
@ -30,18 +30,17 @@ import org.apache.hadoop.security.UserGroupInformation;
public aspect FileDataServletAspects {
static final Log LOG = FileDataServlet.LOG;
pointcut callCreateUri() : call (URI FileDataServlet.createUri(
String, HdfsFileStatus, UserGroupInformation, ClientProtocol,
pointcut callCreateUrl() : call (URL FileDataServlet.createRedirectURL(
String, String, HdfsFileStatus, UserGroupInformation, ClientProtocol,
HttpServletRequest, String));
/** Replace host name with "localhost" for unit test environment. */
URI around () throws URISyntaxException : callCreateUri() {
final URI original = proceed();
LOG.info("FI: original uri = " + original);
final URI replaced = new URI(original.getScheme(), original.getUserInfo(),
"localhost", original.getPort(), original.getPath(),
original.getQuery(), original.getFragment()) ;
LOG.info("FI: replaced uri = " + replaced);
URL around () throws IOException : callCreateUrl() {
final URL original = proceed();
LOG.info("FI: original url = " + original);
final URL replaced = new URL("http", "localhost", original.getPort(),
original.getPath() + '?' + original.getQuery());
LOG.info("FI: replaced url = " + replaced);
return replaced;
}
}