Skip to content

Commit ea90937

Browse files
committed
YARN-11483. Fix CheckStyle.
1 parent c9e5a2b commit ea90937

File tree

5 files changed

+246
-6
lines changed

5 files changed

+246
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.yarn.server.api.protocolrecords;
19+
20+
import org.apache.hadoop.classification.InterfaceAudience.Private;
21+
import org.apache.hadoop.classification.InterfaceAudience.Public;
22+
import org.apache.hadoop.classification.InterfaceStability.Unstable;
23+
import org.apache.hadoop.yarn.util.Records;
24+
25+
/**
26+
* This class is used for cleaning up an application that exists in the FederationStateStore.
27+
* This is a user-specified operation; we typically use this command to clean up an expired application.
28+
* However, it can also be used to clean up non-expired application, although it is not recommended.
29+
*/
30+
@Private
31+
@Unstable
32+
public abstract class DeleteFederationApplicationRequest {
33+
34+
@Private
35+
@Unstable
36+
public static DeleteFederationApplicationRequest newInstance(String application) {
37+
DeleteFederationApplicationRequest request =
38+
Records.newRecord(DeleteFederationApplicationRequest.class);
39+
request.setApplication(application);
40+
return request;
41+
}
42+
43+
@Public
44+
@Unstable
45+
public abstract String getApplication();
46+
47+
@Public
48+
@Unstable
49+
public abstract void setApplication(String application);
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.yarn.server.api.protocolrecords;
19+
20+
import org.apache.hadoop.classification.InterfaceAudience.Public;
21+
import org.apache.hadoop.classification.InterfaceAudience.Private;
22+
import org.apache.hadoop.classification.InterfaceStability.Unstable;
23+
import org.apache.hadoop.yarn.util.Records;
24+
25+
@Private
26+
@Unstable
27+
public abstract class DeleteFederationApplicationResponse {
28+
29+
public static DeleteFederationApplicationResponse newInstance() {
30+
return Records.newRecord(DeleteFederationApplicationResponse.class);
31+
}
32+
33+
public static DeleteFederationApplicationResponse newInstance(String msg) {
34+
DeleteFederationApplicationResponse response =
35+
Records.newRecord(DeleteFederationApplicationResponse.class);
36+
response.setMessage(msg);
37+
return response;
38+
}
39+
40+
@Public
41+
@Unstable
42+
public abstract String getMessage();
43+
44+
@Public
45+
@Unstable
46+
public abstract void setMessage(String msg);
47+
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/yarn_server_resourcemanager_service_protos.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,14 @@ message QueryFederationQueuePoliciesResponseProto {
203203
repeated FederationQueueWeightProto federationQueueWeights = 5;
204204
}
205205

206+
message DeleteFederationApplicationRequestProto {
207+
optional string application = 1;
208+
}
209+
210+
message DeleteFederationApplicationResponseProto {
211+
optional string message = 1;
212+
}
213+
206214
//////////////////////////////////////////////////////////////////
207215
///////////// RM Failover related records ////////////////////////
208216
//////////////////////////////////////////////////////////////////

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RouterCLI.java

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@
1717
*/
1818
package org.apache.hadoop.yarn.client.cli;
1919

20-
import org.apache.commons.cli.CommandLine;
21-
import org.apache.commons.cli.GnuParser;
22-
import org.apache.commons.cli.MissingArgumentException;
23-
import org.apache.commons.cli.Option;
24-
import org.apache.commons.cli.Options;
25-
import org.apache.commons.cli.ParseException;
20+
import org.apache.commons.cli.*;
2621
import org.apache.commons.collections.CollectionUtils;
2722
import org.apache.commons.collections.MapUtils;
2823
import org.apache.commons.lang3.StringUtils;
@@ -247,6 +242,9 @@ public class RouterCLI extends Configured implements Tool {
247242
.addExampleDescs(APPLICATION_DELETE_USAGE.args, APPLICATION_DELETE_USAGE_EXAMPLE_DESC)
248243
.addExample(APPLICATION_DELETE_USAGE.args, APPLICATION_DELETE_USAGE_EXAMPLE_1);
249244

245+
// delete application
246+
private static final String OPTION_DELETE_APP = "delete";
247+
250248
protected final static Map<String, RouterCmdUsageInfos> ADMIN_USAGE =
251249
ImmutableMap.<String, RouterCmdUsageInfos>builder()
252250
// Command1: deregisterSubCluster
@@ -836,6 +834,50 @@ protected int handListPolicies(int pageSize, int currentPage, String queue, List
836834
}
837835
}
838836

837+
838+
private int handleDeleteApplication(String application) {
839+
LOG.info("Delete Application = {}.", application);
840+
try {
841+
/*SaveFederationQueuePolicyRequest request = parsePolicy(policy);
842+
ResourceManagerAdministrationProtocol adminProtocol = createAdminProtocol();
843+
SaveFederationQueuePolicyResponse response = adminProtocol.saveFederationQueuePolicy(request);
844+
System.out.println(response.getMessage());*/
845+
return EXIT_SUCCESS;
846+
} catch (Exception e) {
847+
LOG.error("handleSavePolicy error.", e);
848+
return EXIT_ERROR;
849+
}
850+
}
851+
852+
private int handleApplication(String[] args)
853+
throws IOException, YarnException, ParseException {
854+
// Prepare Options.
855+
Options opts = new Options();
856+
opts.addOption("application", false,
857+
"We provide a set of commands to query and clean applications.");
858+
Option deleteOpt = new Option(null, OPTION_DELETE_APP, true,
859+
"We will clean up the provided application.");
860+
opts.addOption(deleteOpt);
861+
862+
// Parse command line arguments.
863+
CommandLine cliParser;
864+
try {
865+
cliParser = new DefaultParser().parse(opts, args);
866+
} catch (MissingArgumentException ex) {
867+
System.out.println("Missing argument for options");
868+
printUsage(args[0]);
869+
return EXIT_ERROR;
870+
}
871+
872+
if (cliParser.hasOption(OPTION_DELETE_APP)) {
873+
String application = cliParser.getOptionValue(OPTION_DELETE_APP);
874+
// return handleSavePolicy(policy);
875+
} else {
876+
877+
}
878+
return 0;
879+
}
880+
839881
@Override
840882
public int run(String[] args) throws Exception {
841883
YarnConfiguration yarnConf = getConf() == null ?
@@ -861,6 +903,8 @@ public int run(String[] args) throws Exception {
861903
return handleDeregisterSubCluster(args);
862904
} else if (CMD_POLICY.equals(cmd)) {
863905
return handlePolicy(args);
906+
} else if (CMD_APPLICATION.equals(cmd)) {
907+
return handleApplication(args);
864908
} else {
865909
System.out.println("No related commands found.");
866910
printHelp();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb;
19+
20+
import org.apache.commons.lang3.builder.EqualsBuilder;
21+
import org.apache.hadoop.classification.InterfaceAudience.Private;
22+
import org.apache.hadoop.classification.InterfaceStability.Unstable;
23+
import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.DeleteFederationApplicationRequestProto;
24+
import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.DeleteFederationApplicationRequestProtoOrBuilder;
25+
import org.apache.hadoop.yarn.server.api.protocolrecords.DeleteFederationApplicationRequest;
26+
27+
@Private
28+
@Unstable
29+
public class DeleteFederationApplicationRequestPBImpl extends DeleteFederationApplicationRequest {
30+
31+
private DeleteFederationApplicationRequestProto proto =
32+
DeleteFederationApplicationRequestProto.getDefaultInstance();
33+
private DeleteFederationApplicationRequestProto.Builder builder = null;
34+
private boolean viaProto = false;
35+
36+
public DeleteFederationApplicationRequestPBImpl() {
37+
builder = DeleteFederationApplicationRequestProto.newBuilder();
38+
}
39+
40+
public DeleteFederationApplicationRequestPBImpl(DeleteFederationApplicationRequestProto proto) {
41+
this.proto = proto;
42+
viaProto = true;
43+
}
44+
45+
private synchronized void maybeInitBuilder() {
46+
if (viaProto || builder == null) {
47+
builder = DeleteFederationApplicationRequestProto.newBuilder(proto);
48+
}
49+
viaProto = false;
50+
}
51+
52+
public DeleteFederationApplicationRequestProto getProto() {
53+
proto = viaProto ? proto : builder.build();
54+
viaProto = true;
55+
return proto;
56+
}
57+
58+
@Override
59+
public int hashCode() {
60+
return getProto().hashCode();
61+
}
62+
63+
@Override
64+
public boolean equals(Object other) {
65+
if (!(other instanceof DeleteFederationApplicationRequest)) {
66+
return false;
67+
}
68+
DeleteFederationApplicationRequestPBImpl otherImpl = this.getClass().cast(other);
69+
return new EqualsBuilder().append(this.getProto(), otherImpl.getProto()).isEquals();
70+
}
71+
72+
@Override
73+
public String getApplication() {
74+
DeleteFederationApplicationRequestProtoOrBuilder p = viaProto ? proto : builder;
75+
boolean hasApplication = p.hasApplication();
76+
if (hasApplication) {
77+
return p.getApplication();
78+
}
79+
return null;
80+
}
81+
82+
@Override
83+
public void setApplication(String application) {
84+
maybeInitBuilder();
85+
if (application == null) {
86+
builder.clearApplication();
87+
return;
88+
}
89+
builder.setApplication(application);
90+
}
91+
}

0 commit comments

Comments
 (0)