Skip to content

Commit b164bd3

Browse files
author
slfan1989
committed
YARN-11326. Fix CheckStyle.
1 parent fa42bae commit b164bd3

File tree

3 files changed

+170
-20
lines changed

3 files changed

+170
-20
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/federation/FederationStateStoreClientMetrics.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ public final class FederationStateStoreClientMetrics {
6161
private MutableGaugeLong failedUpdateApplicationHomeSubClusterCount;
6262
@Metric("# of failed getApplicationHomeSubCluster count")
6363
private MutableGaugeLong failedGetApplicationHomeSubClusterCount;
64+
@Metric("# of failed getApplicationsHomeSubCluster count")
65+
private MutableGaugeLong failedGetApplicationsHomeSubClusterCount;
66+
@Metric("# of failed deleteApplicationHomeSubCluster count")
67+
private MutableGaugeLong failedDeleteApplicationHomeSubClusterCount;
68+
@Metric("# of failed addReservationHomeSubCluster count")
69+
private MutableGaugeLong failedAddReservationHomeSubClusterCount;
70+
@Metric("# of failed getReservationHomeSubCluster count")
71+
private MutableGaugeLong failedGetReservationHomeSubClusterCount;
72+
@Metric("# of failed getReservationHomeSubCluster count")
73+
private MutableGaugeLong failedGetReservationsHomeSubClusterCount;
74+
@Metric("# of failed updateReservationHomeSubCluster count")
75+
private MutableGaugeLong failedUpdateReservationHomeSubClusterCount;
76+
@Metric("# of failed deleteReservationHomeSubCluster count")
77+
private MutableGaugeLong failedDeleteReservationHomeSubClusterCount;
6478

6579

6680
/**
@@ -136,7 +150,39 @@ public void incrFailedGetApplicationHomeSubClusterCount() {
136150
failedGetApplicationHomeSubClusterCount.incr();
137151
}
138152

153+
public void incrFailedGetApplicationsHomeSubClusterCount() {
154+
failedGetApplicationsHomeSubClusterCount.incr();
155+
}
156+
157+
public void incrFailedDeleteApplicationHomeSubClusterCount() {
158+
failedDeleteApplicationHomeSubClusterCount.incr();
159+
}
160+
161+
public void incrFailedAddReservationHomeSubClusterCount() {
162+
failedAddReservationHomeSubClusterCount.incr();
163+
}
164+
165+
public void incrFailedGetReservationHomeSubClusterCount() {
166+
failedGetReservationHomeSubClusterCount.incr();
167+
}
168+
169+
public void incrFailedGetReservationsHomeSubClusterCount() {
170+
failedGetReservationsHomeSubClusterCount.incr();
171+
}
172+
173+
public void incrFailedUpdateReservationHomeSubClusterCount() {
174+
failedUpdateReservationHomeSubClusterCount.incr();
175+
}
176+
177+
public void incrFailedDeleteReservationHomeSubClusterCount() {
178+
failedDeleteReservationHomeSubClusterCount.incr();
179+
}
180+
139181
public long getFailedGetCurrentVersionCount() {
140182
return failedGetCurrentVersionCount.value();
141183
}
184+
185+
public long getFailedSetPolicyConfigurationCount() {
186+
return failedSetPolicyConfigurationCount.value();
187+
}
142188
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/federation/FederationStateStoreService.java

Lines changed: 120 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public GetSubClusterPolicyConfigurationResponse getPolicyConfiguration(
260260
try {
261261
return stateStoreClient.getPolicyConfiguration(request);
262262
} catch (YarnException e) {
263-
LOG.error("getPolicyConfiguration error", e);
263+
LOG.error("getPolicyConfiguration error.", e);
264264
this.metrics.incrFailedGetCurrentVersionCount();
265265
throw e;
266266
}
@@ -269,106 +269,208 @@ public GetSubClusterPolicyConfigurationResponse getPolicyConfiguration(
269269
@Override
270270
public SetSubClusterPolicyConfigurationResponse setPolicyConfiguration(
271271
SetSubClusterPolicyConfigurationRequest request) throws YarnException {
272-
return stateStoreClient.setPolicyConfiguration(request);
272+
try {
273+
return stateStoreClient.setPolicyConfiguration(request);
274+
} catch (YarnException e) {
275+
LOG.error("setPolicyConfiguration error.", e);
276+
this.metrics.incrFailedSetPolicyConfigurationCount();
277+
throw e;
278+
}
273279
}
274280

275281
@Override
276282
public GetSubClusterPoliciesConfigurationsResponse getPoliciesConfigurations(
277283
GetSubClusterPoliciesConfigurationsRequest request) throws YarnException {
278-
return stateStoreClient.getPoliciesConfigurations(request);
284+
try {
285+
return stateStoreClient.getPoliciesConfigurations(request);
286+
} catch (YarnException e) {
287+
LOG.error("getPoliciesConfigurations error.", e);
288+
this.metrics.incrFailedGetPoliciesConfigurationsCount();
289+
throw e;
290+
}
279291
}
280292

281293
@Override
282294
public SubClusterRegisterResponse registerSubCluster(
283295
SubClusterRegisterRequest registerSubClusterRequest)
284296
throws YarnException {
285-
return stateStoreClient.registerSubCluster(registerSubClusterRequest);
297+
try {
298+
return stateStoreClient.registerSubCluster(registerSubClusterRequest);
299+
} catch (YarnException e) {
300+
LOG.error("registerSubCluster error.", e);
301+
this.metrics.incrFailedRegisterSubClusterCount();
302+
throw e;
303+
}
286304
}
287305

288306
@Override
289307
public SubClusterDeregisterResponse deregisterSubCluster(
290308
SubClusterDeregisterRequest subClusterDeregisterRequest)
291309
throws YarnException {
292-
return stateStoreClient.deregisterSubCluster(subClusterDeregisterRequest);
310+
try {
311+
return stateStoreClient.deregisterSubCluster(subClusterDeregisterRequest);
312+
} catch (YarnException e) {
313+
LOG.error("deregisterSubCluster error.", e);
314+
this.metrics.incrFailedDeregisterSubClusterCount();
315+
throw e;
316+
}
293317
}
294318

295319
@Override
296320
public SubClusterHeartbeatResponse subClusterHeartbeat(
297321
SubClusterHeartbeatRequest subClusterHeartbeatRequest)
298322
throws YarnException {
299-
return stateStoreClient.subClusterHeartbeat(subClusterHeartbeatRequest);
323+
try {
324+
return stateStoreClient.subClusterHeartbeat(subClusterHeartbeatRequest);
325+
} catch (YarnException e) {
326+
LOG.error("subClusterHeartbeat error.", e);
327+
this.metrics.incrFailedSubClusterHeartbeatCount();
328+
throw e;
329+
}
300330
}
301331

302332
@Override
303333
public GetSubClusterInfoResponse getSubCluster(
304334
GetSubClusterInfoRequest subClusterRequest) throws YarnException {
305-
return stateStoreClient.getSubCluster(subClusterRequest);
335+
try {
336+
return stateStoreClient.getSubCluster(subClusterRequest);
337+
} catch (YarnException e) {
338+
LOG.error("getSubCluster error.", e);
339+
this.metrics.incrFailedGetSubClusterCount();
340+
throw e;
341+
}
306342
}
307343

308344
@Override
309345
public GetSubClustersInfoResponse getSubClusters(
310346
GetSubClustersInfoRequest subClustersRequest) throws YarnException {
311-
return stateStoreClient.getSubClusters(subClustersRequest);
347+
try {
348+
return stateStoreClient.getSubClusters(subClustersRequest);
349+
} catch (YarnException e) {
350+
LOG.error("getSubClusters error.", e);
351+
this.metrics.incrFailedGetSubClustersCount();
352+
throw e;
353+
}
312354
}
313355

314356
@Override
315357
public AddApplicationHomeSubClusterResponse addApplicationHomeSubCluster(
316358
AddApplicationHomeSubClusterRequest request) throws YarnException {
317-
return stateStoreClient.addApplicationHomeSubCluster(request);
359+
try {
360+
return stateStoreClient.addApplicationHomeSubCluster(request);
361+
} catch (YarnException e) {
362+
LOG.error("addApplicationHomeSubCluster error.", e);
363+
this.metrics.incrFailedAddApplicationHomeSubClusterCount();
364+
throw e;
365+
}
318366
}
319367

320368
@Override
321369
public UpdateApplicationHomeSubClusterResponse updateApplicationHomeSubCluster(
322370
UpdateApplicationHomeSubClusterRequest request) throws YarnException {
323-
return stateStoreClient.updateApplicationHomeSubCluster(request);
371+
try {
372+
return stateStoreClient.updateApplicationHomeSubCluster(request);
373+
} catch (YarnException e) {
374+
LOG.error("updateApplicationHomeSubCluster error.", e);
375+
this.metrics.incrFailedUpdateApplicationHomeSubClusterCount();
376+
throw e;
377+
}
324378
}
325379

326380
@Override
327381
public GetApplicationHomeSubClusterResponse getApplicationHomeSubCluster(
328382
GetApplicationHomeSubClusterRequest request) throws YarnException {
329-
return stateStoreClient.getApplicationHomeSubCluster(request);
383+
try {
384+
return stateStoreClient.getApplicationHomeSubCluster(request);
385+
} catch (YarnException e) {
386+
LOG.error("getApplicationHomeSubCluster error.", e);
387+
this.metrics.incrFailedGetApplicationHomeSubClusterCount();
388+
throw e;
389+
}
330390
}
331391

332392
@Override
333393
public GetApplicationsHomeSubClusterResponse getApplicationsHomeSubCluster(
334394
GetApplicationsHomeSubClusterRequest request) throws YarnException {
335-
return stateStoreClient.getApplicationsHomeSubCluster(request);
395+
try {
396+
return stateStoreClient.getApplicationsHomeSubCluster(request);
397+
} catch (YarnException e) {
398+
LOG.error("getApplicationsHomeSubCluster error.", e);
399+
this.metrics.incrFailedGetApplicationsHomeSubClusterCount();
400+
throw e;
401+
}
336402
}
337403

338404
@Override
339405
public DeleteApplicationHomeSubClusterResponse deleteApplicationHomeSubCluster(
340406
DeleteApplicationHomeSubClusterRequest request) throws YarnException {
341-
return stateStoreClient.deleteApplicationHomeSubCluster(request);
407+
try {
408+
return stateStoreClient.deleteApplicationHomeSubCluster(request);
409+
} catch (YarnException e) {
410+
LOG.error("deleteApplicationHomeSubCluster error.", e);
411+
this.metrics.incrFailedDeleteApplicationHomeSubClusterCount();
412+
throw e;
413+
}
342414
}
343415

344416
@Override
345417
public AddReservationHomeSubClusterResponse addReservationHomeSubCluster(
346418
AddReservationHomeSubClusterRequest request) throws YarnException {
347-
return stateStoreClient.addReservationHomeSubCluster(request);
419+
try {
420+
return stateStoreClient.addReservationHomeSubCluster(request);
421+
} catch (YarnException e) {
422+
LOG.error("addReservationHomeSubCluster error.", e);
423+
this.metrics.incrFailedAddReservationHomeSubClusterCount();
424+
throw e;
425+
}
348426
}
349427

350428
@Override
351429
public GetReservationHomeSubClusterResponse getReservationHomeSubCluster(
352430
GetReservationHomeSubClusterRequest request) throws YarnException {
353-
return stateStoreClient.getReservationHomeSubCluster(request);
431+
try {
432+
return stateStoreClient.getReservationHomeSubCluster(request);
433+
} catch (YarnException e) {
434+
LOG.error("getReservationHomeSubCluster error.", e);
435+
this.metrics.incrFailedGetReservationHomeSubClusterCount();
436+
throw e;
437+
}
354438
}
355439

356440
@Override
357441
public GetReservationsHomeSubClusterResponse getReservationsHomeSubCluster(
358442
GetReservationsHomeSubClusterRequest request) throws YarnException {
359-
return stateStoreClient.getReservationsHomeSubCluster(request);
443+
try {
444+
return stateStoreClient.getReservationsHomeSubCluster(request);
445+
} catch (YarnException e) {
446+
LOG.error("getReservationsHomeSubCluster error.", e);
447+
this.metrics.incrFailedGetReservationsHomeSubClusterCount();
448+
throw e;
449+
}
360450
}
361451

362452
@Override
363453
public UpdateReservationHomeSubClusterResponse updateReservationHomeSubCluster(
364454
UpdateReservationHomeSubClusterRequest request) throws YarnException {
365-
return stateStoreClient.updateReservationHomeSubCluster(request);
455+
try {
456+
return stateStoreClient.updateReservationHomeSubCluster(request);
457+
} catch (YarnException e) {
458+
LOG.error("updateReservationHomeSubCluster error.", e);
459+
this.metrics.incrFailedUpdateReservationHomeSubClusterCount();
460+
throw e;
461+
}
366462
}
367463

368464
@Override
369465
public DeleteReservationHomeSubClusterResponse deleteReservationHomeSubCluster(
370466
DeleteReservationHomeSubClusterRequest request) throws YarnException {
371-
return stateStoreClient.deleteReservationHomeSubCluster(request);
467+
try {
468+
return stateStoreClient.deleteReservationHomeSubCluster(request);
469+
} catch (YarnException e) {
470+
LOG.error("deleteReservationHomeSubCluster error.", e);
471+
this.metrics.incrFailedDeleteReservationHomeSubClusterCount();
472+
throw e;
473+
}
372474
}
373475

374476
@Override

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/federation/TestFederationStateStoreClientMetrics.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import org.slf4j.Logger;
2323
import org.slf4j.LoggerFactory;
2424

25+
import static org.junit.Assert.assertEquals;
26+
2527
/**
2628
* Unit tests for TestFederationStateStoreClientMetrics.
2729
*/
@@ -35,8 +37,8 @@ public static void init() {
3537
metrics = FederationStateStoreClientMetrics.getMetrics();
3638
LOG.info("Test: aggregate metrics are initialized correctly");
3739

38-
Assert.assertEquals(0, metrics.getFailedGetCurrentVersionCount());
39-
40+
assertEquals(0, metrics.getFailedGetCurrentVersionCount());
41+
assertEquals(0, metrics.getFailedSetPolicyConfigurationCount());
4042

4143
LOG.info("Test: aggregate metrics are updated correctly");
4244
}

0 commit comments

Comments
 (0)