YARN-410. Fixed RM UI so that the new lines diagnostics for a failed app on the per-application page are translated to html line breaks. Contributed by Omkar Vinit Joshi.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1451808 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0b708ab75d
commit
6680ee5f5d
@ -28,6 +28,10 @@ Release 2.0.4-beta - UNRELEASED
|
||||
YARN-380. Fix yarn node -status output to be better readable. (Omkar Vinit
|
||||
Joshi via vinodkv)
|
||||
|
||||
YARN-410. Fixed RM UI so that the new lines diagnostics for a failed app on
|
||||
the per-application page are translated to html line breaks. (Omkar Vinit
|
||||
Joshi via vinodkv)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
BUG FIXES
|
||||
|
@ -20,7 +20,11 @@
|
||||
|
||||
import org.apache.hadoop.yarn.webapp.ResponseInfo;
|
||||
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
|
||||
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.*;
|
||||
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
|
||||
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
|
||||
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TD;
|
||||
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TR;
|
||||
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@ -47,7 +51,19 @@ public class InfoBlock extends HtmlBlock {
|
||||
String value = String.valueOf(item.value);
|
||||
if (item.url == null) {
|
||||
if (!item.isRaw) {
|
||||
tr.td(value);
|
||||
TD<TR<TABLE<DIV<Hamlet>>>> td = tr.td();
|
||||
if ( value.lastIndexOf('\n') > 0) {
|
||||
String []lines = value.split("\n");
|
||||
DIV<TD<TR<TABLE<DIV<Hamlet>>>>> singleLineDiv;
|
||||
for ( String line :lines) {
|
||||
singleLineDiv = td.div();
|
||||
singleLineDiv._r(line);
|
||||
singleLineDiv._();
|
||||
}
|
||||
} else {
|
||||
td._r(value);
|
||||
}
|
||||
td._();
|
||||
} else {
|
||||
tr.td()._r(value)._();
|
||||
}
|
||||
|
@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.yarn.webapp.view;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.apache.hadoop.yarn.webapp.ResponseInfo;
|
||||
import org.apache.hadoop.yarn.webapp.test.WebAppTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestInfoBlock {
|
||||
|
||||
public static StringWriter sw;
|
||||
|
||||
public static PrintWriter pw;
|
||||
|
||||
public static class MultilineInfoBlock extends InfoBlock{
|
||||
|
||||
static ResponseInfo resInfo;
|
||||
|
||||
static {
|
||||
resInfo = new ResponseInfo();
|
||||
resInfo._("Single_line_value", "This is one line.");
|
||||
resInfo._("Multiple_line_value", "This is first line.\nThis is second line.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintWriter writer() {
|
||||
return TestInfoBlock.pw;
|
||||
}
|
||||
|
||||
MultilineInfoBlock(ResponseInfo info) {
|
||||
super(resInfo);
|
||||
}
|
||||
|
||||
public MultilineInfoBlock() {
|
||||
super(resInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
sw = new StringWriter();
|
||||
pw = new PrintWriter(sw);
|
||||
}
|
||||
|
||||
@Test(timeout=60000L)
|
||||
public void testMultilineInfoBlock() throws Exception{
|
||||
|
||||
WebAppTests.testBlock(MultilineInfoBlock.class);
|
||||
TestInfoBlock.pw.flush();
|
||||
String output = TestInfoBlock.sw.toString().replaceAll(" +", " ");
|
||||
String expectedSinglelineData = "<tr class=\"odd\">\n"
|
||||
+ " <th>\n Single_line_value\n <td>\n This is one line.\n";
|
||||
String expectedMultilineData = "<tr class=\"even\">\n"
|
||||
+ " <th>\n Multiple_line_value\n <td>\n <div>\n"
|
||||
+ " This is first line.\n </div>\n <div>\n"
|
||||
+ " This is second line.\n </div>\n";
|
||||
assertTrue(output.contains(expectedSinglelineData) && output.contains(expectedMultilineData));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user