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; 020 021 import org.apache.hadoop.classification.InterfaceAudience.Public; 022 import org.apache.hadoop.classification.InterfaceStability.Evolving; 023 import org.apache.hadoop.security.UserGroupInformation; 024 import org.apache.hadoop.util.Shell; 025 026 /** 027 * This is the API for the applications comprising of constants that YARN sets 028 * up for the applications and the containers. 029 * 030 * TODO: Investigate the semantics and security of each cross-boundary refs. 031 */ 032 @Public 033 @Evolving 034 public interface ApplicationConstants { 035 036 /** 037 * The environment variable for APP_SUBMIT_TIME. Set in AppMaster environment 038 * only 039 */ 040 public static final String APP_SUBMIT_TIME_ENV = "APP_SUBMIT_TIME_ENV"; 041 042 /** 043 * The cache file into which container token is written 044 */ 045 public static final String CONTAINER_TOKEN_FILE_ENV_NAME = 046 UserGroupInformation.HADOOP_TOKEN_FILE_LOCATION; 047 048 /** 049 * The environmental variable for APPLICATION_WEB_PROXY_BASE. Set in 050 * ApplicationMaster's environment only. This states that for all non-relative 051 * web URLs in the app masters web UI what base should they have. 052 */ 053 public static final String APPLICATION_WEB_PROXY_BASE_ENV = 054 "APPLICATION_WEB_PROXY_BASE"; 055 056 /** 057 * The temporary environmental variable for container log directory. This 058 * should be replaced by real container log directory on container launch. 059 */ 060 public static final String LOG_DIR_EXPANSION_VAR = "<LOG_DIR>"; 061 062 public static final String STDERR = "stderr"; 063 064 public static final String STDOUT = "stdout"; 065 066 /** 067 * The environment variable for MAX_APP_ATTEMPTS. Set in AppMaster environment 068 * only 069 */ 070 public static final String MAX_APP_ATTEMPTS_ENV = "MAX_APP_ATTEMPTS"; 071 072 /** 073 * Environment for Applications. 074 * 075 * Some of the environment variables for applications are <em>final</em> 076 * i.e. they cannot be modified by the applications. 077 */ 078 public enum Environment { 079 /** 080 * $USER 081 * Final, non-modifiable. 082 */ 083 USER(Shell.WINDOWS ? "USERNAME": "USER"), 084 085 /** 086 * $LOGNAME 087 * Final, non-modifiable. 088 */ 089 LOGNAME("LOGNAME"), 090 091 /** 092 * $HOME 093 * Final, non-modifiable. 094 */ 095 HOME("HOME"), 096 097 /** 098 * $PWD 099 * Final, non-modifiable. 100 */ 101 PWD("PWD"), 102 103 /** 104 * $PATH 105 */ 106 PATH("PATH"), 107 108 /** 109 * $SHELL 110 */ 111 SHELL("SHELL"), 112 113 /** 114 * $JAVA_HOME 115 */ 116 JAVA_HOME("JAVA_HOME"), 117 118 /** 119 * $CLASSPATH 120 */ 121 CLASSPATH("CLASSPATH"), 122 123 /** 124 * $APP_CLASSPATH 125 */ 126 APP_CLASSPATH("APP_CLASSPATH"), 127 128 /** 129 * $LD_LIBRARY_PATH 130 */ 131 LD_LIBRARY_PATH("LD_LIBRARY_PATH"), 132 133 /** 134 * $HADOOP_CONF_DIR 135 * Final, non-modifiable. 136 */ 137 HADOOP_CONF_DIR("HADOOP_CONF_DIR"), 138 139 /** 140 * $HADOOP_COMMON_HOME 141 */ 142 HADOOP_COMMON_HOME("HADOOP_COMMON_HOME"), 143 144 /** 145 * $HADOOP_HDFS_HOME 146 */ 147 HADOOP_HDFS_HOME("HADOOP_HDFS_HOME"), 148 149 /** 150 * $MALLOC_ARENA_MAX 151 */ 152 MALLOC_ARENA_MAX("MALLOC_ARENA_MAX"), 153 154 /** 155 * $HADOOP_YARN_HOME 156 */ 157 HADOOP_YARN_HOME("HADOOP_YARN_HOME"), 158 159 /** 160 * $CONTAINER_ID 161 * Final, exported by NodeManager and non-modifiable by users. 162 */ 163 CONTAINER_ID("CONTAINER_ID"), 164 165 /** 166 * $NM_HOST 167 * Final, exported by NodeManager and non-modifiable by users. 168 */ 169 NM_HOST("NM_HOST"), 170 171 /** 172 * $NM_HTTP_PORT 173 * Final, exported by NodeManager and non-modifiable by users. 174 */ 175 NM_HTTP_PORT("NM_HTTP_PORT"), 176 177 /** 178 * $NM_PORT 179 * Final, exported by NodeManager and non-modifiable by users. 180 */ 181 NM_PORT("NM_PORT"), 182 183 /** 184 * $LOCAL_DIRS 185 * Final, exported by NodeManager and non-modifiable by users. 186 */ 187 LOCAL_DIRS("LOCAL_DIRS"), 188 189 /** 190 * $LOG_DIRS 191 * Final, exported by NodeManager and non-modifiable by users. 192 * Comma separate list of directories that the container should use for 193 * logging. 194 */ 195 LOG_DIRS("LOG_DIRS"); 196 197 private final String variable; 198 private Environment(String variable) { 199 this.variable = variable; 200 } 201 202 public String key() { 203 return variable; 204 } 205 206 public String toString() { 207 return variable; 208 } 209 210 public String $() { 211 if (Shell.WINDOWS) { 212 return "%" + variable + "%"; 213 } else { 214 return "$" + variable; 215 } 216 } 217 } 218 }