Return-Path: X-Original-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6DF9EC902 for ; Sat, 2 Jun 2012 19:49:35 +0000 (UTC) Received: (qmail 43092 invoked by uid 500); 2 Jun 2012 19:49:35 -0000 Delivered-To: apmail-hadoop-hdfs-commits-archive@hadoop.apache.org Received: (qmail 43065 invoked by uid 500); 2 Jun 2012 19:49:35 -0000 Mailing-List: contact hdfs-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hdfs-dev@hadoop.apache.org Delivered-To: mailing list hdfs-commits@hadoop.apache.org Received: (qmail 43057 invoked by uid 99); 2 Jun 2012 19:49:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jun 2012 19:49:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jun 2012 19:49:33 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 97C692388847; Sat, 2 Jun 2012 19:49:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1345564 - in /hadoop/common/branches/branch-2/hadoop-hdfs-project: ./ hadoop-hdfs/ hadoop-hdfs/src/main/java/ hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ hadoop-hdfs/src/main/native/ hadoop-hdfs/src/main/webapps/datan... Date: Sat, 02 Jun 2012 19:49:13 -0000 To: hdfs-commits@hadoop.apache.org From: umamahesh@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120602194913.97C692388847@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: umamahesh Date: Sat Jun 2 19:49:12 2012 New Revision: 1345564 URL: http://svn.apache.org/viewvc?rev=1345564&view=rev Log: Merge r:1345563 HDFS-2025. Go Back to File View link is not working in tail.jsp. Contributed by Ashish and Sravan. Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/ (props changed) hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/ (props changed) hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/ (props changed) hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/native/ (props changed) hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/ (props changed) hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/ (props changed) hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/ (props changed) hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/hdfs/ (props changed) hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/ ------------------------------------------------------------------------------ Merged /hadoop/common/trunk/hadoop-hdfs-project:r1345563 Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/ ------------------------------------------------------------------------------ Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs:r1345563 Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1345564&r1=1345563&r2=1345564&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Sat Jun 2 19:49:12 2012 @@ -146,6 +146,8 @@ Release 2.0.1-alpha - UNRELEASED HDFS-3442. Incorrect count for Missing Replicas in FSCK report. (Andrew Wang via atm) + HDFS-2025. Go Back to File View link is not working in tail.jsp.(Ashish and Sravan via umamahesh) + Release 2.0.0-alpha - UNRELEASED INCOMPATIBLE CHANGES Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/ ------------------------------------------------------------------------------ Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java:r1345563 Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java?rev=1345564&r1=1345563&r2=1345564&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DatanodeJspHelper.java Sat Jun 2 19:49:12 2012 @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; +import java.net.URL; import java.net.URLEncoder; import java.security.PrivilegedExceptionAction; import java.text.SimpleDateFormat; @@ -616,9 +617,12 @@ public class DatanodeJspHelper { Configuration conf ) throws IOException, InterruptedException { - final String referrer = JspHelper.validateURL(req.getParameter("referrer")); + String referrer = null; boolean noLink = false; - if (referrer == null) { + try { + referrer = new URL(req.getParameter("referrer")).toString(); + } catch (IOException e) { + referrer = null; noLink = true; } Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/native/ ------------------------------------------------------------------------------ Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/native:r1345563 Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/ ------------------------------------------------------------------------------ Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode:r1345563 Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/ ------------------------------------------------------------------------------ Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs:r1345563 Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/ ------------------------------------------------------------------------------ Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary:r1345563 Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/hdfs/ ------------------------------------------------------------------------------ Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/hdfs:r1345563 Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java?rev=1345564&r1=1345563&r2=1345564&view=diff ============================================================================== --- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java (original) +++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java Sat Jun 2 19:49:12 2012 @@ -18,16 +18,20 @@ package org.apache.hadoop.hdfs.server.datanode; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.DataOutputStream; import java.io.IOException; import java.net.InetSocketAddress; import java.net.URL; import java.net.URLEncoder; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspWriter; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.DFSTestUtil; @@ -44,9 +48,10 @@ public class TestDatanodeJsp { private static final String FILE_DATA = "foo bar baz biz buz"; private static final HdfsConfiguration CONF = new HdfsConfiguration(); + private static String viewFilePage; - private static void testViewingFile(MiniDFSCluster cluster, String filePath, - boolean doTail) throws IOException { + private static void testViewingFile(MiniDFSCluster cluster, String filePath) + throws IOException { FileSystem fs = cluster.getFileSystem(); Path testPath = new Path(filePath); @@ -58,23 +63,46 @@ public class TestDatanodeJsp { InetSocketAddress nnHttpAddress = cluster.getNameNode().getHttpAddress(); int dnInfoPort = cluster.getDataNodes().get(0).getInfoPort(); - String jspName = doTail ? "tail.jsp" : "browseDirectory.jsp"; - String fileParamName = doTail ? "filename" : "dir"; + URL url = new URL("http://localhost:" + dnInfoPort + "/" + + "browseDirectory.jsp" + JspHelper.getUrlParam("dir", + URLEncoder.encode(testPath.toString(), "UTF-8"), true) + + JspHelper.getUrlParam("namenodeInfoPort", Integer + .toString(nnHttpAddress.getPort())) + JspHelper + .getUrlParam("nnaddr", "localhost:" + nnIpcAddress.getPort())); - URL url = new URL("http://localhost:" + dnInfoPort + "/" + jspName + - JspHelper.getUrlParam(fileParamName, URLEncoder.encode(testPath.toString(), "UTF-8"), true) + - JspHelper.getUrlParam("namenodeInfoPort", Integer.toString(nnHttpAddress.getPort())) + - JspHelper.getUrlParam("nnaddr", "localhost:" + nnIpcAddress.getPort())); - - String viewFilePage = DFSTestUtil.urlGet(url); + viewFilePage = StringEscapeUtils.unescapeHtml(DFSTestUtil.urlGet(url)); assertTrue("page should show preview of file contents, got: " + viewFilePage, viewFilePage.contains(FILE_DATA)); - if (!doTail) { - assertTrue("page should show link to download file", viewFilePage - .contains("/streamFile" + ServletUtil.encodePath(testPath.toString()) + - "?nnaddr=localhost:" + nnIpcAddress.getPort())); + assertTrue("page should show link to download file", viewFilePage + .contains("/streamFile" + ServletUtil.encodePath(filePath) + + "?nnaddr=localhost:" + nnIpcAddress.getPort())); + + // check whether able to tail the file + String regex = "Tail\\s*this\\s*file\\<\\/a\\>"; + assertFileContents(regex, "Tail this File"); + + // check whether able to 'Go Back to File View' after tailing the file + regex = "Go\\s*Back\\s*to\\s*File\\s*View\\<\\/a\\>"; + assertFileContents(regex, "Go Back to File View"); + } + + private static void assertFileContents(String regex, String text) + throws IOException { + Pattern compile = Pattern.compile(regex); + Matcher matcher = compile.matcher(viewFilePage); + URL hyperlink = null; + if (matcher.find()) { + // got hyperlink for Tail this file + hyperlink = new URL(matcher.group(1)); + viewFilePage = StringEscapeUtils.unescapeHtml(DFSTestUtil + .urlGet(hyperlink)); + assertTrue("page should show preview of file contents", viewFilePage + .contains(FILE_DATA)); + } else { + fail(text + " hyperlink should be there in the page content : " + + viewFilePage); } } @@ -97,8 +125,8 @@ public class TestDatanodeJsp { "/foo\">bar/foo\">bar" }; for (String p : paths) { - testViewingFile(cluster, p, false); - testViewingFile(cluster, p, true); + testViewingFile(cluster, p); + testViewingFile(cluster, p); } } finally { if (cluster != null) {