Skip to content

Commit 07d0c8e

Browse files
committed
YARN-11577. Fix CheckStyle.
1 parent d613492 commit 07d0c8e

File tree

6 files changed

+56
-13
lines changed

6 files changed

+56
-13
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public static void logAndThrowIOException(String errMsg, Throwable t)
227227
throws IOException {
228228
if (t != null) {
229229
LOG.error(errMsg, t);
230-
throw new IOException(errMsg, t);
230+
throw new IOException(errMsg + " " + t.getMessage(), t);
231231
} else {
232232
LOG.error(errMsg);
233233
throw new IOException(errMsg);
@@ -249,7 +249,7 @@ public static void logAndThrowIOException(Throwable t, String errMsgFormat, Obje
249249
String msg = String.format(errMsgFormat, args);
250250
if (t != null) {
251251
LOG.error(msg, t);
252-
throw new IOException(msg, t);
252+
throw new IOException(msg + " " + t.getMessage(), t);
253253
} else {
254254
LOG.error(msg);
255255
throw new IOException(msg);
@@ -269,7 +269,7 @@ public static void logAndThrowRunTimeException(String errMsg, Throwable t)
269269
throws RuntimeException {
270270
if (t != null) {
271271
LOG.error(errMsg, t);
272-
throw new RuntimeException(errMsg, t);
272+
throw new RuntimeException(errMsg + " " + t.getMessage(), t);
273273
} else {
274274
LOG.error(errMsg);
275275
throw new RuntimeException(errMsg);
@@ -291,7 +291,7 @@ public static void logAndThrowRunTimeException(Throwable t, String errMsgFormat,
291291
String msg = String.format(errMsgFormat, args);
292292
if (t != null) {
293293
LOG.error(msg, t);
294-
throw new RuntimeException(msg, t);
294+
throw new RuntimeException(msg + " " + t.getMessage(), t);
295295
} else {
296296
LOG.error(msg);
297297
throw new RuntimeException(msg);
@@ -313,7 +313,7 @@ public static RuntimeException logAndReturnRunTimeException(
313313
String msg = String.format(errMsgFormat, args);
314314
if (t != null) {
315315
LOG.error(msg, t);
316-
return new RuntimeException(msg, t);
316+
return new RuntimeException(msg + " " + t.getMessage(), t);
317317
} else {
318318
LOG.error(msg);
319319
return new RuntimeException(msg);
@@ -349,7 +349,7 @@ public static YarnRuntimeException logAndReturnYarnRunTimeException(
349349
String msg = String.format(errMsgFormat, args);
350350
if (t != null) {
351351
LOG.error(msg, t);
352-
return new YarnRuntimeException(msg, t);
352+
return new YarnRuntimeException(msg + " " + t.getMessage(), t);
353353
} else {
354354
LOG.error(msg);
355355
return new YarnRuntimeException(msg);

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -2942,17 +2942,19 @@ private <R> Map<SubClusterInfo, R> invokeConcurrent(Collection<SubClusterInfo> c
29422942
}
29432943

29442944
Exception exception = result.getException();
2945-
2946-
// If allowPartialResult=false, it means that if an exception occurs in a subCluster,
2947-
// an exception will be thrown directly.
2948-
if (!allowPartialResult && exception != null) {
2945+
if (exception != null) {
29492946
throw exception;
29502947
}
29512948
} catch (Throwable e) {
29522949
String subClusterId = subClusterInfo != null ?
29532950
subClusterInfo.getSubClusterId().getId() : "UNKNOWN";
29542951
LOG.error("SubCluster {} failed to {} report.", subClusterId, request.getMethodName(), e);
2955-
throw new YarnRuntimeException(e.getCause().getMessage(), e);
2952+
// If allowPartialResult=false, it means that if an exception occurs in a subCluster,
2953+
// an exception will be thrown directly.
2954+
if (!allowPartialResult) {
2955+
throw new YarnException("SubCluster " + subClusterId +
2956+
" failed to " + request.getMethodName() + " report.", e);
2957+
}
29562958
}
29572959
}
29582960

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
* main difference with AMRMProxyService is the protocol they implement.
107107
**/
108108
@Singleton
109-
@Path("/ws/v1/cluster")
109+
@Path(RMWSConsts.RM_WEB_SERVICE_PATH)
110110
public class RouterWebServices implements RMWebServiceProtocol {
111111

112112
private static final Logger LOG =

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/capacity/TestYarnFederationWithCapacityScheduler.java

+23-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ClusterInfo;
2323
import org.apache.hadoop.yarn.server.router.subcluster.TestFederationSubCluster;
2424
import org.apache.hadoop.yarn.server.router.webapp.dao.FederationClusterInfo;
25+
import org.apache.hadoop.yarn.server.router.webapp.dao.FederationClusterUserInfo;
2526
import org.junit.AfterClass;
2627
import org.junit.BeforeClass;
2728
import org.junit.Test;
@@ -31,7 +32,7 @@
3132
import java.util.Set;
3233
import java.util.concurrent.TimeoutException;
3334

34-
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.RM_WEB_SERVICE_PATH;
35+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.*;
3536
import static org.junit.Assert.assertNotNull;
3637
import static org.junit.Assert.assertEquals;
3738
import static org.junit.Assert.assertTrue;
@@ -73,4 +74,25 @@ public void testGetClusterInfo() throws InterruptedException, IOException {
7374
assertTrue(subClusters.contains(clusterInfo.getSubClusterId()));
7475
}
7576
}
77+
78+
@Test
79+
public void testInfo() throws InterruptedException, IOException {
80+
FederationClusterInfo federationClusterInfo =
81+
TestFederationSubCluster.performGetCalls(ROUTER_WEB_ADDRESS, RM_WEB_SERVICE_PATH + INFO,
82+
FederationClusterInfo.class, null, null);
83+
List<ClusterInfo> clusterInfos = federationClusterInfo.getList();
84+
assertNotNull(clusterInfos);
85+
assertEquals(2, clusterInfos.size());
86+
for (ClusterInfo clusterInfo : clusterInfos) {
87+
assertNotNull(clusterInfo);
88+
assertTrue(subClusters.contains(clusterInfo.getSubClusterId()));
89+
}
90+
}
91+
92+
@Test
93+
public void testClusterInfoXML() throws Exception {
94+
FederationClusterUserInfo federationClusterUserInfo =
95+
TestFederationSubCluster.performGetCalls(ROUTER_WEB_ADDRESS, RM_WEB_SERVICE_PATH + CLUSTER_USER_INFO,
96+
FederationClusterUserInfo.class, null, null);
97+
}
7698
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/subcluster/fair/TestYarnFederationWithFairScheduler.java

+15
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.Set;
3232
import java.util.concurrent.TimeoutException;
3333

34+
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.INFO;
3435
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWSConsts.RM_WEB_SERVICE_PATH;
3536
import static org.junit.Assert.assertNotNull;
3637
import static org.junit.Assert.assertEquals;
@@ -72,4 +73,18 @@ public void testGetClusterInfo() throws InterruptedException, IOException {
7273
assertTrue(subClusters.contains(clusterInfo.getSubClusterId()));
7374
}
7475
}
76+
77+
@Test
78+
public void testInfo() throws InterruptedException, IOException {
79+
FederationClusterInfo federationClusterInfo =
80+
TestFederationSubCluster.performGetCalls(ROUTER_WEB_ADDRESS, RM_WEB_SERVICE_PATH + INFO,
81+
FederationClusterInfo.class, null, null);
82+
List<ClusterInfo> clusterInfos = federationClusterInfo.getList();
83+
assertNotNull(clusterInfos);
84+
assertEquals(2, clusterInfos.size());
85+
for (ClusterInfo clusterInfo : clusterInfos) {
86+
assertNotNull(clusterInfo);
87+
assertTrue(subClusters.contains(clusterInfo.getSubClusterId()));
88+
}
89+
}
7590
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/resources/yarn-site.xml

+4
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@
4747
<name>yarn.resourcemanager.cluster-id</name>
4848
<value>local-cluster</value>
4949
</property>
50+
<property>
51+
<name>yarn.router.interceptor.allow-partial-result.enable</name>
52+
<value>true</value>
53+
</property>
5054
</configuration>

0 commit comments

Comments
 (0)