001/** 002* Licensed to the Apache Software Foundation (ASF) under one 003* or more contributor license agreements. See the NOTICE file 004* distributed with this work for additional information 005* regarding copyright ownership. The ASF licenses this file 006* to you under the Apache License, Version 2.0 (the 007* "License"); you may not use this file except in compliance 008* with the License. You may obtain a copy of the License at 009* 010* http://www.apache.org/licenses/LICENSE-2.0 011* 012* Unless required by applicable law or agreed to in writing, software 013* distributed under the License is distributed on an "AS IS" BASIS, 014* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015* See the License for the specific language governing permissions and 016* limitations under the License. 017*/ 018 019package org.apache.hadoop.yarn.client.api; 020 021import java.io.IOException; 022import java.util.EnumSet; 023import java.util.List; 024import java.util.Map; 025import java.util.Set; 026 027import org.apache.hadoop.classification.InterfaceAudience; 028import org.apache.hadoop.classification.InterfaceAudience.Private; 029import org.apache.hadoop.classification.InterfaceAudience.Public; 030import org.apache.hadoop.classification.InterfaceStability; 031import org.apache.hadoop.classification.InterfaceStability.Unstable; 032import org.apache.hadoop.io.Text; 033import org.apache.hadoop.service.AbstractService; 034import org.apache.hadoop.yarn.api.ApplicationClientProtocol; 035import org.apache.hadoop.yarn.api.protocolrecords.GetNewReservationResponse; 036import org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest; 037import org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteResponse; 038import org.apache.hadoop.yarn.api.protocolrecords.ReservationListRequest; 039import org.apache.hadoop.yarn.api.protocolrecords.ReservationListResponse; 040import org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest; 041import org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionResponse; 042import org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateRequest; 043import org.apache.hadoop.yarn.api.protocolrecords.ReservationUpdateResponse; 044import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; 045import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; 046import org.apache.hadoop.yarn.api.records.ApplicationId; 047import org.apache.hadoop.yarn.api.records.ApplicationReport; 048import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; 049import org.apache.hadoop.yarn.api.records.ContainerId; 050import org.apache.hadoop.yarn.api.records.ContainerReport; 051import org.apache.hadoop.yarn.api.records.NodeId; 052import org.apache.hadoop.yarn.api.records.NodeLabel; 053import org.apache.hadoop.yarn.api.records.NodeReport; 054import org.apache.hadoop.yarn.api.records.NodeState; 055import org.apache.hadoop.yarn.api.records.Priority; 056import org.apache.hadoop.yarn.api.records.QueueInfo; 057import org.apache.hadoop.yarn.api.records.QueueUserACLInfo; 058import org.apache.hadoop.yarn.api.records.ReservationDefinition; 059import org.apache.hadoop.yarn.api.records.ReservationId; 060import org.apache.hadoop.yarn.api.records.SignalContainerCommand; 061import org.apache.hadoop.yarn.api.records.Token; 062import org.apache.hadoop.yarn.api.records.YarnApplicationState; 063import org.apache.hadoop.yarn.api.records.YarnClusterMetrics; 064import org.apache.hadoop.yarn.client.api.impl.YarnClientImpl; 065import org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException; 066import org.apache.hadoop.yarn.exceptions.ApplicationIdNotProvidedException; 067import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException; 068import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException; 069import org.apache.hadoop.yarn.exceptions.YarnException; 070import org.apache.hadoop.yarn.security.AMRMTokenIdentifier; 071 072@InterfaceAudience.Public 073@InterfaceStability.Stable 074public abstract class YarnClient extends AbstractService { 075 076 /** 077 * Create a new instance of YarnClient. 078 */ 079 @Public 080 public static YarnClient createYarnClient() { 081 YarnClient client = new YarnClientImpl(); 082 return client; 083 } 084 085 @Private 086 protected YarnClient(String name) { 087 super(name); 088 } 089 090 /** 091 * <p> 092 * Obtain a {@link YarnClientApplication} for a new application, 093 * which in turn contains the {@link ApplicationSubmissionContext} and 094 * {@link org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse} 095 * objects. 096 * </p> 097 * 098 * @return {@link YarnClientApplication} built for a new application 099 * @throws YarnException 100 * @throws IOException 101 */ 102 public abstract YarnClientApplication createApplication() 103 throws YarnException, IOException; 104 105 /** 106 * <p> 107 * Submit a new application to <code>YARN.</code> It is a blocking call - it 108 * will not return {@link ApplicationId} until the submitted application is 109 * submitted successfully and accepted by the ResourceManager. 110 * </p> 111 * 112 * <p> 113 * Users should provide an {@link ApplicationId} as part of the parameter 114 * {@link ApplicationSubmissionContext} when submitting a new application, 115 * otherwise it will throw the {@link ApplicationIdNotProvidedException}. 116 * </p> 117 * 118 * <p>This internally calls {@link ApplicationClientProtocol#submitApplication 119 * (SubmitApplicationRequest)}, and after that, it internally invokes 120 * {@link ApplicationClientProtocol#getApplicationReport 121 * (GetApplicationReportRequest)} and waits till it can make sure that the 122 * application gets properly submitted. If RM fails over or RM restart 123 * happens before ResourceManager saves the application's state, 124 * {@link ApplicationClientProtocol 125 * #getApplicationReport(GetApplicationReportRequest)} will throw 126 * the {@link ApplicationNotFoundException}. This API automatically resubmits 127 * the application with the same {@link ApplicationSubmissionContext} when it 128 * catches the {@link ApplicationNotFoundException}</p> 129 * 130 * @param appContext 131 * {@link ApplicationSubmissionContext} containing all the details 132 * needed to submit a new application 133 * @return {@link ApplicationId} of the accepted application 134 * @throws YarnException 135 * @throws IOException 136 * @see #createApplication() 137 */ 138 public abstract ApplicationId submitApplication( 139 ApplicationSubmissionContext appContext) throws YarnException, 140 IOException; 141 142 /** 143 * <p> 144 * Fail an application attempt identified by given ID. 145 * </p> 146 * 147 * @param applicationAttemptId 148 * {@link ApplicationAttemptId} of the attempt to fail. 149 * @throws YarnException 150 * in case of errors or if YARN rejects the request due to 151 * access-control restrictions. 152 * @throws IOException 153 * @see #getQueueAclsInfo() 154 */ 155 public abstract void failApplicationAttempt( 156 ApplicationAttemptId applicationAttemptId) throws YarnException, 157 IOException; 158 159 /** 160 * <p> 161 * Kill an application identified by given ID. 162 * </p> 163 * 164 * @param applicationId 165 * {@link ApplicationId} of the application that needs to be killed 166 * @throws YarnException 167 * in case of errors or if YARN rejects the request due to 168 * access-control restrictions. 169 * @throws IOException 170 * @see #getQueueAclsInfo() 171 */ 172 public abstract void killApplication(ApplicationId applicationId) throws YarnException, 173 IOException; 174 175 /** 176 * <p> 177 * Kill an application identified by given ID. 178 * </p> 179 * @param applicationId {@link ApplicationId} of the application that needs to 180 * be killed 181 * @param diagnostics for killing an application. 182 * @throws YarnException in case of errors or if YARN rejects the request due 183 * to access-control restrictions. 184 * @throws IOException 185 */ 186 public abstract void killApplication(ApplicationId applicationId, 187 String diagnostics) throws YarnException, IOException; 188 189 /** 190 * <p> 191 * Get a report of the given Application. 192 * </p> 193 * 194 * <p> 195 * In secure mode, <code>YARN</code> verifies access to the application, queue 196 * etc. before accepting the request. 197 * </p> 198 * 199 * <p> 200 * If the user does not have <code>VIEW_APP</code> access then the following 201 * fields in the report will be set to stubbed values: 202 * <ul> 203 * <li>host - set to "N/A"</li> 204 * <li>RPC port - set to -1</li> 205 * <li>client token - set to "N/A"</li> 206 * <li>diagnostics - set to "N/A"</li> 207 * <li>tracking URL - set to "N/A"</li> 208 * <li>original tracking URL - set to "N/A"</li> 209 * <li>resource usage report - all values are -1</li> 210 * </ul> 211 * 212 * @param appId 213 * {@link ApplicationId} of the application that needs a report 214 * @return application report 215 * @throws YarnException 216 * @throws IOException 217 */ 218 public abstract ApplicationReport getApplicationReport(ApplicationId appId) 219 throws YarnException, IOException; 220 221 /** 222 * Get the AMRM token of the application. 223 * <p> 224 * The AMRM token is required for AM to RM scheduling operations. For 225 * managed Application Masters Yarn takes care of injecting it. For unmanaged 226 * Applications Masters, the token must be obtained via this method and set 227 * in the {@link org.apache.hadoop.security.UserGroupInformation} of the 228 * current user. 229 * <p> 230 * The AMRM token will be returned only if all the following conditions are 231 * met: 232 * <ul> 233 * <li>the requester is the owner of the ApplicationMaster</li> 234 * <li>the application master is an unmanaged ApplicationMaster</li> 235 * <li>the application master is in ACCEPTED state</li> 236 * </ul> 237 * Else this method returns NULL. 238 * 239 * @param appId {@link ApplicationId} of the application to get the AMRM token 240 * @return the AMRM token if available 241 * @throws YarnException 242 * @throws IOException 243 */ 244 public abstract org.apache.hadoop.security.token.Token<AMRMTokenIdentifier> 245 getAMRMToken(ApplicationId appId) throws YarnException, IOException; 246 247 /** 248 * <p> 249 * Get a report (ApplicationReport) of all Applications in the cluster. 250 * </p> 251 * 252 * <p> 253 * If the user does not have <code>VIEW_APP</code> access for an application 254 * then the corresponding report will be filtered as described in 255 * {@link #getApplicationReport(ApplicationId)}. 256 * </p> 257 * 258 * @return a list of reports of all running applications 259 * @throws YarnException 260 * @throws IOException 261 */ 262 public abstract List<ApplicationReport> getApplications() 263 throws YarnException, IOException; 264 265 /** 266 * <p> 267 * Get a report (ApplicationReport) of Applications 268 * matching the given application types in the cluster. 269 * </p> 270 * 271 * <p> 272 * If the user does not have <code>VIEW_APP</code> access for an application 273 * then the corresponding report will be filtered as described in 274 * {@link #getApplicationReport(ApplicationId)}. 275 * </p> 276 * 277 * @param applicationTypes set of application types you are interested in 278 * @return a list of reports of applications 279 * @throws YarnException 280 * @throws IOException 281 */ 282 public abstract List<ApplicationReport> getApplications( 283 Set<String> applicationTypes) throws YarnException, IOException; 284 285 /** 286 * <p> 287 * Get a report (ApplicationReport) of Applications matching the given 288 * application states in the cluster. 289 * </p> 290 * 291 * <p> 292 * If the user does not have <code>VIEW_APP</code> access for an application 293 * then the corresponding report will be filtered as described in 294 * {@link #getApplicationReport(ApplicationId)}. 295 * </p> 296 * 297 * @param applicationStates set of application states you are interested in 298 * @return a list of reports of applications 299 * @throws YarnException 300 * @throws IOException 301 */ 302 public abstract List<ApplicationReport> 303 getApplications(EnumSet<YarnApplicationState> applicationStates) 304 throws YarnException, IOException; 305 306 /** 307 * <p> 308 * Get a report (ApplicationReport) of Applications matching the given 309 * application types and application states in the cluster. 310 * </p> 311 * 312 * <p> 313 * If the user does not have <code>VIEW_APP</code> access for an application 314 * then the corresponding report will be filtered as described in 315 * {@link #getApplicationReport(ApplicationId)}. 316 * </p> 317 * 318 * @param applicationTypes set of application types you are interested in 319 * @param applicationStates set of application states you are interested in 320 * @return a list of reports of applications 321 * @throws YarnException 322 * @throws IOException 323 */ 324 public abstract List<ApplicationReport> getApplications( 325 Set<String> applicationTypes, 326 EnumSet<YarnApplicationState> applicationStates) throws YarnException, 327 IOException; 328 329 /** 330 * <p> 331 * Get a report (ApplicationReport) of Applications matching the given users, 332 * queues, application types and application states in the cluster. If any of 333 * the params is set to null, it is not used when filtering. 334 * </p> 335 * 336 * <p> 337 * If the user does not have <code>VIEW_APP</code> access for an application 338 * then the corresponding report will be filtered as described in 339 * {@link #getApplicationReport(ApplicationId)}. 340 * </p> 341 * 342 * @param queues set of queues you are interested in 343 * @param users set of users you are interested in 344 * @param applicationTypes set of application types you are interested in 345 * @param applicationStates set of application states you are interested in 346 * @return a list of reports of applications 347 * @throws YarnException 348 * @throws IOException 349 */ 350 public abstract List<ApplicationReport> getApplications(Set<String> queues, 351 Set<String> users, Set<String> applicationTypes, 352 EnumSet<YarnApplicationState> applicationStates) throws YarnException, 353 IOException; 354 355 /** 356 * <p> 357 * Get metrics ({@link YarnClusterMetrics}) about the cluster. 358 * </p> 359 * 360 * @return cluster metrics 361 * @throws YarnException 362 * @throws IOException 363 */ 364 public abstract YarnClusterMetrics getYarnClusterMetrics() throws YarnException, 365 IOException; 366 367 /** 368 * <p> 369 * Get a report of nodes ({@link NodeReport}) in the cluster. 370 * </p> 371 * 372 * @param states The {@link NodeState}s to filter on. If no filter states are 373 * given, nodes in all states will be returned. 374 * @return A list of node reports 375 * @throws YarnException 376 * @throws IOException 377 */ 378 public abstract List<NodeReport> getNodeReports(NodeState... states) 379 throws YarnException, IOException; 380 381 /** 382 * <p> 383 * Get a delegation token so as to be able to talk to YARN using those tokens. 384 * 385 * @param renewer 386 * Address of the renewer who can renew these tokens when needed by 387 * securely talking to YARN. 388 * @return a delegation token ({@link Token}) that can be used to 389 * talk to YARN 390 * @throws YarnException 391 * @throws IOException 392 */ 393 public abstract Token getRMDelegationToken(Text renewer) 394 throws YarnException, IOException; 395 396 /** 397 * <p> 398 * Get information ({@link QueueInfo}) about a given <em>queue</em>. 399 * </p> 400 * 401 * @param queueName 402 * Name of the queue whose information is needed 403 * @return queue information 404 * @throws YarnException 405 * in case of errors or if YARN rejects the request due to 406 * access-control restrictions. 407 * @throws IOException 408 */ 409 public abstract QueueInfo getQueueInfo(String queueName) throws YarnException, 410 IOException; 411 412 /** 413 * <p> 414 * Get information ({@link QueueInfo}) about all queues, recursively if there 415 * is a hierarchy 416 * </p> 417 * 418 * @return a list of queue-information for all queues 419 * @throws YarnException 420 * @throws IOException 421 */ 422 public abstract List<QueueInfo> getAllQueues() throws YarnException, IOException; 423 424 /** 425 * <p> 426 * Get information ({@link QueueInfo}) about top level queues. 427 * </p> 428 * 429 * @return a list of queue-information for all the top-level queues 430 * @throws YarnException 431 * @throws IOException 432 */ 433 public abstract List<QueueInfo> getRootQueueInfos() throws YarnException, IOException; 434 435 /** 436 * <p> 437 * Get information ({@link QueueInfo}) about all the immediate children queues 438 * of the given queue 439 * </p> 440 * 441 * @param parent 442 * Name of the queue whose child-queues' information is needed 443 * @return a list of queue-information for all queues who are direct children 444 * of the given parent queue. 445 * @throws YarnException 446 * @throws IOException 447 */ 448 public abstract List<QueueInfo> getChildQueueInfos(String parent) throws YarnException, 449 IOException; 450 451 /** 452 * <p> 453 * Get information about <em>acls</em> for <em>current user</em> on all the 454 * existing queues. 455 * </p> 456 * 457 * @return a list of queue acls ({@link QueueUserACLInfo}) for 458 * <em>current user</em> 459 * @throws YarnException 460 * @throws IOException 461 */ 462 public abstract List<QueueUserACLInfo> getQueueAclsInfo() throws YarnException, 463 IOException; 464 465 /** 466 * <p> 467 * Get a report of the given ApplicationAttempt. 468 * </p> 469 * 470 * <p> 471 * In secure mode, <code>YARN</code> verifies access to the application, queue 472 * etc. before accepting the request. 473 * </p> 474 * 475 * @param applicationAttemptId 476 * {@link ApplicationAttemptId} of the application attempt that needs 477 * a report 478 * @return application attempt report 479 * @throws YarnException 480 * @throws ApplicationAttemptNotFoundException if application attempt 481 * not found 482 * @throws IOException 483 */ 484 public abstract ApplicationAttemptReport getApplicationAttemptReport( 485 ApplicationAttemptId applicationAttemptId) throws YarnException, IOException; 486 487 /** 488 * <p> 489 * Get a report of all (ApplicationAttempts) of Application in the cluster. 490 * </p> 491 * 492 * @param applicationId application id of the app 493 * @return a list of reports for all application attempts for specified 494 * application. 495 * @throws YarnException 496 * @throws IOException 497 */ 498 public abstract List<ApplicationAttemptReport> getApplicationAttempts( 499 ApplicationId applicationId) throws YarnException, IOException; 500 501 /** 502 * <p> 503 * Get a report of the given Container. 504 * </p> 505 * 506 * <p> 507 * In secure mode, <code>YARN</code> verifies access to the application, queue 508 * etc. before accepting the request. 509 * </p> 510 * 511 * @param containerId 512 * {@link ContainerId} of the container that needs a report 513 * @return container report 514 * @throws YarnException 515 * @throws ContainerNotFoundException if container not found. 516 * @throws IOException 517 */ 518 public abstract ContainerReport getContainerReport(ContainerId containerId) 519 throws YarnException, IOException; 520 521 /** 522 * <p> 523 * Get a report of all (Containers) of ApplicationAttempt in the cluster. 524 * </p> 525 * 526 * @param applicationAttemptId application attempt id 527 * @return a list of reports of all containers for specified application 528 * attempts 529 * @throws YarnException 530 * @throws IOException 531 */ 532 public abstract List<ContainerReport> getContainers( 533 ApplicationAttemptId applicationAttemptId) throws YarnException, 534 IOException; 535 536 /** 537 * <p> 538 * Attempts to move the given application to the given queue. 539 * </p> 540 * 541 * @param appId 542 * Application to move. 543 * @param queue 544 * Queue to place it in to. 545 * @throws YarnException 546 * @throws IOException 547 */ 548 public abstract void moveApplicationAcrossQueues(ApplicationId appId, 549 String queue) throws YarnException, IOException; 550 551 /** 552 * <p> 553 * Obtain a {@link GetNewReservationResponse} for a new reservation, 554 * which contains the {@link ReservationId} object. 555 * </p> 556 * 557 * @return The {@link GetNewReservationResponse} containing a new 558 * {@link ReservationId} object. 559 * @throws YarnException if reservation cannot be created. 560 * @throws IOException if reservation cannot be created. 561 */ 562 public abstract GetNewReservationResponse createReservation() 563 throws YarnException, IOException; 564 565 /** 566 * <p> 567 * The interface used by clients to submit a new reservation to the 568 * {@code ResourceManager}. 569 * </p> 570 * 571 * <p> 572 * The client packages all details of its request in a 573 * {@link ReservationSubmissionRequest} object. This contains information 574 * about the amount of capacity, temporal constraints, and gang needs. 575 * Furthermore, the reservation might be composed of multiple stages, with 576 * ordering dependencies among them. 577 * </p> 578 * 579 * <p> 580 * In order to respond, a new admission control component in the 581 * {@code ResourceManager} performs an analysis of the resources that have 582 * been committed over the period of time the user is requesting, verify that 583 * the user requests can be fulfilled, and that it respect a sharing policy 584 * (e.g., {@code CapacityOverTimePolicy}). Once it has positively determined 585 * that the ReservationRequest is satisfiable the {@code ResourceManager} 586 * answers with a {@link ReservationSubmissionResponse} that includes a 587 * {@link ReservationId}. Upon failure to find a valid allocation the response 588 * is an exception with the message detailing the reason of failure. 589 * </p> 590 * 591 * <p> 592 * The semantics guarantees that the {@link ReservationId} returned, 593 * corresponds to a valid reservation existing in the time-range request by 594 * the user. The amount of capacity dedicated to such reservation can vary 595 * overtime, depending of the allocation that has been determined. But it is 596 * guaranteed to satisfy all the constraint expressed by the user in the 597 * {@link ReservationDefinition} 598 * </p> 599 * 600 * @param request request to submit a new Reservation 601 * @return response contains the {@link ReservationId} on accepting the 602 * submission 603 * @throws YarnException if the reservation cannot be created successfully 604 * @throws IOException 605 * 606 */ 607 @Public 608 @Unstable 609 public abstract ReservationSubmissionResponse submitReservation( 610 ReservationSubmissionRequest request) throws YarnException, IOException; 611 612 /** 613 * <p> 614 * The interface used by clients to update an existing Reservation. This is 615 * referred to as a re-negotiation process, in which a user that has 616 * previously submitted a Reservation. 617 * </p> 618 * 619 * <p> 620 * The allocation is attempted by virtually substituting all previous 621 * allocations related to this Reservation with new ones, that satisfy the new 622 * {@link ReservationDefinition}. Upon success the previous allocation is 623 * atomically substituted by the new one, and on failure (i.e., if the system 624 * cannot find a valid allocation for the updated request), the previous 625 * allocation remains valid. 626 * </p> 627 * 628 * @param request to update an existing Reservation (the 629 * {@link ReservationUpdateRequest} should refer to an existing valid 630 * {@link ReservationId}) 631 * @return response empty on successfully updating the existing reservation 632 * @throws YarnException if the request is invalid or reservation cannot be 633 * updated successfully 634 * @throws IOException 635 * 636 */ 637 @Public 638 @Unstable 639 public abstract ReservationUpdateResponse updateReservation( 640 ReservationUpdateRequest request) throws YarnException, IOException; 641 642 /** 643 * <p> 644 * The interface used by clients to remove an existing Reservation. 645 * </p> 646 * 647 * @param request to remove an existing Reservation (the 648 * {@link ReservationDeleteRequest} should refer to an existing valid 649 * {@link ReservationId}) 650 * @return response empty on successfully deleting the existing reservation 651 * @throws YarnException if the request is invalid or reservation cannot be 652 * deleted successfully 653 * @throws IOException 654 * 655 */ 656 @Public 657 @Unstable 658 public abstract ReservationDeleteResponse deleteReservation( 659 ReservationDeleteRequest request) throws YarnException, IOException; 660 661 /** 662 * <p> 663 * The interface used by clients to get the list of reservations in a plan. 664 * The reservationId will be used to search for reservations to list if it is 665 * provided. Otherwise, it will select active reservations within the 666 * startTime and endTime (inclusive). 667 * </p> 668 * 669 * @param request to list reservations in a plan. Contains fields to select 670 * String queue, ReservationId reservationId, long startTime, 671 * long endTime, and a bool includeReservationAllocations. 672 * 673 * queue: Required. Cannot be null or empty. Refers to the 674 * reservable queue in the scheduler that was selected when 675 * creating a reservation submission 676 * {@link ReservationSubmissionRequest}. 677 * 678 * reservationId: Optional. If provided, other fields will 679 * be ignored. 680 * 681 * startTime: Optional. If provided, only reservations that 682 * end after the startTime will be selected. This defaults 683 * to 0 if an invalid number is used. 684 * 685 * endTime: Optional. If provided, only reservations that 686 * start on or before endTime will be selected. This defaults 687 * to Long.MAX_VALUE if an invalid number is used. 688 * 689 * includeReservationAllocations: Optional. Flag that 690 * determines whether the entire reservation allocations are 691 * to be returned. Reservation allocations are subject to 692 * change in the event of re-planning as described by 693 * {@link ReservationDefinition}. 694 * 695 * @return response that contains information about reservations that are 696 * being searched for. 697 * @throws YarnException if the request is invalid 698 * @throws IOException if the request failed otherwise 699 * 700 */ 701 @Public 702 @Unstable 703 public abstract ReservationListResponse listReservations( 704 ReservationListRequest request) throws YarnException, IOException; 705 706 /** 707 * <p> 708 * The interface used by client to get node to labels mappings in existing cluster 709 * </p> 710 * 711 * @return node to labels mappings 712 * @throws YarnException 713 * @throws IOException 714 */ 715 @Public 716 @Unstable 717 public abstract Map<NodeId, Set<String>> getNodeToLabels() 718 throws YarnException, IOException; 719 720 /** 721 * <p> 722 * The interface used by client to get labels to nodes mapping 723 * in existing cluster 724 * </p> 725 * 726 * @return node to labels mappings 727 * @throws YarnException 728 * @throws IOException 729 */ 730 @Public 731 @Unstable 732 public abstract Map<String, Set<NodeId>> getLabelsToNodes() 733 throws YarnException, IOException; 734 735 /** 736 * <p> 737 * The interface used by client to get labels to nodes mapping 738 * for specified labels in existing cluster 739 * </p> 740 * 741 * @param labels labels for which labels to nodes mapping has to be retrieved 742 * @return labels to nodes mappings for specific labels 743 * @throws YarnException 744 * @throws IOException 745 */ 746 @Public 747 @Unstable 748 public abstract Map<String, Set<NodeId>> getLabelsToNodes( 749 Set<String> labels) throws YarnException, IOException; 750 751 /** 752 * <p> 753 * The interface used by client to get node labels in the cluster 754 * </p> 755 * 756 * @return cluster node labels collection 757 * @throws YarnException when there is a failure in 758 * {@link ApplicationClientProtocol} 759 * @throws IOException when there is a failure in 760 * {@link ApplicationClientProtocol} 761 */ 762 @Public 763 @Unstable 764 public abstract List<NodeLabel> getClusterNodeLabels() 765 throws YarnException, IOException; 766 767 /** 768 * <p> 769 * The interface used by client to set priority of an application 770 * </p> 771 * @param applicationId 772 * @param priority 773 * @return updated priority of an application. 774 * @throws YarnException 775 * @throws IOException 776 */ 777 @Public 778 @Unstable 779 public abstract Priority updateApplicationPriority( 780 ApplicationId applicationId, 781 Priority priority) throws YarnException, IOException; 782 783 /** 784 * <p> 785 * Signal a container identified by given ID. 786 * </p> 787 * 788 * @param containerId 789 * {@link ContainerId} of the container that needs to be signaled 790 * @param command the signal container command 791 * @throws YarnException 792 * @throws IOException 793 */ 794 public abstract void signalToContainer(ContainerId containerId, 795 SignalContainerCommand command) throws YarnException, IOException; 796}