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 33c7dc1 commit 5fecc41
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.hadoop.yarn.server.api.protocolrecords;

import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.util.Records;
Expand All @@ -27,4 +28,19 @@ public abstract class SaveFederationQueuePolicyResponse {
public static SaveFederationQueuePolicyResponse newInstance() {
return Records.newRecord(SaveFederationQueuePolicyResponse.class);
}

public static SaveFederationQueuePolicyResponse newInstance(String msg) {
SaveFederationQueuePolicyResponse response =
Records.newRecord(SaveFederationQueuePolicyResponse.class);
response.setMessage(msg);
return response;
}

@Public
@Unstable
public abstract String getMessage();

@Public
@Unstable
public abstract void setMessage(String msg);
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ message SaveFederationQueuePolicyRequestProto {
}

message SaveFederationQueuePolicyResponseProto {
required string message = 1;
}

//////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ private int handleSavePolicy(String policy) {
SaveFederationQueuePolicyRequest request = parsePolicy(policy);
ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
SaveFederationQueuePolicyResponse response = adminProtocol.saveFederationQueuePolicy(request);
System.out.println(response.getMessage());
return EXIT_SUCCESS;
} catch (YarnException | IOException e) {
LOG.error("handleSavePolicy error.", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.thirdparty.protobuf.TextFormat;
import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.SaveFederationQueuePolicyResponseProtoOrBuilder;
import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.SaveFederationQueuePolicyResponseProto;
import org.apache.hadoop.yarn.server.api.protocolrecords.SaveFederationQueuePolicyResponse;

Expand Down Expand Up @@ -65,4 +66,31 @@ public boolean equals(Object other) {
public String toString() {
return TextFormat.shortDebugString(getProto());
}

@Override
public String getMessage() {
SaveFederationQueuePolicyResponseProtoOrBuilder p = viaProto ? proto : builder;
boolean hasMessage = p.hasMessage();
if (hasMessage) {
return p.getMessage();
}
return null;
}

private synchronized void maybeInitBuilder() {
if (viaProto || builder == null) {
builder = SaveFederationQueuePolicyResponseProto.newBuilder(proto);
}
viaProto = false;
}

@Override
public void setMessage(String msg) {
maybeInitBuilder();
if (msg == null) {
builder.clearMessage();
return;
}
builder.setMessage(msg);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ public SaveFederationQueuePolicyResponse saveFederationQueuePolicy(
federationFacade.setPolicyConfiguration(policyConfiguration);
long stopTime = clock.getTime();
routerMetrics.succeededSaveFederationQueuePolicyRetrieved(stopTime - startTime);
return SaveFederationQueuePolicyResponse.newInstance();
return SaveFederationQueuePolicyResponse.newInstance("save policy success.");
} catch (Exception e) {
routerMetrics.incrSaveFederationQueuePolicyFailedRetrieved();
RouterServerUtil.logAndThrowException(e,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ public void testSaveFederationQueuePolicyRequest() throws IOException, YarnExcep
SaveFederationQueuePolicyRequest.newInstance(queue, federationQueueWeight, policyTypeName);
SaveFederationQueuePolicyResponse response = interceptor.saveFederationQueuePolicy(request);
assertNotNull(response);
assertEquals("save policy success.", response.getMessage());

FederationStateStoreFacade federationFacade = interceptor.getFederationFacade();
SubClusterPolicyConfiguration policyConfiguration = federationFacade.getPolicyConfiguration(queue);
Expand Down

0 comments on commit 5fecc41

Please sign in to comment.