Skip to content

Commit 2bd6c39

Browse files
committed
YARN-11536. [Federation] Router CLI Supports Batch Save the SubClusterPolicyConfiguration Of Queues.
1 parent 82c8070 commit 2bd6c39

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class RouterCLI extends Configured implements Tool {
7171
"set the state of the subCluster to SC_LOST."))
7272
// Command2: policy
7373
.put("-policy", new UsageInfo(
74-
"[-s|--save [queue;router weight;amrm weight;headroomalpha]]",
74+
"[-s|--save [queue;router weight;amrm weight;headroomalpha]] [-bs|--batch-save [--format xml,json] [-f|--input-file fileName]]",
7575
"We provide a set of commands for Policy:" +
7676
" Include list policies, save policies, batch save policies. " +
7777
" (Note: The policy type will be directly read from the" +
@@ -102,8 +102,16 @@ public class RouterCLI extends Configured implements Tool {
102102
// Command2: policy
103103
// save policy
104104
private static final String OPTION_S = "s";
105+
106+
private static final String OPTION_BATCH_S = "bs";
107+
105108
private static final String OPTION_SAVE = "save";
109+
110+
private static final String OPTION_BATCH_SAVE = "batch-save";
111+
106112
private static final String CMD_POLICY = "-policy";
113+
private static final String FORMAT_XML = "xml";
114+
private static final String FORMAT_JSON = "json";
107115

108116
public RouterCLI() {
109117
super();
@@ -161,7 +169,7 @@ private static void printHelp() {
161169
.append("The full syntax is: \n\n")
162170
.append("routeradmin\n")
163171
.append(" [-deregisterSubCluster [-sc|--subClusterId [subCluster Id]]\n")
164-
.append(" [-policy [-s|--save [queue;router weight;amrm weight;headroomalpha]]\n")
172+
.append(" [-policy [-s|--save [queue;router weight;amrm weight;headroomalpha] [-bs|--batch-save [--format xml,json] [-f|--input-file fileName]]]\n")
165173
.append(" [-help [cmd]]").append("\n");
166174
StringBuilder helpBuilder = new StringBuilder();
167175
System.out.println(summary);

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestRouterCLI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ private DeregisterSubClusterResponse generateAllSubClusterData() {
120120
public void testHelp() throws Exception {
121121
ByteArrayOutputStream dataOut = new ByteArrayOutputStream();
122122
ByteArrayOutputStream dataErr = new ByteArrayOutputStream();
123-
System.setOut(new PrintStream(dataOut));
124-
System.setErr(new PrintStream(dataErr));
123+
// System.setOut(new PrintStream(dataOut));
124+
// System.setErr(new PrintStream(dataErr));
125125

126126
String[] args = {"-help"};
127127
rmAdminCLI.run(args);
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0"?>
2+
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
3+
4+
<!--
5+
Licensed to the Apache Software Foundation (ASF) under one or more
6+
contributor license agreements. See the NOTICE file distributed with
7+
this work for additional information regarding copyright ownership.
8+
The ASF licenses this file to You under the Apache License, Version 2.0
9+
(the "License"); you may not use this file except in compliance with
10+
the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
-->
20+
21+
<federationWeights>
22+
<weight>
23+
<queue>
24+
<name>root.a</name>
25+
<amrmPolicyWeights>
26+
<subClusterIdInfo>
27+
<id>SC-1</id>
28+
<weight>0.7</weight>
29+
</subClusterIdInfo>
30+
<subClusterIdInfo>
31+
<id>SC-2</id>
32+
<weight>0.3</weight>
33+
</subClusterIdInfo>
34+
</amrmPolicyWeights>
35+
<routerPolicyWeights>
36+
<subClusterIdInfo>
37+
<id>SC-1</id>
38+
<weight>0.6</weight>
39+
</subClusterIdInfo>
40+
<subClusterIdInfo>
41+
<id>SC-2</id>
42+
<weight>0.4</weight>
43+
</subClusterIdInfo>
44+
</routerPolicyWeights>
45+
<headroomAlpha>1.0</headroomAlpha>
46+
</queue>
47+
</weight>
48+
</federationWeights>

0 commit comments

Comments
 (0)