MAPREDUCE-7133. History Server task attempts REST API returns invalid data. Contributed by Oleksandr Shevchenko
(cherry picked from commit 2886024ac3
)
This commit is contained in:
parent
1314dc2397
commit
f918e4d894
|
@ -19,12 +19,10 @@ package org.apache.hadoop.mapreduce.v2.app.webapp.dao;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlElementRef;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
@XmlRootElement(name = "taskAttempts")
|
@XmlRootElement(name = "taskAttempts")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
|
||||||
public class TaskAttemptsInfo {
|
public class TaskAttemptsInfo {
|
||||||
|
|
||||||
protected ArrayList<TaskAttemptInfo> taskAttempt = new ArrayList<TaskAttemptInfo>();
|
protected ArrayList<TaskAttemptInfo> taskAttempt = new ArrayList<TaskAttemptInfo>();
|
||||||
|
@ -36,6 +34,10 @@ public class TaskAttemptsInfo {
|
||||||
taskAttempt.add(taskattemptInfo);
|
taskAttempt.add(taskattemptInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XmlElementRef annotation should be used to identify the exact type of a list element
|
||||||
|
// otherwise metadata will be added to XML attributes,
|
||||||
|
// it can lead to incorrect JSON marshaling
|
||||||
|
@XmlElementRef
|
||||||
public ArrayList<TaskAttemptInfo> getTaskAttempts() {
|
public ArrayList<TaskAttemptInfo> getTaskAttempts() {
|
||||||
return taskAttempt;
|
return taskAttempt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.mapreduce.v2.app.webapp;
|
||||||
|
|
||||||
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
|
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
@ -483,6 +484,8 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
||||||
Boolean found = false;
|
Boolean found = false;
|
||||||
for (int i = 0; i < nodes.getLength(); i++) {
|
for (int i = 0; i < nodes.getLength(); i++) {
|
||||||
Element element = (Element) nodes.item(i);
|
Element element = (Element) nodes.item(i);
|
||||||
|
assertFalse("task attempt should not contain any attributes, it can lead to incorrect JSON marshaling",
|
||||||
|
element.hasAttributes());
|
||||||
|
|
||||||
if (attid.matches(WebServicesTestUtils.getXmlString(element, "id"))) {
|
if (attid.matches(WebServicesTestUtils.getXmlString(element, "id"))) {
|
||||||
found = true;
|
found = true;
|
||||||
|
|
|
@ -1875,7 +1875,7 @@ Response Body:
|
||||||
|
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<taskAttempts>
|
<taskAttempts>
|
||||||
<taskAttempt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="reduceTaskAttemptInfo">
|
<taskAttempt>
|
||||||
<startTime>1326238777460</startTime>
|
<startTime>1326238777460</startTime>
|
||||||
<finishTime>0</finishTime>
|
<finishTime>0</finishTime>
|
||||||
<elapsedTime>0</elapsedTime>
|
<elapsedTime>0</elapsedTime>
|
||||||
|
|
Loading…
Reference in New Issue