Skip to content

Commit

Permalink
YARN-11525. Fix CheckStyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 committed Jul 11, 2023
1 parent ca3e41b commit 7294c12
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,15 @@ public abstract class FederationQueueWeight {

@Private
@Unstable
public static FederationQueueWeight newInstance(String queue, String routerWeight,
public static FederationQueueWeight newInstance(String routerWeight,
String amrmWeight, String headRoomAlpha) {
FederationQueueWeight federationQueueWeight = Records.newRecord(FederationQueueWeight.class);
federationQueueWeight.setQueue(queue);
federationQueueWeight.setRouterWeight(routerWeight);
federationQueueWeight.setAmrmWeight(amrmWeight);
federationQueueWeight.setHeadRoomAlpha(headRoomAlpha);
return federationQueueWeight;
}

@Public
@Unstable
public abstract String getQueue();

@Public
@Unstable
public abstract void setQueue(String queue);

@Public
@Unstable
public abstract String getRouterWeight();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,9 @@ message DeregisterSubClustersProto {
}

message FederationQueueWeightProto {
optional string queue = 1;
optional string routerWeight = 2;
optional string amrmWeight = 3;
optional string headRoomAlpha = 4;
optional string routerWeight = 1;
optional string amrmWeight = 2;
optional string headRoomAlpha = 3;
}

////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ public class RouterCLI extends Configured implements Tool {
private static final String CMD_HELP = "-help";

// Command2: policy
// list
//
//
// save policy
private static final String OPTION_S = "s";
private static final String OPTION_SAVE = "save";

public RouterCLI() {
super();
Expand Down Expand Up @@ -309,10 +309,10 @@ private int handlePolicy(String[] args)
}

// Try to parse the cmd save.
if (cliParser.hasOption("s") || cliParser.hasOption("save")) {
String policy = cliParser.getOptionValue("s");
if (cliParser.hasOption(OPTION_S) || cliParser.hasOption(OPTION_SAVE)) {
String policy = cliParser.getOptionValue(OPTION_S);
if (StringUtils.isBlank(policy)) {
policy = cliParser.getOptionValue("save");
policy = cliParser.getOptionValue(OPTION_SAVE);
}
}

Expand Down Expand Up @@ -369,8 +369,8 @@ protected FederationQueueWeight parsePolicy(String policy) throws YarnException
checkSubClusterQueueWeightRatioValid(amrmWeight);
checkHeadRoomAlphaValid(headroomalpha);

FederationQueueWeight federationQueueWeight = FederationQueueWeight.newInstance(
queue, routerWeight, amrmWeight, headroomalpha);
FederationQueueWeight federationQueueWeight =
FederationQueueWeight.newInstance(routerWeight, amrmWeight, headroomalpha);
return federationQueueWeight;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ public void testParsePolicy() throws Exception {
String policy = "root.a;SC-1:0.7,SC-2:0.3;SC-1:0.6,SC-2:0.4;1.0";
FederationQueueWeight federationQueueWeight = rmAdminCLI.parsePolicy(policy);
assertNotNull(federationQueueWeight);
assertEquals("root.a", federationQueueWeight.getQueue());
assertEquals("SC-1:0.7,SC-2:0.3", federationQueueWeight.getRouterWeight());
assertEquals("SC-1:0.6,SC-2:0.4", federationQueueWeight.getAmrmWeight());
assertEquals("1.0", federationQueueWeight.getHeadRoomAlpha());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,6 @@ public FederationQueueWeightProto getProto() {
return this.proto;
}

@Override
public String getQueue() {
FederationQueueWeightProtoOrBuilder p = this.viaProto ? this.proto : this.builder;
boolean hasQueue = p.hasQueue();
if (hasQueue) {
return p.getQueue();
}
return null;
}

@Override
public void setQueue(String queue) {
maybeInitBuilder();
if (queue == null) {
builder.clearQueue();
return;
}
builder.setQueue(queue);
}

@Override
public String getRouterWeight() {
FederationQueueWeightProtoOrBuilder p = this.viaProto ? this.proto : this.builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,11 @@ public void getGroupsForUserFailed() {
LOG.info("Mocked: failed getGroupsForUser call");
metrics.incrGetGroupsForUserFailedRetrieved();
}

public void getSaveFederationQueuePolicyFailedRetrieved() {
LOG.info("Mocked: failed refreshClusterMaxPriority call");
metrics.incrSaveFederationQueuePolicyFailedRetrieved();
}
}

// Records successes for all calls
Expand Down Expand Up @@ -952,6 +957,12 @@ public void getGroupsForUsersRetrieved(long duration) {
duration);
metrics.succeededGetGroupsForUsersRetrieved(duration);
}

public void getSaveFederationQueuePolicyRetrieved(long duration) {
LOG.info("Mocked: successful SaveFederationQueuePolicy call with duration {}",
duration);
metrics.succeededSaveFederationQueuePolicyRetrieved(duration);
}
}

@Test
Expand Down Expand Up @@ -2208,4 +2219,26 @@ public void testGetGroupsForUserRetrieved() {
Assert.assertEquals(225,
metrics.getLatencySucceededGetGroupsForUsersRetrieved(), ASSERT_DOUBLE_DELTA);
}

@Test
public void testSaveFederationQueuePolicyFailedRetrieved() {
long totalBadBefore = metrics.getSaveFederationQueuePolicyFailedRetrieved();
badSubCluster.getSaveFederationQueuePolicyFailedRetrieved();
Assert.assertEquals(totalBadBefore + 1, metrics.getSaveFederationQueuePolicyFailedRetrieved());
}

@Test
public void testSaveFederationQueuePolicyRetrieved() {
long totalGoodBefore = metrics.getNumSucceededSaveFederationQueuePolicyRetrieved();
goodSubCluster.getSaveFederationQueuePolicyRetrieved(150);
Assert.assertEquals(totalGoodBefore + 1,
metrics.getNumSucceededSaveFederationQueuePolicyRetrieved());
Assert.assertEquals(150,
metrics.getLatencySucceededSaveFederationQueuePolicyRetrieved(), ASSERT_DOUBLE_DELTA);
goodSubCluster.getSaveFederationQueuePolicyRetrieved(300);
Assert.assertEquals(totalGoodBefore + 2,
metrics.getNumSucceededSaveFederationQueuePolicyRetrieved());
Assert.assertEquals(225,
metrics.getLatencySucceededSaveFederationQueuePolicyRetrieved(), ASSERT_DOUBLE_DELTA);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -581,18 +581,17 @@ public void testGetGroupsForUserNormalRequest() throws Exception {

@Test
public void testSaveFederationQueuePolicyErrorRequest() throws Exception {
// null request1.
// null request.
LambdaTestUtils.intercept(YarnException.class, "Missing SaveFederationQueuePolicy request.",
() -> interceptor.saveFederationQueuePolicy(null));

// null request2.
// federationQueueWeight is null.
LambdaTestUtils.intercept(IllegalArgumentException.class, "FederationQueueWeight cannot be null.",
() -> SaveFederationQueuePolicyRequest.newInstance("root.a", null, "-"));

// null request3.
// queue is null
FederationQueueWeight federationQueueWeight =
FederationQueueWeight.newInstance(
"", "SC-1:0.7,SC-2:0.3", "SC-1:0.7,SC-2:0.3", "1.0");
FederationQueueWeight.newInstance("SC-1:0.7,SC-2:0.3", "SC-1:0.7,SC-2:0.3", "1.0");
SaveFederationQueuePolicyRequest request =
SaveFederationQueuePolicyRequest.newInstance("", federationQueueWeight, "-");
LambdaTestUtils.intercept(YarnException.class, "Missing Queue information.",
Expand Down

0 comments on commit 7294c12

Please sign in to comment.