hadoop-yarn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ss...@apache.org
Subject svn commit: r1375833 - in /hadoop/common/branches/branch-2.1.0-alpha/hadoop-yarn-project: ./ hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ hadoop-yarn/hadoop-yarn-server/ha...
Date Tue, 21 Aug 2012 22:34:42 GMT
Author: sseth
Date: Tue Aug 21 22:34:40 2012
New Revision: 1375833

URL: http://svn.apache.org/viewvc?rev=1375833&view=rev
Log:
merge YARN-22 from trunk. Fix ContainerLogs to work if the log-dir is specified as a URI.
(Contributed by Mayank Bansal)

Added:
    hadoop/common/branches/branch-2.1.0-alpha/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestContainerLogsPage.java
      - copied unchanged from r1375829, hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestContainerLogsPage.java
Modified:
    hadoop/common/branches/branch-2.1.0-alpha/hadoop-yarn-project/CHANGES.txt
    hadoop/common/branches/branch-2.1.0-alpha/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-2.1.0-alpha/hadoop-yarn-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1.0-alpha/hadoop-yarn-project/CHANGES.txt?rev=1375833&r1=1375832&r2=1375833&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1.0-alpha/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2.1.0-alpha/hadoop-yarn-project/CHANGES.txt Tue Aug 21 22:34:40
2012
@@ -34,6 +34,9 @@ Release 2.1.0-alpha - Unreleased 
 
     YARN-12. Fix findbugs warnings in FairScheduler. (Junping Du via acmurthy) 
 
+    YARN-22. Fix ContainerLogs to work if the log-dir is specified as a URI.
+    (Mayank Bansal via sseth)
+
 Release 0.23.3 - Unreleased 
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-2.1.0-alpha/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-2.1.0-alpha/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=1375833&r1=1375832&r2=1375833&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1.0-alpha/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-2.1.0-alpha/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/ContainerLogsPage.java
Tue Aug 21 22:34:40 2012
@@ -29,6 +29,8 @@ import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -53,6 +55,7 @@ import org.apache.hadoop.yarn.util.Conve
 import org.apache.hadoop.yarn.webapp.YarnWebParams;
 import org.apache.hadoop.yarn.webapp.SubView;
 import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
+import org.mortbay.log.Log;
 
 import com.google.inject.Inject;
 
@@ -198,12 +201,14 @@ public class ContainerLogsPage extends N
       if (!$(CONTAINER_LOG_TYPE).isEmpty()) {
         File logFile = null;
         try {
-          logFile =
-              new File(this.dirsHandler.getLogPathToRead(
-                  ContainerLaunch.getRelativeContainerLogDir(
+          URI logPathURI = new URI(this.dirsHandler.getLogPathToRead(
+              ContainerLaunch.getRelativeContainerLogDir(
                   applicationId.toString(), containerId.toString())
-                  + Path.SEPARATOR + $(CONTAINER_LOG_TYPE))
-                  .toUri().getPath());
+                  + Path.SEPARATOR + $(CONTAINER_LOG_TYPE)).toString());
+          logFile = new File(logPathURI.getPath());
+        } catch (URISyntaxException e) {
+          html.h1("Cannot find this log on the local disk.");
+          return;
         } catch (Exception e) {
           html.h1("Cannot find this log on the local disk.");
           return;
@@ -278,14 +283,16 @@ public class ContainerLogsPage extends N
         boolean foundLogFile = false;
         for (File containerLogsDir : containerLogsDirs) {
           File[] logFiles = containerLogsDir.listFiles();
-          Arrays.sort(logFiles);
-          for (File logFile : logFiles) {
-            foundLogFile = true;
-            html.p()
-                .a(url("containerlogs", $(CONTAINER_ID), $(APP_OWNER), 
-                    logFile.getName(), "?start=-4096"),
-                    logFile.getName() + " : Total file length is "
-                        + logFile.length() + " bytes.")._();
+          if (logFiles != null) {
+            Arrays.sort(logFiles);
+            for (File logFile : logFiles) {
+              foundLogFile = true;
+              html.p()
+                  .a(url("containerlogs", $(CONTAINER_ID), $(APP_OWNER),
+                      logFile.getName(), "?start=-4096"),
+                      logFile.getName() + " : Total file length is "
+                          + logFile.length() + " bytes.")._();
+            }
           }
         }
         if (!foundLogFile) {
@@ -297,13 +304,17 @@ public class ContainerLogsPage extends N
     }
 
     static List<File> getContainerLogDirs(ContainerId containerId,
-            LocalDirsHandlerService dirsHandler) {
+        LocalDirsHandlerService dirsHandler) {
       List<String> logDirs = dirsHandler.getLogDirs();
       List<File> containerLogDirs = new ArrayList<File>(logDirs.size());
       for (String logDir : logDirs) {
-        String appIdStr = 
-            ConverterUtils.toString(
-                containerId.getApplicationAttemptId().getApplicationId());
+        try {
+          logDir = new URI(logDir).getPath();
+        } catch (URISyntaxException e) {
+          Log.warn(e.getMessage());
+        }
+        String appIdStr = ConverterUtils.toString(containerId
+            .getApplicationAttemptId().getApplicationId());
         File appLogDir = new File(logDir, appIdStr);
         String containerIdStr = ConverterUtils.toString(containerId);
         containerLogDirs.add(new File(appLogDir, containerIdStr));



Mime
View raw message