Skip to content

Commit 913e0a1

Browse files
committed
YARN-11484. Fix CheckStyle.
1 parent 692f0ae commit 913e0a1

File tree

9 files changed

+274
-40
lines changed

9 files changed

+274
-40
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/GetQueueInfoRequest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,20 @@ public abstract class GetQueueInfoRequest {
115115
@Stable
116116
public abstract void setRecursive(boolean recursive);
117117

118+
/**
119+
* Get SubClusterId.
120+
* @return SubClusterId.
121+
*/
118122
@Public
119123
@Stable
120124
public abstract String getSubClusterId();
121125

126+
/**
127+
* Set SubClusterId.
128+
* @param subClusterId SubClusterId.
129+
*/
122130
@Public
123131
@Stable
124-
public abstract void setSubClusterId();
132+
public abstract void setSubClusterId(String subClusterId);
125133
}
126134

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueInfo.java

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,82 +350,162 @@ public abstract void setIntraQueuePreemptionDisabled(
350350
@Stable
351351
public abstract String getSchedulerType();
352352

353+
/**
354+
* Set Scheduler type.
355+
* @param schedulerType scheduler Type.
356+
*/
353357
@Private
354358
@Unstable
355359
public abstract void setSchedulerType(String schedulerType);
356360

361+
/**
362+
* Get the minimum resource VCore.
363+
* @return minimum resource VCore.
364+
*/
357365
@Public
358366
@Stable
359367
public abstract int getMinResourceVCore();
360368

369+
/**
370+
* Set the minimum resource VCore.
371+
* @param vCore minimum resource VCore.
372+
*/
361373
@Private
362374
@Unstable
363375
public abstract void setMinResourceVCore(int vCore);
364376

377+
/**
378+
* Get the minimum resource Memory.
379+
* @return minimum resource Memory.
380+
*/
365381
@Public
366382
@Stable
367383
public abstract long getMinResourceMemory();
368384

385+
/**
386+
* Set the minimum resource Memory.
387+
* @param memory minimum resource Memory.
388+
*/
369389
@Private
370390
@Unstable
371391
public abstract void setMinResourceMemory(long memory);
372392

393+
/**
394+
* Get the maximum resource VCore.
395+
* @return maximum resource VCore.
396+
*/
373397
@Public
374398
@Stable
375399
public abstract int getMaxResourceVCore();
376400

401+
/**
402+
* Set the maximum resource Memory.
403+
* @param vCore maximum resource VCore.
404+
*/
377405
@Private
378406
@Unstable
379407
public abstract void setMaxResourceVCore(int vCore);
380408

409+
/**
410+
* Get the maximum resource Memory.
411+
* @return maximum resource Memory.
412+
*/
381413
@Public
382414
@Stable
383415
public abstract long getMaxResourceMemory();
384416

417+
/**
418+
* Set the maximum resource Memory.
419+
* @param memory maximum resource Memory.
420+
*/
385421
@Private
386422
@Unstable
387423
public abstract void setMaxResourceMemory(long memory);
388424

425+
/**
426+
* Get the reserved resource VCore.
427+
* @return reserved resource VCore.
428+
*/
389429
@Public
390430
@Stable
391431
public abstract int getReservedResourceVCore();
392432

433+
/**
434+
* Set the reserved resource VCore.
435+
* @param vCore reserved resource VCore.
436+
*/
393437
@Private
394438
@Unstable
395439
public abstract void setReservedResourceVCore(int vCore);
396440

441+
/**
442+
* Get the reserved resource Memory.
443+
* @return reserved resource Memory.
444+
*/
397445
@Public
398446
@Stable
399447
public abstract long getReservedResourceMemory();
400448

449+
/**
450+
* Set the reserved resource Memory.
451+
* @param memory reserved resource Memory.
452+
*/
401453
@Private
402454
@Unstable
403455
public abstract void setReservedResourceMemory(long memory);
404456

457+
/**
458+
* Get the SteadyFairShare VCore.
459+
* @return SteadyFairShare VCore.
460+
*/
405461
@Public
406462
@Stable
407463
public abstract int getSteadyFairShareVCore();
408464

465+
/**
466+
* Set the SteadyFairShare VCore.
467+
* @param vCore SteadyFairShare VCore.
468+
*/
409469
@Private
410470
@Unstable
411471
public abstract void setSteadyFairShareVCore(int vCore);
412472

473+
/**
474+
* Get the SteadyFairShare Memory.
475+
* @return SteadyFairShare Memory.
476+
*/
413477
@Public
414478
@Stable
415479
public abstract long getSteadyFairShareMemory();
416480

481+
/**
482+
* Set the SteadyFairShare Memory.
483+
* @param memory SteadyFairShare Memory.
484+
*/
417485
@Private
418486
@Unstable
419487
public abstract void setSteadyFairShareMemory(long memory);
420488

489+
/**
490+
* Get the SubClusterId.
491+
* @return the SubClusterId.
492+
*/
421493
@Public
422494
@Stable
423495
public abstract String getSubClusterId();
424496

497+
/**
498+
* Set the SubClusterId.
499+
* @param subClusterId the SubClusterId.
500+
*/
425501
@Private
426502
@Unstable
427503
public abstract void setSubClusterId(String subClusterId);
428504

505+
/**
506+
* Get the MaxRunningApp.
507+
* @return The number of MaxRunningApp.
508+
*/
429509
@Public
430510
@Stable
431511
public abstract int getMaxRunningApp();

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/YarnClient.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,25 @@ public abstract Token getRMDelegationToken(Text renewer)
464464
* @throws YarnException
465465
* in case of errors or if YARN rejects the request due to
466466
* access-control restrictions.
467-
* @throws IOException
467+
* @throws IOException I/O exception has occurred.
468468
*/
469469
public abstract QueueInfo getQueueInfo(String queueName) throws YarnException,
470470
IOException;
471471

472+
/**
473+
* <p>
474+
* Get information ({@link QueueInfo}) about a given <em>queue</em>.
475+
* </p>
476+
*
477+
* @param queueName
478+
* Name of the queue whose information is needed
479+
* @param subClusterId sub-cluster Id
480+
* @return
481+
* @throws YarnException
482+
* in case of errors or if YARN rejects the request due to
483+
* access-control restrictions.
484+
* @throws IOException I/O exception has occurred.
485+
*/
472486
public abstract QueueInfo getQueueInfo(String queueName, String subClusterId)
473487
throws YarnException, IOException;
474488

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,18 @@ public Token getRMDelegationToken(Text renewer)
735735
return request;
736736
}
737737

