hadoop-yarn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jl...@apache.org
Subject svn commit: r1576963 - in /hadoop/common/branches/branch-2.4/hadoop-yarn-project: ./ hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ hadoop-yarn/hadoop-yarn-server/hadoop-ya...
Date Wed, 12 Mar 2014 22:27:23 GMT
Author: jlowe
Date: Wed Mar 12 22:27:23 2014
New Revision: 1576963

URL: http://svn.apache.org/r1576963
Log:
svn merge -c 1576960 FIXES: svn merge -c 1576960 FIXES: YARN-1789. ApplicationSummary does
not escape newlines in the app name. Contributed by Tsuyoshi OZAWA

Modified:
    hadoop/common/branches/branch-2.4/hadoop-yarn-project/CHANGES.txt
    hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java
    hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java

Modified: hadoop/common/branches/branch-2.4/hadoop-yarn-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-yarn-project/CHANGES.txt?rev=1576963&r1=1576962&r2=1576963&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.4/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2.4/hadoop-yarn-project/CHANGES.txt Wed Mar 12 22:27:23
2014
@@ -417,6 +417,9 @@ Release 2.4.0 - UNRELEASED
     ATTEMPT_FINISHED event at ACCEPTED state that can happen after RM restarts.
     (Jian He via vinodkv)
 
+    YARN-1789. ApplicationSummary does not escape newlines in the app name
+    (Tsuyoshi OZAWA via jlowe)
+
 Release 2.3.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java?rev=1576963&r1=1576962&r2=1576963&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java
(original)
+++ hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java
Wed Mar 12 22:27:23 2014
@@ -116,8 +116,10 @@ public class RMAppManager implements Eve
       }
 
       <T> SummaryBuilder add(String key, T value) {
-        return _add(key, StringUtils.escapeString(String.valueOf(value),
-                    StringUtils.ESCAPE_CHAR, charsToEscape));
+        String escapedString = StringUtils.escapeString(String.valueOf(value),
+            StringUtils.ESCAPE_CHAR, charsToEscape).replaceAll("\n", "\\\\n")
+            .replaceAll("\r", "\\\\r");
+        return _add(key, escapedString);
       }
 
       SummaryBuilder add(SummaryBuilder summary) {

Modified: hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java?rev=1576963&r1=1576962&r2=1576963&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java
(original)
+++ hadoop/common/branches/branch-2.4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java
Wed Mar 12 22:27:23 2014
@@ -19,6 +19,9 @@
 package org.apache.hadoop.yarn.server.resourcemanager;
 
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppImpl;
 import static org.mockito.Matchers.isA;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
@@ -74,6 +77,7 @@ import com.google.common.collect.Maps;
  */
 
 public class TestAppManager{
+  private Log LOG = LogFactory.getLog(TestAppManager.class);
   private static RMAppEventType appEventType = RMAppEventType.KILL; 
 
   public synchronized RMAppEventType getAppEventType() {
@@ -548,6 +552,29 @@ public class TestAppManager{
     }
   }
 
+  @Test (timeout = 30000)
+  public void testEscapeApplicationSummary() {
+    RMApp app = mock(RMAppImpl.class);
+    when(app.getApplicationId()).thenReturn(
+        ApplicationId.newInstance(100L, 1));
+    when(app.getName()).thenReturn("Multiline\n\n\r\rAppName");
+    when(app.getUser()).thenReturn("Multiline\n\n\r\rUserName");
+    when(app.getQueue()).thenReturn("Multiline\n\n\r\rQueueName");
+    when(app.getState()).thenReturn(RMAppState.RUNNING);
+
+    RMAppManager.ApplicationSummary.SummaryBuilder summary =
+        new RMAppManager.ApplicationSummary().createAppSummary(app);
+    String msg = summary.toString();
+    LOG.info("summary: " + msg);
+    Assert.assertFalse(msg.contains("\n"));
+    Assert.assertFalse(msg.contains("\r"));
+
+    String escaped = "\\n\\n\\r\\r";
+    Assert.assertTrue(msg.contains("Multiline" + escaped +"AppName"));
+    Assert.assertTrue(msg.contains("Multiline" + escaped +"UserName"));
+    Assert.assertTrue(msg.contains("Multiline" + escaped +"QueueName"));
+  }
+
   private static ResourceScheduler mockResourceScheduler() {
     ResourceScheduler scheduler = mock(ResourceScheduler.class);
     when(scheduler.getMinimumResourceCapability()).thenReturn(



Mime
View raw message