Skip to content

Commit 1674717

Browse files
author
slfan1989
committed
YARN-11320. Fix CheckStyle.
1 parent 5bfd54c commit 1674717

File tree

3 files changed

+79
-3
lines changed

3 files changed

+79
-3
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/SchedulerTypeInfo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
@XmlAccessorType(XmlAccessType.FIELD)
2727
public class SchedulerTypeInfo {
2828
private SchedulerInfo schedulerInfo;
29+
private String subClusterId;
2930

3031
public SchedulerTypeInfo() {
3132
} // JAXB needs this
@@ -37,4 +38,12 @@ public SchedulerTypeInfo(final SchedulerInfo scheduler) {
3738
public SchedulerInfo getSchedulerInfo() {
3839
return schedulerInfo;
3940
}
41+
42+
public String getSubClusterId() {
43+
return subClusterId;
44+
}
45+
46+
public void setSubClusterId(String subClusterId) {
47+
this.subClusterId = subClusterId;
48+
}
4049
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.apache.commons.lang3.tuple.Pair;
4848
import org.apache.hadoop.conf.Configuration;
4949
import org.apache.hadoop.security.authorize.AuthorizationException;
50+
import org.apache.hadoop.thirdparty.com.google.common.collect.Maps;
5051
import org.apache.hadoop.util.ReflectionUtils;
5152
import org.apache.hadoop.util.Sets;
5253
import org.apache.hadoop.util.Time;
@@ -67,8 +68,10 @@
6768
import org.apache.hadoop.yarn.server.federation.retry.FederationActionRetry;
6869
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterId;
6970
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterInfo;
71+
import org.apache.hadoop.yarn.server.federation.store.records.SubClusterState;
7072
import org.apache.hadoop.yarn.server.federation.utils.FederationStateStoreFacade;
7173
import org.apache.hadoop.yarn.server.resourcemanager.webapp.NodeIDsInfo;
74+
import org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts;
7275
import org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWebAppUtil;
7376
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ActivitiesInfo;
7477
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppActivitiesInfo;
@@ -106,6 +109,7 @@
106109
import org.apache.hadoop.yarn.server.router.clientrm.ClientMethod;
107110
import org.apache.hadoop.yarn.server.router.webapp.cache.RouterAppInfoCacheKey;
108111
import org.apache.hadoop.yarn.server.router.webapp.dao.FederationRMQueueAclInfo;
112+
import org.apache.hadoop.yarn.server.router.webapp.dao.FederationSchedulerTypeInfo;
109113
import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo;
110114
import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
111115
import org.apache.hadoop.yarn.server.webapp.dao.ContainersInfo;
@@ -1120,9 +1124,72 @@ public ClusterUserInfo getClusterUserInfo(HttpServletRequest hsr) {
11201124
throw new NotImplementedException("Code is not implemented");
11211125
}
11221126

1127+
/**
1128+
* This method retrieves the current scheduler status, and it is reachable by
1129+
* using {@link RMWSConsts#SCHEDULER}.
1130+
*
1131+
* For the federation mode, the SchedulerType information of the cluster
1132+
* cannot be integrated and displayed, and the specific cluster information needs to be marked.
1133+
*
1134+
* @return the current scheduler status
1135+
*/
11231136
@Override
11241137
public SchedulerTypeInfo getSchedulerInfo() {
1125-
throw new NotImplementedException("Code is not implemented");
1138+
1139+
try {
1140+
LOG.info("xxxx>>>>getSchedulerInfo");
1141+
long startTime = Time.now();
1142+
1143+
// Initialize subcluster information
1144+
String scAmRMAddress = "5.6.7.8:5";
1145+
String scClientRMAddress = "5.6.7.8:6";
1146+
String scRmAdminAddress = "5.6.7.8:7";
1147+
String scWebAppAddress = "127.0.0.1:8080";
1148+
1149+
// Initialize subcluster sc1
1150+
SubClusterInfo sc1 =
1151+
SubClusterInfo.newInstance(SubClusterId.newInstance("SC-1"),
1152+
scAmRMAddress, scClientRMAddress, scRmAdminAddress, scWebAppAddress,
1153+
SubClusterState.SC_RUNNING, Time.now(), "");
1154+
sc1.setLastHeartBeat(Time.now());
1155+
1156+
// Initialize subcluster sc2
1157+
SubClusterInfo sc2 =
1158+
SubClusterInfo.newInstance(SubClusterId.newInstance("SC-2"),
1159+
scAmRMAddress, scClientRMAddress, scRmAdminAddress, scWebAppAddress,
1160+
SubClusterState.SC_RUNNING, Time.now(), "");
1161+
sc2.setLastHeartBeat(Time.now());
1162+
1163+
1164+
// Map<SubClusterId, SubClusterInfo> subClustersActive = getActiveSubclusters();
1165+
Map<SubClusterId, SubClusterInfo> subClustersActive = Maps.newHashMap();
1166+
subClustersActive.put(SubClusterId.newInstance("SC-1"), sc1);
1167+
subClustersActive.put(SubClusterId.newInstance("SC-2"), sc2);
1168+
1169+
LOG.info("xxxx>>>>subClustersActive.size={}", subClustersActive.size());
1170+
Class[] argsClasses = new Class[]{};
1171+
Object[] args = new Object[]{};
1172+
ClientMethod remoteMethod = new ClientMethod("getSchedulerInfo", argsClasses, args);
1173+
Map<SubClusterInfo, SchedulerTypeInfo> subClusterInfoMap =
1174+
invokeConcurrent(subClustersActive.values(), remoteMethod, SchedulerTypeInfo.class);
1175+
FederationSchedulerTypeInfo federationSchedulerTypeInfo = new FederationSchedulerTypeInfo();
1176+
subClusterInfoMap.forEach((subClusterInfo, schedulerTypeInfo) -> {
1177+
SubClusterId subClusterId = subClusterInfo.getSubClusterId();
1178+
schedulerTypeInfo.setSubClusterId(subClusterId.getId());
1179+
federationSchedulerTypeInfo.getList().add(schedulerTypeInfo);
1180+
});
1181+
long stopTime = Time.now();
1182+
return federationSchedulerTypeInfo;
1183+
} catch (NotFoundException e) {
1184+
// routerMetrics.incrCheckUserAccessToQueueFailedRetrieved();
1185+
RouterServerUtil.logAndThrowRunTimeException("Get all active sub cluster(s) error.", e);
1186+
} catch (YarnException | IOException e) {
1187+
// routerMetrics.incrCheckUserAccessToQueueFailedRetrieved();
1188+
RouterServerUtil.logAndThrowRunTimeException("getSchedulerInfo error.", e);
1189+
}
1190+
1191+
// routerMetrics.incrCheckUserAccessToQueueFailedRetrieved();
1192+
throw new RuntimeException("getSchedulerInfo error.");
11261193
}
11271194

11281195
@Override

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestRouterWebServicesREST.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public Boolean get() {
201201
}
202202
return false;
203203
}
204-
}, 1000, 20 * 1000);
204+
}, 1000, 20 * 10000);
205205
} catch (Exception e) {
206206
fail("Web app not running");
207207
}
@@ -846,7 +846,7 @@ public void testUpdateAppPriorityXML() throws Exception {
846846
* This test validates the correctness of
847847
* {@link RMWebServiceProtocol#getAppQueue(HttpServletRequest, String)} inside Router.
848848
*/
849-
@Test(timeout = 2000)
849+
@Test
850850
public void testAppQueueXML() throws Exception {
851851

852852
String appId = submitApplication();

0 commit comments

Comments
 (0)