738+
private GetQueueInfoRequest getQueueInfoRequest(
739+
String queueName, String subClusterId, boolean includeApplications,
740+
boolean includeChildQueues, boolean recursive) {
741+
GetQueueInfoRequest request = Records.newRecord(GetQueueInfoRequest.class);
742+
request.setQueueName(queueName);
743+
request.setSubClusterId(subClusterId);
744+
request.setIncludeApplications(includeApplications);
745+
request.setIncludeChildQueues(includeChildQueues);
746+
request.setRecursive(recursive);
747+
return request;
748+
}
749+
738750
@Override
739751
public QueueInfo getQueueInfo(String queueName) throws YarnException,
740752
IOException {
@@ -747,7 +759,10 @@ public QueueInfo getQueueInfo(String queueName) throws YarnException,
747759
@Override
748760
public QueueInfo getQueueInfo(String queueName,
749761
String subClusterId) throws YarnException, IOException {
750-
return null;
762+
GetQueueInfoRequest request =
763+
getQueueInfoRequest(queueName, subClusterId, true, false, false);
764+
Records.newRecord(GetQueueInfoRequest.class);
765+
return rmClient.getQueueInfo(request).getQueueInfo();
751766
}
752767

753768
@Override

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

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.apache.hadoop.yarn.api.records.NodeLabel;
4040
import org.apache.hadoop.yarn.api.records.QueueInfo;
4141
import org.apache.hadoop.yarn.client.util.FormattingCLIUtils;
42-
import org.apache.hadoop.yarn.client.util.YarnClientUtils;
4342
import org.apache.hadoop.yarn.exceptions.YarnException;
4443

4544
import org.apache.hadoop.classification.VisibleForTesting;
@@ -53,8 +52,6 @@ public class QueueCLI extends YarnCLI {
5352

5453
public static final String ALLTAG = "all";
5554

56-
57-
5855
public static void main(String[] args) throws Exception {
5956
QueueCLI cli = new QueueCLI();
6057
cli.setSysOutPrintStream(System.out);
@@ -94,10 +91,12 @@ public int run(String[] args) throws Exception {
9491
return -1;
9592
}
9693
String queue = cliParser.getOptionValue(STATUS_CMD);
97-
if (isYarnFederationEnabled(getConf())) {
98-
return listQueue(cliParser.getOptionValue(STATUS_CMD));
94+
String subClusterId = cliParser.getOptionValue(OPTION_SUBCLUSTERID);
95+
if (isYarnFederationEnabled(getConf()) && StringUtils.isNotBlank(subClusterId)) {
96+
return listQueue(queue, subClusterId);
97+
} else {
98+
return listQueue(queue);
9999
}
100-
return listQueue(cliParser.getOptionValue(STATUS_CMD));
101100
} else if (cliParser.hasOption(HELP_CMD)) {
102101
printUsage(opts);
103102
return 0;
@@ -127,12 +126,12 @@ void printUsage(Options opts) {
127126
/**
128127
* Lists the Queue Information matching the given queue name.
129128
*
130-
* @param queueName
131-
* @throws YarnException
132-
* @throws IOException
129+
* @param queueName Queue name to be queried.
130+
* @throws YarnException YarnException indicates exceptions from yarn servers.
131+
* @throws IOException I/O exception has occurred.
132+
* @return 0, the command execution is successful; -1, the command execution fails.
133133
*/
134-
private int listQueue(String queueName)
135-
throws YarnException, IOException {
134+
private int listQueue(String queueName) throws YarnException, IOException {
136135
int rc;
137136
PrintWriter writer = new PrintWriter(
138137
new OutputStreamWriter(sysout, Charset.forName("UTF-8")));
@@ -151,6 +150,34 @@ private int listQueue(String queueName)
151150
return rc;
152151
}
153152

153+
/**
154+
* Lists the Queue Information matching the given queue name.
155+
*
156+
* @param queueName Queue name to be queried.
157+
* @param subClusterId Subcluster id.
158+
* @throws YarnException YarnException indicates exceptions from yarn servers.
159+
* @throws IOException I/O exception has occurred.
160+
* @return 0, the command execution is successful; -1, the command execution fails.
161+
*/
162+
private int listQueue(String queueName, String subClusterId)
163+
throws YarnException, IOException {
164+
int rc;
165+
PrintWriter writer = new PrintWriter(
166+
new OutputStreamWriter(sysout, Charset.forName("UTF-8")));
167+
QueueInfo queueInfo = client.getQueueInfo(queueName, subClusterId);
168+
if (queueInfo != null) {
169+
writer.println("Queue Information : ");
170+
printQueueInfo(writer, queueInfo);
171+
rc = 0;
172+
} else {
173+
writer.println("Cannot get queue from RM by queueName = " + queueName
174+
+ ", subClusterId = " + subClusterId + " please check.");
175+
rc = -1;
176+
}
177+
writer.flush();
178+
return rc;
179+
}
180+
154181
/**
155182
* List information about all child queues based on the parent queue.
156183
* @param parentQueueName The name of the payment queue.

0 commit comments

Comments
 (0)