hadoop-yarn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject svn commit: r1400191 - in /hadoop/common/branches/branch-0.23/hadoop-yarn-project: CHANGES.txt hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ContainerLogsPage.java
Date Fri, 19 Oct 2012 17:40:14 GMT
Author: bobby
Date: Fri Oct 19 17:40:14 2012
New Revision: 1400191

URL: http://svn.apache.org/viewvc?rev=1400191&view=rev
Log:
svn merge -c 1400189 FIXES: YARN-163. Retrieving container log via NM webapp can hang with
multibyte characters in log (jlowe via bobby)

Modified:
    hadoop/common/branches/branch-0.23/hadoop-yarn-project/CHANGES.txt
    hadoop/common/branches/branch-0.23/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ContainerLogsPage.java

Modified: hadoop/common/branches/branch-0.23/hadoop-yarn-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-yarn-project/CHANGES.txt?rev=1400191&r1=1400190&r2=1400191&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.23/hadoop-yarn-project/CHANGES.txt Fri Oct 19 17:40:14
2012
@@ -36,6 +36,9 @@ Release 0.23.5 - UNRELEASED
     YARN-131. Fix incorrect ACL properties in capacity scheduler documentation.
     (Ahmed Radwan via sseth)
 
+    YARN-163. Retrieving container log via NM webapp can hang with multibyte
+    characters in log (jlowe via bobby)
+
 Release 0.23.4 - UNRELEASED
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-0.23/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ContainerLogsPage.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.23/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ContainerLogsPage.java?rev=1400191&r1=1400190&r2=1400191&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.23/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ContainerLogsPage.java
(original)
+++ hadoop/common/branches/branch-0.23/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ContainerLogsPage.java
Fri Oct 19 17:40:14 2012
@@ -26,7 +26,7 @@ import static org.apache.hadoop.yarn.web
 import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID;
 
 import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
@@ -35,6 +35,7 @@ import java.util.Collections;
 import java.util.EnumSet;
 import java.util.List;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -52,6 +53,8 @@ import org.apache.hadoop.yarn.server.sec
 import org.apache.hadoop.yarn.util.ConverterUtils;
 import org.apache.hadoop.yarn.webapp.YarnWebParams;
 import org.apache.hadoop.yarn.webapp.SubView;
+import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
+import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.PRE;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
 
 import com.google.inject.Inject;
@@ -221,7 +224,7 @@ public class ContainerLogsPage extends N
               + ", end[" + end + "]");
           return;
         } else {
-          InputStreamReader reader = null;
+          FileInputStream logByteStream = null;
           try {
             long toRead = end - start;
             if (toRead < logFile.length()) {
@@ -232,38 +235,34 @@ public class ContainerLogsPage extends N
             }
             // TODO: Use secure IO Utils to avoid symlink attacks.
             // TODO Fix findBugs close warning along with IOUtils change
-            reader = new FileReader(logFile);
+            logByteStream = new FileInputStream(logFile);
+            IOUtils.skipFully(logByteStream, start);
+
+            InputStreamReader reader = new InputStreamReader(logByteStream);
             int bufferSize = 65536;
             char[] cbuf = new char[bufferSize];
 
-            long skipped = 0;
-            long totalSkipped = 0;
-            while (totalSkipped < start) {
-              skipped = reader.skip(start - totalSkipped);
-              totalSkipped += skipped;
-            }
-
             int len = 0;
             int currentToRead = toRead > bufferSize ? bufferSize : (int) toRead;
-            writer().write("<pre>");
+            PRE<Hamlet> pre = html.pre();
 
             while ((len = reader.read(cbuf, 0, currentToRead)) > 0
                 && toRead > 0) {
-              writer().write(cbuf, 0, len); // TODO: HTMl Quoting?
+              pre._(new String(cbuf, 0, len));
               toRead = toRead - len;
               currentToRead = toRead > bufferSize ? bufferSize : (int) toRead;
             }
 
+            pre._();
             reader.close();
-            writer().write("</pre>");
 
           } catch (IOException e) {
             html.h1("Exception reading log-file. Log file was likely aggregated. "
                 + StringUtils.stringifyException(e));
           } finally {
-            if (reader != null) {
+            if (logByteStream != null) {
               try {
-                reader.close();
+                logByteStream.close();
               } catch (IOException e) {
                 // Ignore
               }



Mime
View raw message