YARN-4417. Make RM and Timeline-server REST APIs more consistent. Contributed by Wangda Tan
(cherry picked from commit d0a22bae9b
)
This commit is contained in:
parent
ca575e6add
commit
c7cc9d6bac
|
@ -18,6 +18,9 @@ Release 2.9.0 - UNRELEASED
|
||||||
YARN-4341. add doc about timeline performance tool usage (Chang Li via
|
YARN-4341. add doc about timeline performance tool usage (Chang Li via
|
||||||
sjlee)
|
sjlee)
|
||||||
|
|
||||||
|
YARN-4417. Make RM and Timeline-server REST APIs more consistent.
|
||||||
|
(wtan via jianhe)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -169,6 +169,9 @@ import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedulerTypeInf
|
||||||
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.StatisticsItemInfo;
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.StatisticsItemInfo;
|
||||||
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
|
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
|
||||||
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
|
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
|
||||||
|
import org.apache.hadoop.yarn.server.webapp.WebServices;
|
||||||
|
import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
|
||||||
|
import org.apache.hadoop.yarn.server.webapp.dao.ContainersInfo;
|
||||||
import org.apache.hadoop.yarn.util.AdHocLogDumper;
|
import org.apache.hadoop.yarn.util.AdHocLogDumper;
|
||||||
import org.apache.hadoop.yarn.util.ConverterUtils;
|
import org.apache.hadoop.yarn.util.ConverterUtils;
|
||||||
import org.apache.hadoop.yarn.webapp.BadRequestException;
|
import org.apache.hadoop.yarn.webapp.BadRequestException;
|
||||||
|
@ -182,7 +185,7 @@ import com.google.inject.Singleton;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Path("/ws/v1/cluster")
|
@Path("/ws/v1/cluster")
|
||||||
public class RMWebServices {
|
public class RMWebServices extends WebServices {
|
||||||
private static final Log LOG =
|
private static final Log LOG =
|
||||||
LogFactory.getLog(RMWebServices.class.getName());
|
LogFactory.getLog(RMWebServices.class.getName());
|
||||||
private static final String EMPTY = "";
|
private static final String EMPTY = "";
|
||||||
|
@ -201,6 +204,7 @@ public class RMWebServices {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public RMWebServices(final ResourceManager rm, Configuration conf) {
|
public RMWebServices(final ResourceManager rm, Configuration conf) {
|
||||||
|
super(rm.getClientRMService());
|
||||||
this.rm = rm;
|
this.rm = rm;
|
||||||
this.conf = conf;
|
this.conf = conf;
|
||||||
isCentralizedNodeLabelConfiguration =
|
isCentralizedNodeLabelConfiguration =
|
||||||
|
@ -335,8 +339,8 @@ public class RMWebServices {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<RMNode> rmNodes = RMServerUtils.queryRMNodes(this.rm.getRMContext(),
|
Collection<RMNode> rmNodes = RMServerUtils.queryRMNodes(
|
||||||
acceptedStates);
|
this.rm.getRMContext(), acceptedStates);
|
||||||
NodesInfo nodesInfo = new NodesInfo();
|
NodesInfo nodesInfo = new NodesInfo();
|
||||||
for (RMNode rmNode : rmNodes) {
|
for (RMNode rmNode : rmNodes) {
|
||||||
NodeInfo nodeInfo = new NodeInfo(rmNode, sched);
|
NodeInfo nodeInfo = new NodeInfo(rmNode, sched);
|
||||||
|
@ -617,39 +621,6 @@ public class RMWebServices {
|
||||||
return appStatInfo;
|
return appStatInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<String> parseQueries(
|
|
||||||
Set<String> queries, boolean isState) {
|
|
||||||
Set<String> params = new HashSet<String>();
|
|
||||||
if (!queries.isEmpty()) {
|
|
||||||
for (String query : queries) {
|
|
||||||
if (query != null && !query.trim().isEmpty()) {
|
|
||||||
String[] paramStrs = query.split(",");
|
|
||||||
for (String paramStr : paramStrs) {
|
|
||||||
if (paramStr != null && !paramStr.trim().isEmpty()) {
|
|
||||||
if (isState) {
|
|
||||||
try {
|
|
||||||
// enum string is in the uppercase
|
|
||||||
YarnApplicationState.valueOf(
|
|
||||||
StringUtils.toUpperCase(paramStr.trim()));
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
YarnApplicationState[] stateArray =
|
|
||||||
YarnApplicationState.values();
|
|
||||||
String allAppStates = Arrays.toString(stateArray);
|
|
||||||
throw new BadRequestException(
|
|
||||||
"Invalid application-state " + paramStr.trim()
|
|
||||||
+ " specified. It should be one of " + allAppStates);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
params.add(
|
|
||||||
StringUtils.toLowerCase(paramStr.trim()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Map<YarnApplicationState, Map<String, Long>> buildScoreboard(
|
private static Map<YarnApplicationState, Map<String, Long>> buildScoreboard(
|
||||||
Set<String> states, Set<String> types) {
|
Set<String> states, Set<String> types) {
|
||||||
Map<YarnApplicationState, Map<String, Long>> scoreboard
|
Map<YarnApplicationState, Map<String, Long>> scoreboard
|
||||||
|
@ -728,6 +699,40 @@ public class RMWebServices {
|
||||||
return appAttemptsInfo;
|
return appAttemptsInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/apps/{appid}/appattempts/{appattemptid}")
|
||||||
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
|
@Override
|
||||||
|
public org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo getAppAttempt(@Context HttpServletRequest req,
|
||||||
|
@Context HttpServletResponse res, @PathParam("appid") String appId,
|
||||||
|
@PathParam("appattemptid") String appAttemptId) {
|
||||||
|
init(res);
|
||||||
|
return super.getAppAttempt(req, res, appId, appAttemptId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/apps/{appid}/appattempts/{appattemptid}/containers")
|
||||||
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
|
@Override
|
||||||
|
public ContainersInfo getContainers(@Context HttpServletRequest req,
|
||||||
|
@Context HttpServletResponse res, @PathParam("appid") String appId,
|
||||||
|
@PathParam("appattemptid") String appAttemptId) {
|
||||||
|
init(res);
|
||||||
|
return super.getContainers(req, res, appId, appAttemptId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/apps/{appid}/appattempts/{appattemptid}/containers/{containerid}")
|
||||||
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
|
@Override
|
||||||
|
public ContainerInfo getContainer(@Context HttpServletRequest req,
|
||||||
|
@Context HttpServletResponse res, @PathParam("appid") String appId,
|
||||||
|
@PathParam("appattemptid") String appAttemptId,
|
||||||
|
@PathParam("containerid") String containerId) {
|
||||||
|
init(res);
|
||||||
|
return super.getContainer(req, res, appId, appAttemptId, containerId);
|
||||||
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/apps/{appid}/state")
|
@Path("/apps/{appid}/state")
|
||||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
|
@ -885,8 +890,7 @@ public class RMWebServices {
|
||||||
NodeId nid = ConverterUtils.toNodeIdWithDefaultPort(nodeId);
|
NodeId nid = ConverterUtils.toNodeIdWithDefaultPort(nodeId);
|
||||||
Map<NodeId, Set<String>> newLabelsForNode =
|
Map<NodeId, Set<String>> newLabelsForNode =
|
||||||
new HashMap<NodeId, Set<String>>();
|
new HashMap<NodeId, Set<String>>();
|
||||||
newLabelsForNode.put(nid,
|
newLabelsForNode.put(nid, new HashSet<String>(newNodeLabelsName));
|
||||||
new HashSet<String>(newNodeLabelsName));
|
|
||||||
|
|
||||||
return replaceLabelsOnNode(newLabelsForNode, hsr,
|
return replaceLabelsOnNode(newLabelsForNode, hsr,
|
||||||
"/nodes/nodeid/replace-labels");
|
"/nodes/nodeid/replace-labels");
|
||||||
|
|
|
@ -36,11 +36,13 @@ public class AppAttemptInfo {
|
||||||
|
|
||||||
protected int id;
|
protected int id;
|
||||||
protected long startTime;
|
protected long startTime;
|
||||||
|
protected long finishedTime;
|
||||||
protected String containerId;
|
protected String containerId;
|
||||||
protected String nodeHttpAddress;
|
protected String nodeHttpAddress;
|
||||||
protected String nodeId;
|
protected String nodeId;
|
||||||
protected String logsLink;
|
protected String logsLink;
|
||||||
protected String blacklistedNodes;
|
protected String blacklistedNodes;
|
||||||
|
protected String appAttemptId;
|
||||||
|
|
||||||
public AppAttemptInfo() {
|
public AppAttemptInfo() {
|
||||||
}
|
}
|
||||||
|
@ -56,6 +58,7 @@ public class AppAttemptInfo {
|
||||||
if (attempt != null) {
|
if (attempt != null) {
|
||||||
this.id = attempt.getAppAttemptId().getAttemptId();
|
this.id = attempt.getAppAttemptId().getAttemptId();
|
||||||
this.startTime = attempt.getStartTime();
|
this.startTime = attempt.getStartTime();
|
||||||
|
this.finishedTime = attempt.getFinishTime();
|
||||||
Container masterContainer = attempt.getMasterContainer();
|
Container masterContainer = attempt.getMasterContainer();
|
||||||
if (masterContainer != null) {
|
if (masterContainer != null) {
|
||||||
this.containerId = masterContainer.getId().toString();
|
this.containerId = masterContainer.getId().toString();
|
||||||
|
@ -75,6 +78,7 @@ public class AppAttemptInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.appAttemptId = attempt.getAppAttemptId().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +90,10 @@ public class AppAttemptInfo {
|
||||||
return this.startTime;
|
return this.startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getFinishedTime() {
|
||||||
|
return this.finishedTime;
|
||||||
|
}
|
||||||
|
|
||||||
public String getNodeHttpAddress() {
|
public String getNodeHttpAddress() {
|
||||||
return this.nodeHttpAddress;
|
return this.nodeHttpAddress;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1643,7 +1643,7 @@ public class TestRMWebServicesApps extends JerseyTestBase {
|
||||||
String user)
|
String user)
|
||||||
throws JSONException, Exception {
|
throws JSONException, Exception {
|
||||||
|
|
||||||
assertEquals("incorrect number of elements", 7, info.length());
|
assertEquals("incorrect number of elements", 9, info.length());
|
||||||
|
|
||||||
verifyAppAttemptInfoGeneric(appAttempt, info.getInt("id"),
|
verifyAppAttemptInfoGeneric(appAttempt, info.getInt("id"),
|
||||||
info.getLong("startTime"), info.getString("containerId"),
|
info.getLong("startTime"), info.getString("containerId"),
|
||||||
|
|
Loading…
Reference in New Issue