|
@@ -197,6 +197,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ReservationUpdat
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceInfo;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceOptionInfo;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedulerInfo;
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.BulkActivitiesInfo;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedulerTypeInfo;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.StatisticsItemInfo;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ConfigVersionInfo;
|
|
@@ -242,6 +243,9 @@ public class RMWebServices extends WebServices implements RMWebServiceProtocol {
|
|
|
public static final String DEFAULT_END_TIME = "-1";
|
|
|
public static final String DEFAULT_INCLUDE_RESOURCE = "false";
|
|
|
public static final String DEFAULT_SUMMARIZE = "false";
|
|
|
+ public static final String DEFAULT_ACTIVITIES_COUNT = "10";
|
|
|
+ public static final int MAX_ACTIVITIES_COUNT = 500;
|
|
|
+ private static final String ERROR_MSG = "Not Capacity Scheduler";
|
|
|
|
|
|
@VisibleForTesting
|
|
|
boolean isCentralizedNodeLabelConfiguration = true;
|
|
@@ -697,76 +701,133 @@ public class RMWebServices extends WebServices implements RMWebServiceProtocol {
|
|
|
public ActivitiesInfo getActivities(@Context HttpServletRequest hsr,
|
|
|
@QueryParam(RMWSConsts.NODEID) String nodeId,
|
|
|
@QueryParam(RMWSConsts.GROUP_BY) String groupBy) {
|
|
|
- initForReadableEndpoints();
|
|
|
|
|
|
- YarnScheduler scheduler = rm.getRMContext().getScheduler();
|
|
|
- if (scheduler instanceof AbstractYarnScheduler) {
|
|
|
- String errMessage = "";
|
|
|
+ initForReadableEndpoints();
|
|
|
|
|
|
- AbstractYarnScheduler abstractYarnScheduler =
|
|
|
- (AbstractYarnScheduler) scheduler;
|
|
|
+ ActivitiesManager activitiesManager = getActivitiesManager();
|
|
|
+ if (null == activitiesManager) {
|
|
|
+ return new ActivitiesInfo(ERROR_MSG, nodeId);
|
|
|
+ }
|
|
|
|
|
|
- ActivitiesManager activitiesManager =
|
|
|
- abstractYarnScheduler.getActivitiesManager();
|
|
|
- if (null == activitiesManager) {
|
|
|
- errMessage = "Not Capacity Scheduler";
|
|
|
- return new ActivitiesInfo(errMessage, nodeId);
|
|
|
- }
|
|
|
+ RMWSConsts.ActivitiesGroupBy activitiesGroupBy;
|
|
|
+ try {
|
|
|
+ activitiesGroupBy = parseActivitiesGroupBy(groupBy);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ return new ActivitiesInfo(e.getMessage(), nodeId);
|
|
|
+ }
|
|
|
|
|
|
- RMWSConsts.ActivitiesGroupBy activitiesGroupBy;
|
|
|
- try {
|
|
|
- activitiesGroupBy = parseActivitiesGroupBy(groupBy);
|
|
|
- } catch (IllegalArgumentException e) {
|
|
|
- return new ActivitiesInfo(e.getMessage(), nodeId);
|
|
|
- }
|
|
|
+ AbstractYarnScheduler abstractYarnScheduler =
|
|
|
+ (AbstractYarnScheduler) rm.getRMContext().getScheduler();
|
|
|
|
|
|
- List<FiCaSchedulerNode> nodeList =
|
|
|
- abstractYarnScheduler.getNodeTracker().getAllNodes();
|
|
|
+ List<FiCaSchedulerNode> nodeList =
|
|
|
+ abstractYarnScheduler.getNodeTracker().getAllNodes();
|
|
|
|
|
|
- boolean illegalInput = false;
|
|
|
+ boolean illegalInput = false;
|
|
|
+ String errMessage = "";
|
|
|
|
|
|
- if (nodeList.size() == 0) {
|
|
|
- illegalInput = true;
|
|
|
- errMessage = "No node manager running in the cluster";
|
|
|
- } else {
|
|
|
- if (nodeId != null) {
|
|
|
- String hostName = nodeId;
|
|
|
- String portName = "";
|
|
|
- if (nodeId.contains(":")) {
|
|
|
- int index = nodeId.indexOf(":");
|
|
|
- hostName = nodeId.substring(0, index);
|
|
|
- portName = nodeId.substring(index + 1);
|
|
|
- }
|
|
|
+ if (nodeList.size() == 0) {
|
|
|
+ illegalInput = true;
|
|
|
+ errMessage = "No node manager running in the cluster";
|
|
|
+ } else {
|
|
|
+ if (nodeId != null) {
|
|
|
+ String hostName = nodeId;
|
|
|
+ String portName = "";
|
|
|
+ if (nodeId.contains(":")) {
|
|
|
+ int index = nodeId.indexOf(":");
|
|
|
+ hostName = nodeId.substring(0, index);
|
|
|
+ portName = nodeId.substring(index + 1);
|
|
|
+ }
|
|
|
|
|
|
- boolean correctNodeId = false;
|
|
|
- for (FiCaSchedulerNode node : nodeList) {
|
|
|
- if ((portName.equals("")
|
|
|
- && node.getRMNode().getHostName().equals(hostName))
|
|
|
- || (!portName.equals("")
|
|
|
- && node.getRMNode().getHostName().equals(hostName)
|
|
|
- && String.valueOf(node.getRMNode().getCommandPort())
|
|
|
- .equals(portName))) {
|
|
|
- correctNodeId = true;
|
|
|
- nodeId = node.getNodeID().toString();
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!correctNodeId) {
|
|
|
- illegalInput = true;
|
|
|
- errMessage = "Cannot find node manager with given node id";
|
|
|
+ boolean correctNodeId = false;
|
|
|
+ for (FiCaSchedulerNode node : nodeList) {
|
|
|
+ if ((portName.equals("")
|
|
|
+ && node.getRMNode().getHostName().equals(hostName))
|
|
|
+ || (!portName.equals("")
|
|
|
+ && node.getRMNode().getHostName().equals(hostName)
|
|
|
+ && String.valueOf(node.getRMNode().getCommandPort())
|
|
|
+ .equals(portName))) {
|
|
|
+ correctNodeId = true;
|
|
|
+ nodeId = node.getNodeID().toString();
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ if (!correctNodeId) {
|
|
|
+ illegalInput = true;
|
|
|
+ errMessage = "Cannot find node manager with given node id";
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (!illegalInput) {
|
|
|
- activitiesManager.recordNextNodeUpdateActivities(nodeId);
|
|
|
- return activitiesManager.getActivitiesInfo(nodeId, activitiesGroupBy);
|
|
|
- }
|
|
|
+ if (!illegalInput) {
|
|
|
+ activitiesManager.recordNextNodeUpdateActivities(nodeId);
|
|
|
+ return activitiesManager.getActivitiesInfo(nodeId, activitiesGroupBy);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Return a activities info with error message
|
|
|
+ return new ActivitiesInfo(errMessage, nodeId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GET
|
|
|
+ @Path(RMWSConsts.SCHEDULER_BULK_ACTIVITIES)
|
|
|
+ @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
|
|
|
+ MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
|
|
|
+ @Override
|
|
|
+ public BulkActivitiesInfo getBulkActivities(
|
|
|
+ @Context HttpServletRequest hsr,
|
|
|
+ @QueryParam(RMWSConsts.GROUP_BY) String groupBy,
|
|
|
+ @QueryParam(RMWSConsts.ACTIVITIES_COUNT)
|
|
|
+ @DefaultValue(DEFAULT_ACTIVITIES_COUNT) int activitiesCount)
|
|
|
+ throws InterruptedException {
|
|
|
+
|
|
|
+ initForReadableEndpoints();
|
|
|
+
|
|
|
+ ActivitiesManager activitiesManager = getActivitiesManager();
|
|
|
+ if (null == activitiesManager) {
|
|
|
+ throw new BadRequestException(ERROR_MSG);
|
|
|
+ }
|
|
|
|
|
|
- // Return a activities info with error message
|
|
|
- return new ActivitiesInfo(errMessage, nodeId);
|
|
|
+ RMWSConsts.ActivitiesGroupBy activitiesGroupBy;
|
|
|
+ try {
|
|
|
+ activitiesGroupBy = parseActivitiesGroupBy(groupBy);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ throw new BadRequestException(e.getMessage());
|
|
|
}
|
|
|
|
|
|
+ AbstractYarnScheduler abstractYarnScheduler =
|
|
|
+ (AbstractYarnScheduler) rm.getRMContext().getScheduler();
|
|
|
+
|
|
|
+ List<FiCaSchedulerNode> nodeList =
|
|
|
+ abstractYarnScheduler.getNodeTracker().getAllNodes();
|
|
|
+ if (nodeList.size() == 0) {
|
|
|
+ throw new BadRequestException(
|
|
|
+ "No node manager running in the cluster");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (activitiesCount <= 0) {
|
|
|
+ activitiesCount = Integer.parseInt(DEFAULT_ACTIVITIES_COUNT);
|
|
|
+ }
|
|
|
+ activitiesCount = Math.min(activitiesCount, MAX_ACTIVITIES_COUNT);
|
|
|
+
|
|
|
+ List<ActivitiesInfo> activitiesList = activitiesManager
|
|
|
+ .recordAndGetBulkActivitiesInfo(activitiesCount,
|
|
|
+ activitiesGroupBy);
|
|
|
+ BulkActivitiesInfo bulkActivitiesInfo = new
|
|
|
+ BulkActivitiesInfo();
|
|
|
+ bulkActivitiesInfo.addAll(activitiesList);
|
|
|
+
|
|
|
+ return bulkActivitiesInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private ActivitiesManager getActivitiesManager() {
|
|
|
+ YarnScheduler scheduler = rm.getRMContext().getScheduler();
|
|
|
+ if (scheduler instanceof AbstractYarnScheduler) {
|
|
|
+ AbstractYarnScheduler abstractYarnScheduler =
|
|
|
+ (AbstractYarnScheduler) scheduler;
|
|
|
+ ActivitiesManager activitiesManager =
|
|
|
+ abstractYarnScheduler.getActivitiesManager();
|
|
|
+ return activitiesManager;
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -788,105 +849,95 @@ public class RMWebServices extends WebServices implements RMWebServiceProtocol {
|
|
|
boolean summarize) {
|
|
|
initForReadableEndpoints();
|
|
|
|
|
|
- YarnScheduler scheduler = rm.getRMContext().getScheduler();
|
|
|
- if (scheduler instanceof AbstractYarnScheduler) {
|
|
|
- AbstractYarnScheduler abstractYarnScheduler =
|
|
|
- (AbstractYarnScheduler) scheduler;
|
|
|
+ ActivitiesManager activitiesManager = getActivitiesManager();
|
|
|
+ if (null == activitiesManager) {
|
|
|
+ return new AppActivitiesInfo(ERROR_MSG, appId);
|
|
|
+ }
|
|
|
|
|
|
- ActivitiesManager activitiesManager =
|
|
|
- abstractYarnScheduler.getActivitiesManager();
|
|
|
- if (null == activitiesManager) {
|
|
|
- String errMessage = "Not Capacity Scheduler";
|
|
|
- return new AppActivitiesInfo(errMessage, appId);
|
|
|
- }
|
|
|
+ if (appId == null) {
|
|
|
+ String errMessage = "Must provide an application Id";
|
|
|
+ return new AppActivitiesInfo(errMessage, null);
|
|
|
+ }
|
|
|
|
|
|
- if (appId == null) {
|
|
|
- String errMessage = "Must provide an application Id";
|
|
|
- return new AppActivitiesInfo(errMessage, null);
|
|
|
- }
|
|
|
+ RMWSConsts.ActivitiesGroupBy activitiesGroupBy;
|
|
|
+ try {
|
|
|
+ activitiesGroupBy = parseActivitiesGroupBy(groupBy);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ return new AppActivitiesInfo(e.getMessage(), appId);
|
|
|
+ }
|
|
|
|
|
|
- RMWSConsts.ActivitiesGroupBy activitiesGroupBy;
|
|
|
- try {
|
|
|
- activitiesGroupBy = parseActivitiesGroupBy(groupBy);
|
|
|
- } catch (IllegalArgumentException e) {
|
|
|
- return new AppActivitiesInfo(e.getMessage(), appId);
|
|
|
- }
|
|
|
+ Set<RMWSConsts.AppActivitiesRequiredAction> requiredActions;
|
|
|
+ try {
|
|
|
+ requiredActions =
|
|
|
+ parseAppActivitiesRequiredActions(getFlatSet(actions));
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ return new AppActivitiesInfo(e.getMessage(), appId);
|
|
|
+ }
|
|
|
|
|
|
- Set<RMWSConsts.AppActivitiesRequiredAction> requiredActions;
|
|
|
- try {
|
|
|
- requiredActions =
|
|
|
- parseAppActivitiesRequiredActions(getFlatSet(actions));
|
|
|
- } catch (IllegalArgumentException e) {
|
|
|
- return new AppActivitiesInfo(e.getMessage(), appId);
|
|
|
- }
|
|
|
+ Set<Integer> parsedRequestPriorities;
|
|
|
+ try {
|
|
|
+ parsedRequestPriorities = getFlatSet(requestPriorities).stream()
|
|
|
+ .map(e -> Integer.valueOf(e)).collect(Collectors.toSet());
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ return new AppActivitiesInfo("request priorities must be integers!",
|
|
|
+ appId);
|
|
|
+ }
|
|
|
+ Set<Long> parsedAllocationRequestIds;
|
|
|
+ try {
|
|
|
+ parsedAllocationRequestIds = getFlatSet(allocationRequestIds).stream()
|
|
|
+ .map(e -> Long.valueOf(e)).collect(Collectors.toSet());
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ return new AppActivitiesInfo(
|
|
|
+ "allocation request Ids must be integers!", appId);
|
|
|
+ }
|
|
|
|
|
|
- Set<Integer> parsedRequestPriorities;
|
|
|
+ int limitNum = -1;
|
|
|
+ if (limit != null) {
|
|
|
try {
|
|
|
- parsedRequestPriorities = getFlatSet(requestPriorities).stream()
|
|
|
- .map(e -> Integer.valueOf(e)).collect(Collectors.toSet());
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- return new AppActivitiesInfo("request priorities must be integers!",
|
|
|
- appId);
|
|
|
- }
|
|
|
- Set<Long> parsedAllocationRequestIds;
|
|
|
- try {
|
|
|
- parsedAllocationRequestIds = getFlatSet(allocationRequestIds).stream()
|
|
|
- .map(e -> Long.valueOf(e)).collect(Collectors.toSet());
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- return new AppActivitiesInfo(
|
|
|
- "allocation request Ids must be integers!", appId);
|
|
|
- }
|
|
|
-
|
|
|
- int limitNum = -1;
|
|
|
- if (limit != null) {
|
|
|
- try {
|
|
|
- limitNum = Integer.parseInt(limit);
|
|
|
- if (limitNum <= 0) {
|
|
|
- return new AppActivitiesInfo(
|
|
|
- "limit must be greater than 0!", appId);
|
|
|
- }
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- return new AppActivitiesInfo("limit must be integer!", appId);
|
|
|
+ limitNum = Integer.parseInt(limit);
|
|
|
+ if (limitNum <= 0) {
|
|
|
+ return new AppActivitiesInfo(
|
|
|
+ "limit must be greater than 0!", appId);
|
|
|
}
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ return new AppActivitiesInfo("limit must be integer!", appId);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- double maxTime = 3.0;
|
|
|
+ double maxTime = 3.0;
|
|
|
|
|
|
- if (time != null) {
|
|
|
- if (time.contains(".")) {
|
|
|
- maxTime = Double.parseDouble(time);
|
|
|
- } else {
|
|
|
- maxTime = Double.parseDouble(time + ".0");
|
|
|
- }
|
|
|
+ if (time != null) {
|
|
|
+ if (time.contains(".")) {
|
|
|
+ maxTime = Double.parseDouble(time);
|
|
|
+ } else {
|
|
|
+ maxTime = Double.parseDouble(time + ".0");
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- ApplicationId applicationId;
|
|
|
- try {
|
|
|
- applicationId = ApplicationId.fromString(appId);
|
|
|
- if (requiredActions
|
|
|
- .contains(RMWSConsts.AppActivitiesRequiredAction.REFRESH)) {
|
|
|
- activitiesManager
|
|
|
- .turnOnAppActivitiesRecording(applicationId, maxTime);
|
|
|
- }
|
|
|
- if (requiredActions
|
|
|
- .contains(RMWSConsts.AppActivitiesRequiredAction.GET)) {
|
|
|
- AppActivitiesInfo appActivitiesInfo = activitiesManager
|
|
|
- .getAppActivitiesInfo(applicationId, parsedRequestPriorities,
|
|
|
- parsedAllocationRequestIds, activitiesGroupBy, limitNum,
|
|
|
- summarize, maxTime);
|
|
|
- return appActivitiesInfo;
|
|
|
- }
|
|
|
- return new AppActivitiesInfo("Successfully received "
|
|
|
- + (actions.size() == 1 ? "action: " : "actions: ")
|
|
|
- + StringUtils.join(',', actions), appId);
|
|
|
- } catch (Exception e) {
|
|
|
- String errMessage = "Cannot find application with given appId";
|
|
|
- LOG.error(errMessage, e);
|
|
|
- return new AppActivitiesInfo(errMessage, appId);
|
|
|
+ ApplicationId applicationId;
|
|
|
+ try {
|
|
|
+ applicationId = ApplicationId.fromString(appId);
|
|
|
+ if (requiredActions
|
|
|
+ .contains(RMWSConsts.AppActivitiesRequiredAction.REFRESH)) {
|
|
|
+ activitiesManager
|
|
|
+ .turnOnAppActivitiesRecording(applicationId, maxTime);
|
|
|
}
|
|
|
-
|
|
|
+ if (requiredActions
|
|
|
+ .contains(RMWSConsts.AppActivitiesRequiredAction.GET)) {
|
|
|
+ AppActivitiesInfo appActivitiesInfo = activitiesManager
|
|
|
+ .getAppActivitiesInfo(applicationId, parsedRequestPriorities,
|
|
|
+ parsedAllocationRequestIds, activitiesGroupBy, limitNum,
|
|
|
+ summarize, maxTime);
|
|
|
+ return appActivitiesInfo;
|
|
|
+ }
|
|
|
+ return new AppActivitiesInfo("Successfully received "
|
|
|
+ + (actions.size() == 1 ? "action: " : "actions: ")
|
|
|
+ + StringUtils.join(',', actions), appId);
|
|
|
+ } catch (Exception e) {
|
|
|
+ String errMessage = "Cannot find application with given appId";
|
|
|
+ LOG.error(errMessage, e);
|
|
|
+ return new AppActivitiesInfo(errMessage, appId);
|
|
|
}
|
|
|
- return null;
|
|
|
}
|
|
|
|
|
|
private Set<String> getFlatSet(Set<String> set) {
|