Skip to content

Commit

Permalink
YARN-11483. Fix CheckStyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 committed Nov 6, 2023
1 parent f4d3468 commit 5f8abdf
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
*/
package org.apache.hadoop.yarn.client.cli;

import org.apache.commons.cli.*;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.MissingArgumentException;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -37,6 +43,8 @@
import org.apache.hadoop.yarn.server.api.protocolrecords.DeregisterSubClusterRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.DeregisterSubClusterResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.DeregisterSubClusters;
import org.apache.hadoop.yarn.server.api.protocolrecords.DeleteFederationApplicationRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.DeleteFederationApplicationResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.SaveFederationQueuePolicyRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.SaveFederationQueuePolicyResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.BatchSaveFederationQueuePoliciesRequest;
Expand Down Expand Up @@ -834,14 +842,15 @@ protected int handListPolicies(int pageSize, int currentPage, String queue, List
}
}


private int handleDeleteApplication(String application) {
LOG.info("Delete Application = {}.", application);
try {
/*SaveFederationQueuePolicyRequest request = parsePolicy(policy);
DeleteFederationApplicationRequest request =
DeleteFederationApplicationRequest.newInstance(application);
ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
SaveFederationQueuePolicyResponse response = adminProtocol.saveFederationQueuePolicy(request);
System.out.println(response.getMessage());*/
DeleteFederationApplicationResponse response =
adminProtocol.deleteFederationApplication(request);
System.out.println(response.getMessage());
return EXIT_SUCCESS;
} catch (Exception e) {
LOG.error("handleSavePolicy error.", e);
Expand Down Expand Up @@ -871,10 +880,9 @@ private int handleApplication(String[] args)

if (cliParser.hasOption(OPTION_DELETE_APP)) {
String application = cliParser.getOptionValue(OPTION_DELETE_APP);
// return handleSavePolicy(policy);
} else {

return handleDeleteApplication(application);
}

return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
Expand Down Expand Up @@ -1093,7 +1094,24 @@ public QueryFederationQueuePoliciesResponse listFederationQueuePolicies(
@Override
public DeleteFederationApplicationResponse deleteFederationApplication(
DeleteFederationApplicationRequest request) throws YarnException, IOException {
return null;
// Parameter validation.
if (request == null) {
RouterServerUtil.logAndThrowException(
"Missing deleteFederationApplication Request.", null);
}


try {
ApplicationId applicationId = ApplicationId.fromString(request.getApplication());
federationFacade.deleteApplicationHomeSubCluster(applicationId);
return DeleteFederationApplicationResponse.newInstance(
"application = " + applicationId + " delete success.");
} catch (Exception e) {
RouterServerUtil.logAndThrowException(e,
"Unable to deleteFederationApplication due to exception. " + e.getMessage());
}

throw new YarnException("Unable to listFederationQueuePolicies.");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,7 @@
import org.apache.hadoop.yarn.api.records.NodeAttributeType;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshQueuesRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshQueuesResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshSuperUserGroupsConfigurationRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshSuperUserGroupsConfigurationResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshUserToGroupsMappingsRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshUserToGroupsMappingsResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshAdminAclsRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshAdminAclsResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshServiceAclsRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshServiceAclsResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesResourcesRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshNodesResourcesResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.AddToClusterNodeLabelsResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.RemoveFromClusterNodeLabelsRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.RemoveFromClusterNodeLabelsResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.ReplaceLabelsOnNodeRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.ReplaceLabelsOnNodeResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.CheckForDecommissioningNodesResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.NodesToAttributesMappingRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.AttributeMappingOperationType;
import org.apache.hadoop.yarn.server.api.protocolrecords.NodeToAttributes;
import org.apache.hadoop.yarn.server.api.protocolrecords.FederationQueueWeight;
import org.apache.hadoop.yarn.server.api.protocolrecords.SaveFederationQueuePolicyRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.SaveFederationQueuePolicyResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.BatchSaveFederationQueuePoliciesRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.BatchSaveFederationQueuePoliciesResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.QueryFederationQueuePoliciesRequest;
import org.apache.hadoop.yarn.server.api.protocolrecords.QueryFederationQueuePoliciesResponse;
import org.apache.hadoop.yarn.server.api.protocolrecords.*;
import org.apache.hadoop.yarn.server.federation.policies.dao.WeightedPolicyInfo;
import org.apache.hadoop.yarn.server.federation.policies.manager.WeightedLocalityPolicyManager;
import org.apache.hadoop.yarn.server.federation.store.impl.MemoryFederationStateStore;
Expand Down Expand Up @@ -989,4 +957,13 @@ public void testFilterPoliciesConfigurationsByQueues() throws Exception {
"The index of the records to be retrieved has exceeded the maximum index.",
() -> interceptor.listFederationQueuePolicies(request8));
}


@Test
public void testDeleteFederationApplication() throws IOException, YarnException {
DeleteFederationApplicationRequest request =
DeleteFederationApplicationRequest.newInstance("application_1");
DeleteFederationApplicationResponse response = interceptor.deleteFederationApplication(request);
assertNotNull(response);
}
}

0 comments on commit 5f8abdf

Please sign in to comment.