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 019 package org.apache.hadoop.yarn.api.protocolrecords; 020 021 import java.nio.ByteBuffer; 022 import java.util.Map; 023 024 import org.apache.hadoop.classification.InterfaceAudience.Private; 025 import org.apache.hadoop.classification.InterfaceAudience.Public; 026 import org.apache.hadoop.classification.InterfaceStability.Stable; 027 import org.apache.hadoop.classification.InterfaceStability.Unstable; 028 import org.apache.hadoop.yarn.api.ApplicationMasterProtocol; 029 import org.apache.hadoop.yarn.api.records.ApplicationAccessType; 030 import org.apache.hadoop.yarn.api.records.Resource; 031 import org.apache.hadoop.yarn.util.Records; 032 033 /** 034 * <p>The response sent by the <code>ResourceManager</code> to a new 035 * <code>ApplicationMaster</code> on registration.</p> 036 * 037 * <p>The response contains critical details such as: 038 * <ul> 039 * <li>Maximum capability for allocated resources in the cluster.</li> 040 * <li><code>ApplicationACL</code>s for the application.</li> 041 * <li>ClientToAMToken master key.</li> 042 * </ul> 043 * </p> 044 * 045 * @see ApplicationMasterProtocol#registerApplicationMaster(RegisterApplicationMasterRequest) 046 */ 047 @Public 048 @Stable 049 public abstract class RegisterApplicationMasterResponse { 050 @Private 051 @Unstable 052 public static RegisterApplicationMasterResponse newInstance( 053 Resource minCapability, Resource maxCapability, 054 Map<ApplicationAccessType, String> acls, ByteBuffer key) { 055 RegisterApplicationMasterResponse response = 056 Records.newRecord(RegisterApplicationMasterResponse.class); 057 response.setMaximumResourceCapability(maxCapability); 058 response.setApplicationACLs(acls); 059 response.setClientToAMTokenMasterKey(key); 060 return response; 061 } 062 063 /** 064 * Get the maximum capability for any {@link Resource} allocated by the 065 * <code>ResourceManager</code> in the cluster. 066 * @return maximum capability of allocated resources in the cluster 067 */ 068 @Public 069 @Stable 070 public abstract Resource getMaximumResourceCapability(); 071 072 @Private 073 @Unstable 074 public abstract void setMaximumResourceCapability(Resource capability); 075 076 /** 077 * Get the <code>ApplicationACL</code>s for the application. 078 * @return all the <code>ApplicationACL</code>s 079 */ 080 @Public 081 @Stable 082 public abstract Map<ApplicationAccessType, String> getApplicationACLs(); 083 084 /** 085 * Set the <code>ApplicationACL</code>s for the application. 086 * @param acls 087 */ 088 @Private 089 @Unstable 090 public abstract void setApplicationACLs(Map<ApplicationAccessType, String> acls); 091 092 /** 093 * <p>Get ClientToAMToken master key.</p> 094 * <p>The ClientToAMToken master key is sent to <code>ApplicationMaster</code> 095 * by <code>ResourceManager</code> via {@link RegisterApplicationMasterResponse} 096 * , used to verify corresponding ClientToAMToken.</p> 097 */ 098 @Public 099 @Stable 100 public abstract ByteBuffer getClientToAMTokenMasterKey(); 101 102 /** 103 * Set ClientToAMToken master key. 104 */ 105 @Public 106 @Stable 107 public abstract void setClientToAMTokenMasterKey(ByteBuffer key); 108 }