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.conf;
020
021import java.net.InetSocketAddress;
022import java.util.Arrays;
023import java.util.Collections;
024import java.util.List;
025
026import org.apache.hadoop.HadoopIllegalArgumentException;
027import org.apache.hadoop.classification.InterfaceAudience.Private;
028import org.apache.hadoop.classification.InterfaceAudience.Public;
029import org.apache.hadoop.classification.InterfaceStability.Evolving;
030import org.apache.hadoop.classification.InterfaceStability.Unstable;
031import org.apache.hadoop.conf.Configuration;
032import org.apache.hadoop.http.HttpConfig;
033import org.apache.hadoop.net.NetUtils;
034import org.apache.hadoop.security.authorize.ProxyUsers;
035import org.apache.hadoop.util.StringUtils;
036import org.apache.hadoop.yarn.api.ApplicationConstants;
037
038@Public
039@Evolving
040public class YarnConfiguration extends Configuration {
041
042  @Private
043  public static final String CS_CONFIGURATION_FILE= "capacity-scheduler.xml";
044
045  @Private
046  public static final String HADOOP_POLICY_CONFIGURATION_FILE =
047      "hadoop-policy.xml";
048
049  @Private
050  public static final String YARN_SITE_CONFIGURATION_FILE = "yarn-site.xml";
051
052  private static final String YARN_DEFAULT_CONFIGURATION_FILE =
053      "yarn-default.xml";
054
055  @Private
056  public static final String CORE_SITE_CONFIGURATION_FILE = "core-site.xml";
057
058  @Private
059  public static final List<String> RM_CONFIGURATION_FILES =
060      Collections.unmodifiableList(Arrays.asList(
061          CS_CONFIGURATION_FILE,
062          HADOOP_POLICY_CONFIGURATION_FILE,
063          YARN_SITE_CONFIGURATION_FILE,
064          CORE_SITE_CONFIGURATION_FILE));
065
066  @Evolving
067  public static final int APPLICATION_MAX_TAGS = 10;
068
069  @Evolving
070  public static final int APPLICATION_MAX_TAG_LENGTH = 100;
071
072  static {
073    addDeprecatedKeys();
074    Configuration.addDefaultResource(YARN_DEFAULT_CONFIGURATION_FILE);
075    Configuration.addDefaultResource(YARN_SITE_CONFIGURATION_FILE);
076  }
077
078  private static void addDeprecatedKeys() {
079    Configuration.addDeprecations(new DeprecationDelta[] {
080        new DeprecationDelta("yarn.client.max-nodemanagers-proxies",
081            NM_CLIENT_MAX_NM_PROXIES)
082    });
083  }
084
085  //Configurations
086
087  public static final String YARN_PREFIX = "yarn.";
088
089  /** Delay before deleting resource to ease debugging of NM issues */
090  public static final String DEBUG_NM_DELETE_DELAY_SEC =
091    YarnConfiguration.NM_PREFIX + "delete.debug-delay-sec";
092  
093  ////////////////////////////////
094  // IPC Configs
095  ////////////////////////////////
096  public static final String IPC_PREFIX = YARN_PREFIX + "ipc.";
097
098  /** Factory to create client IPC classes.*/
099  public static final String IPC_CLIENT_FACTORY_CLASS =
100    IPC_PREFIX + "client.factory.class";
101  public static final String DEFAULT_IPC_CLIENT_FACTORY_CLASS = 
102      "org.apache.hadoop.yarn.factories.impl.pb.RpcClientFactoryPBImpl";
103
104  /** Factory to create server IPC classes.*/
105  public static final String IPC_SERVER_FACTORY_CLASS = 
106    IPC_PREFIX + "server.factory.class";
107  public static final String DEFAULT_IPC_SERVER_FACTORY_CLASS = 
108      "org.apache.hadoop.yarn.factories.impl.pb.RpcServerFactoryPBImpl";
109
110  /** Factory to create serializeable records.*/
111  public static final String IPC_RECORD_FACTORY_CLASS = 
112    IPC_PREFIX + "record.factory.class";
113  public static final String DEFAULT_IPC_RECORD_FACTORY_CLASS = 
114      "org.apache.hadoop.yarn.factories.impl.pb.RecordFactoryPBImpl";
115
116  /** RPC class implementation*/
117  public static final String IPC_RPC_IMPL =
118    IPC_PREFIX + "rpc.class";
119  public static final String DEFAULT_IPC_RPC_IMPL = 
120    "org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC";
121  
122  ////////////////////////////////
123  // Resource Manager Configs
124  ////////////////////////////////
125  public static final String RM_PREFIX = "yarn.resourcemanager.";
126
127  public static final String RM_CLUSTER_ID = RM_PREFIX + "cluster-id";
128
129  public static final String RM_HOSTNAME = RM_PREFIX + "hostname";
130
131  /** The address of the applications manager interface in the RM.*/
132  public static final String RM_ADDRESS = 
133    RM_PREFIX + "address";
134  public static final int DEFAULT_RM_PORT = 8032;
135  public static final String DEFAULT_RM_ADDRESS =
136    "0.0.0.0:" + DEFAULT_RM_PORT;
137
138  /** The actual bind address for the RM.*/
139  public static final String RM_BIND_HOST =
140    RM_PREFIX + "bind-host";
141
142  /** The number of threads used to handle applications manager requests.*/
143  public static final String RM_CLIENT_THREAD_COUNT =
144    RM_PREFIX + "client.thread-count";
145  public static final int DEFAULT_RM_CLIENT_THREAD_COUNT = 50;
146
147  /** The Kerberos principal for the resource manager.*/
148  public static final String RM_PRINCIPAL =
149    RM_PREFIX + "principal";
150  
151  /** The address of the scheduler interface.*/
152  public static final String RM_SCHEDULER_ADDRESS = 
153    RM_PREFIX + "scheduler.address";
154  public static final int DEFAULT_RM_SCHEDULER_PORT = 8030;
155  public static final String DEFAULT_RM_SCHEDULER_ADDRESS = "0.0.0.0:" +
156    DEFAULT_RM_SCHEDULER_PORT;
157
158  /** Miniumum request grant-able by the RM scheduler. */
159  public static final String RM_SCHEDULER_MINIMUM_ALLOCATION_MB =
160    YARN_PREFIX + "scheduler.minimum-allocation-mb";
161  public static final int DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB = 1024;
162  public static final String RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES =
163      YARN_PREFIX + "scheduler.minimum-allocation-vcores";
164    public static final int DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES = 1;
165
166  /** Maximum request grant-able by the RM scheduler. */
167  public static final String RM_SCHEDULER_MAXIMUM_ALLOCATION_MB =
168    YARN_PREFIX + "scheduler.maximum-allocation-mb";
169  public static final int DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB = 8192;
170  public static final String RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES =
171      YARN_PREFIX + "scheduler.maximum-allocation-vcores";
172  public static final int DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES = 4;
173
174  /** Number of threads to handle scheduler interface.*/
175  public static final String RM_SCHEDULER_CLIENT_THREAD_COUNT =
176    RM_PREFIX + "scheduler.client.thread-count";
177  public static final int DEFAULT_RM_SCHEDULER_CLIENT_THREAD_COUNT = 50;
178
179  /** If the port should be included or not in the node name. The node name
180   * is used by the scheduler for resource requests allocation location 
181   * matching. Typically this is just the hostname, using the port is needed
182   * when using minicluster and specific NM are required.*/
183  public static final String RM_SCHEDULER_INCLUDE_PORT_IN_NODE_NAME =
184      YARN_PREFIX + "scheduler.include-port-in-node-name";
185  public static final boolean DEFAULT_RM_SCHEDULER_USE_PORT_FOR_NODE_NAME = 
186      false;
187
188  /** Enable Resource Manager webapp ui actions */
189  public static final String RM_WEBAPP_UI_ACTIONS_ENABLED =
190    RM_PREFIX + "webapp.ui-actions.enabled";
191  public static final boolean DEFAULT_RM_WEBAPP_UI_ACTIONS_ENABLED =
192    true;
193
194  /** Whether the RM should enable Reservation System */
195  public static final String RM_RESERVATION_SYSTEM_ENABLE = RM_PREFIX
196      + "reservation-system.enable";
197  public static final boolean DEFAULT_RM_RESERVATION_SYSTEM_ENABLE = false;
198
199  /** The class to use as the Reservation System. */
200  public static final String RM_RESERVATION_SYSTEM_CLASS = RM_PREFIX
201      + "reservation-system.class";
202
203  /** The PlanFollower for the Reservation System. */
204  public static final String RM_RESERVATION_SYSTEM_PLAN_FOLLOWER = RM_PREFIX
205      + "reservation-system.plan.follower";
206
207  /** The step size of the Reservation System. */
208  public static final String RM_RESERVATION_SYSTEM_PLAN_FOLLOWER_TIME_STEP =
209      RM_PREFIX + "reservation-system.planfollower.time-step";
210  public static final long DEFAULT_RM_RESERVATION_SYSTEM_PLAN_FOLLOWER_TIME_STEP =
211      1000L;
212
213  /**
214   * Enable periodic monitor threads.
215   * @see #RM_SCHEDULER_MONITOR_POLICIES
216   */
217  public static final String RM_SCHEDULER_ENABLE_MONITORS =
218    RM_PREFIX + "scheduler.monitor.enable";
219  public static final boolean DEFAULT_RM_SCHEDULER_ENABLE_MONITORS = false;
220
221  /** List of SchedulingEditPolicy classes affecting the scheduler. */
222  public static final String RM_SCHEDULER_MONITOR_POLICIES =
223    RM_PREFIX + "scheduler.monitor.policies";
224
225  /** The address of the RM web application.*/
226  public static final String RM_WEBAPP_ADDRESS = 
227    RM_PREFIX + "webapp.address";
228
229  public static final int DEFAULT_RM_WEBAPP_PORT = 8088;
230  public static final String DEFAULT_RM_WEBAPP_ADDRESS = "0.0.0.0:" +
231    DEFAULT_RM_WEBAPP_PORT;
232  
233  /** The https address of the RM web application.*/
234  public static final String RM_WEBAPP_HTTPS_ADDRESS =
235      RM_PREFIX + "webapp.https.address";
236  public static final boolean YARN_SSL_CLIENT_HTTPS_NEED_AUTH_DEFAULT = false;
237  public static final String YARN_SSL_SERVER_RESOURCE_DEFAULT = "ssl-server.xml";
238  
239  public static final int DEFAULT_RM_WEBAPP_HTTPS_PORT = 8090;
240  public static final String DEFAULT_RM_WEBAPP_HTTPS_ADDRESS = "0.0.0.0:"
241      + DEFAULT_RM_WEBAPP_HTTPS_PORT;
242  
243  public static final String RM_RESOURCE_TRACKER_ADDRESS =
244    RM_PREFIX + "resource-tracker.address";
245  public static final int DEFAULT_RM_RESOURCE_TRACKER_PORT = 8031;
246  public static final String DEFAULT_RM_RESOURCE_TRACKER_ADDRESS =
247    "0.0.0.0:" + DEFAULT_RM_RESOURCE_TRACKER_PORT;
248
249  /** The expiry interval for application master reporting.*/
250  public static final String RM_AM_EXPIRY_INTERVAL_MS = 
251    YARN_PREFIX  + "am.liveness-monitor.expiry-interval-ms";
252  public static final int DEFAULT_RM_AM_EXPIRY_INTERVAL_MS = 600000;
253
254  /** How long to wait until a node manager is considered dead.*/
255  public static final String RM_NM_EXPIRY_INTERVAL_MS = 
256    YARN_PREFIX + "nm.liveness-monitor.expiry-interval-ms";
257  public static final int DEFAULT_RM_NM_EXPIRY_INTERVAL_MS = 600000;
258
259  /** Are acls enabled.*/
260  public static final String YARN_ACL_ENABLE = 
261    YARN_PREFIX + "acl.enable";
262  public static final boolean DEFAULT_YARN_ACL_ENABLE = false;
263  
264  /** ACL of who can be admin of YARN cluster.*/
265  public static final String YARN_ADMIN_ACL = 
266    YARN_PREFIX + "admin.acl";
267  public static final String DEFAULT_YARN_ADMIN_ACL = "*";
268  
269  /** ACL used in case none is found. Allows nothing. */
270  public static final String DEFAULT_YARN_APP_ACL = " ";
271
272  /** The address of the RM admin interface.*/
273  public static final String RM_ADMIN_ADDRESS = 
274    RM_PREFIX + "admin.address";
275  public static final int DEFAULT_RM_ADMIN_PORT = 8033;
276  public static final String DEFAULT_RM_ADMIN_ADDRESS = "0.0.0.0:" +
277      DEFAULT_RM_ADMIN_PORT;
278  
279  /**Number of threads used to handle RM admin interface.*/
280  public static final String RM_ADMIN_CLIENT_THREAD_COUNT =
281    RM_PREFIX + "admin.client.thread-count";
282  public static final int DEFAULT_RM_ADMIN_CLIENT_THREAD_COUNT = 1;
283  
284  /**
285   * The maximum number of application attempts.
286   * It's a global setting for all application masters.
287   */
288  public static final String RM_AM_MAX_ATTEMPTS =
289    RM_PREFIX + "am.max-attempts";
290  public static final int DEFAULT_RM_AM_MAX_ATTEMPTS = 2;
291  
292  /** The keytab for the resource manager.*/
293  public static final String RM_KEYTAB = 
294    RM_PREFIX + "keytab";
295
296  /**The kerberos principal to be used for spnego filter for RM.*/
297  public static final String RM_WEBAPP_SPNEGO_USER_NAME_KEY =
298      RM_PREFIX + "webapp.spnego-principal";
299  
300  /**The kerberos keytab to be used for spnego filter for RM.*/
301  public static final String RM_WEBAPP_SPNEGO_KEYTAB_FILE_KEY =
302      RM_PREFIX + "webapp.spnego-keytab-file";
303
304  /**
305   * Flag to enable override of the default kerberos authentication filter with
306   * the RM authentication filter to allow authentication using delegation
307   * tokens(fallback to kerberos if the tokens are missing). Only applicable
308   * when the http authentication type is kerberos.
309   */
310  public static final String RM_WEBAPP_DELEGATION_TOKEN_AUTH_FILTER = RM_PREFIX
311      + "webapp.delegation-token-auth-filter.enabled";
312  public static final boolean DEFAULT_RM_WEBAPP_DELEGATION_TOKEN_AUTH_FILTER =
313      true;
314
315  /** How long to wait until a container is considered dead.*/
316  public static final String RM_CONTAINER_ALLOC_EXPIRY_INTERVAL_MS = 
317    RM_PREFIX + "rm.container-allocation.expiry-interval-ms";
318  public static final int DEFAULT_RM_CONTAINER_ALLOC_EXPIRY_INTERVAL_MS = 600000;
319  
320  /** Path to file with nodes to include.*/
321  public static final String RM_NODES_INCLUDE_FILE_PATH = 
322    RM_PREFIX + "nodes.include-path";
323  public static final String DEFAULT_RM_NODES_INCLUDE_FILE_PATH = "";
324  
325  /** Path to file with nodes to exclude.*/
326  public static final String RM_NODES_EXCLUDE_FILE_PATH = 
327    RM_PREFIX + "nodes.exclude-path";
328  public static final String DEFAULT_RM_NODES_EXCLUDE_FILE_PATH = "";
329  
330  /** Number of threads to handle resource tracker calls.*/
331  public static final String RM_RESOURCE_TRACKER_CLIENT_THREAD_COUNT =
332    RM_PREFIX + "resource-tracker.client.thread-count";
333  public static final int DEFAULT_RM_RESOURCE_TRACKER_CLIENT_THREAD_COUNT = 50;
334  
335  /** The class to use as the resource scheduler.*/
336  public static final String RM_SCHEDULER = 
337    RM_PREFIX + "scheduler.class";
338 
339  public static final String DEFAULT_RM_SCHEDULER = 
340      "org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler";
341
342  /** RM set next Heartbeat interval for NM */
343  public static final String RM_NM_HEARTBEAT_INTERVAL_MS =
344      RM_PREFIX + "nodemanagers.heartbeat-interval-ms";
345  public static final long DEFAULT_RM_NM_HEARTBEAT_INTERVAL_MS = 1000;
346
347  /** Number of worker threads that write the history data. */
348  public static final String RM_HISTORY_WRITER_MULTI_THREADED_DISPATCHER_POOL_SIZE =
349      RM_PREFIX + "history-writer.multi-threaded-dispatcher.pool-size";
350  public static final int DEFAULT_RM_HISTORY_WRITER_MULTI_THREADED_DISPATCHER_POOL_SIZE =
351      10;
352
353  /**
354   *  The setting that controls whether yarn system metrics is published on the
355   *  timeline server or not by RM.
356   */
357  public static final String RM_SYSTEM_METRICS_PUBLISHER_ENABLED =
358      RM_PREFIX + "system-metrics-publisher.enabled";
359  public static final boolean DEFAULT_RM_SYSTEM_METRICS_PUBLISHER_ENABLED = false;
360
361  public static final String RM_SYSTEM_METRICS_PUBLISHER_DISPATCHER_POOL_SIZE =
362      RM_PREFIX + "system-metrics-publisher.dispatcher.pool-size";
363  public static final int DEFAULT_RM_SYSTEM_METRICS_PUBLISHER_DISPATCHER_POOL_SIZE =
364      10;
365
366  //Delegation token related keys
367  public static final String  DELEGATION_KEY_UPDATE_INTERVAL_KEY = 
368    RM_PREFIX + "delegation.key.update-interval";
369  public static final long    DELEGATION_KEY_UPDATE_INTERVAL_DEFAULT = 
370    24*60*60*1000; // 1 day
371  public static final String  DELEGATION_TOKEN_RENEW_INTERVAL_KEY = 
372    RM_PREFIX + "delegation.token.renew-interval";
373  public static final long    DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT = 
374    24*60*60*1000;  // 1 day
375  public static final String  DELEGATION_TOKEN_MAX_LIFETIME_KEY = 
376     RM_PREFIX + "delegation.token.max-lifetime";
377  public static final long    DELEGATION_TOKEN_MAX_LIFETIME_DEFAULT = 
378    7*24*60*60*1000; // 7 days
379  
380  public static final String RECOVERY_ENABLED = RM_PREFIX + "recovery.enabled";
381  public static final boolean DEFAULT_RM_RECOVERY_ENABLED = false;
382
383  @Private
384  public static final String RM_WORK_PRESERVING_RECOVERY_ENABLED = RM_PREFIX
385      + "work-preserving-recovery.enabled";
386  @Private
387  public static final boolean DEFAULT_RM_WORK_PRESERVING_RECOVERY_ENABLED =
388      false;
389
390  public static final String RM_WORK_PRESERVING_RECOVERY_SCHEDULING_WAIT_MS =
391      RM_PREFIX + "work-preserving-recovery.scheduling-wait-ms";
392  public static final long DEFAULT_RM_WORK_PRESERVING_RECOVERY_SCHEDULING_WAIT_MS =
393      10000;
394
395  /** Zookeeper interaction configs */
396  public static final String RM_ZK_PREFIX = RM_PREFIX + "zk-";
397
398  public static final String RM_ZK_ADDRESS = RM_ZK_PREFIX + "address";
399
400  public static final String RM_ZK_NUM_RETRIES = RM_ZK_PREFIX + "num-retries";
401  public static final int DEFAULT_ZK_RM_NUM_RETRIES = 1000;
402
403  public static final String RM_ZK_RETRY_INTERVAL_MS =
404      RM_ZK_PREFIX + "retry-interval-ms";
405  public static final long DEFAULT_RM_ZK_RETRY_INTERVAL_MS = 1000;
406
407  public static final String RM_ZK_TIMEOUT_MS = RM_ZK_PREFIX + "timeout-ms";
408  public static final int DEFAULT_RM_ZK_TIMEOUT_MS = 10000;
409
410  public static final String RM_ZK_ACL = RM_ZK_PREFIX + "acl";
411  public static final String DEFAULT_RM_ZK_ACL = "world:anyone:rwcda";
412
413  public static final String RM_ZK_AUTH = RM_ZK_PREFIX + "auth";
414
415  public static final String ZK_STATE_STORE_PREFIX =
416      RM_PREFIX + "zk-state-store.";
417
418  /** Parent znode path under which ZKRMStateStore will create znodes */
419  public static final String ZK_RM_STATE_STORE_PARENT_PATH =
420      ZK_STATE_STORE_PREFIX + "parent-path";
421  public static final String DEFAULT_ZK_RM_STATE_STORE_PARENT_PATH = "/rmstore";
422
423  /** Root node ACLs for fencing */
424  public static final String ZK_RM_STATE_STORE_ROOT_NODE_ACL =
425      ZK_STATE_STORE_PREFIX + "root-node.acl";
426
427  /** HA related configs */
428  public static final String RM_HA_PREFIX = RM_PREFIX + "ha.";
429  public static final String RM_HA_ENABLED = RM_HA_PREFIX + "enabled";
430  public static final boolean DEFAULT_RM_HA_ENABLED = false;
431
432  public static final String RM_HA_IDS = RM_HA_PREFIX + "rm-ids";
433  public static final String RM_HA_ID = RM_HA_PREFIX + "id";
434
435  /** Store the related configuration files in File System */
436  public static final String FS_BASED_RM_CONF_STORE = RM_PREFIX
437      + "configuration.file-system-based-store";
438  public static final String DEFAULT_FS_BASED_RM_CONF_STORE = "/yarn/conf";
439
440  public static final String RM_CONFIGURATION_PROVIDER_CLASS = RM_PREFIX
441      + "configuration.provider-class";
442  public static final String DEFAULT_RM_CONFIGURATION_PROVIDER_CLASS =
443      "org.apache.hadoop.yarn.LocalConfigurationProvider";
444
445  private static final List<String> RM_SERVICES_ADDRESS_CONF_KEYS_HTTP =
446      Collections.unmodifiableList(Arrays.asList(
447          RM_ADDRESS,
448          RM_SCHEDULER_ADDRESS,
449          RM_ADMIN_ADDRESS,
450          RM_RESOURCE_TRACKER_ADDRESS,
451          RM_WEBAPP_ADDRESS));
452
453  private static final List<String> RM_SERVICES_ADDRESS_CONF_KEYS_HTTPS =
454      Collections.unmodifiableList(Arrays.asList(
455          RM_ADDRESS,
456          RM_SCHEDULER_ADDRESS,
457          RM_ADMIN_ADDRESS,
458          RM_RESOURCE_TRACKER_ADDRESS,
459          RM_WEBAPP_HTTPS_ADDRESS));
460
461  public static final String AUTO_FAILOVER_PREFIX =
462      RM_HA_PREFIX + "automatic-failover.";
463
464  public static final String AUTO_FAILOVER_ENABLED =
465      AUTO_FAILOVER_PREFIX + "enabled";
466  public static final boolean DEFAULT_AUTO_FAILOVER_ENABLED = true;
467
468  public static final String AUTO_FAILOVER_EMBEDDED =
469      AUTO_FAILOVER_PREFIX + "embedded";
470  public static final boolean DEFAULT_AUTO_FAILOVER_EMBEDDED = true;
471
472  public static final String AUTO_FAILOVER_ZK_BASE_PATH =
473      AUTO_FAILOVER_PREFIX + "zk-base-path";
474  public static final String DEFAULT_AUTO_FAILOVER_ZK_BASE_PATH =
475      "/yarn-leader-election";
476
477  public static final String CLIENT_FAILOVER_PREFIX =
478      YARN_PREFIX + "client.failover-";
479  public static final String CLIENT_FAILOVER_PROXY_PROVIDER =
480      CLIENT_FAILOVER_PREFIX + "proxy-provider";
481  public static final String DEFAULT_CLIENT_FAILOVER_PROXY_PROVIDER =
482      "org.apache.hadoop.yarn.client.ConfiguredRMFailoverProxyProvider";
483
484  public static final String CLIENT_FAILOVER_MAX_ATTEMPTS =
485      CLIENT_FAILOVER_PREFIX + "max-attempts";
486
487  public static final String CLIENT_FAILOVER_SLEEPTIME_BASE_MS =
488      CLIENT_FAILOVER_PREFIX + "sleep-base-ms";
489
490  public static final String CLIENT_FAILOVER_SLEEPTIME_MAX_MS =
491      CLIENT_FAILOVER_PREFIX + "sleep-max-ms";
492
493  public static final String CLIENT_FAILOVER_RETRIES =
494      CLIENT_FAILOVER_PREFIX + "retries";
495  public static final int DEFAULT_CLIENT_FAILOVER_RETRIES = 0;
496
497  public static final String CLIENT_FAILOVER_RETRIES_ON_SOCKET_TIMEOUTS =
498      CLIENT_FAILOVER_PREFIX + "retries-on-socket-timeouts";
499  public static final int
500      DEFAULT_CLIENT_FAILOVER_RETRIES_ON_SOCKET_TIMEOUTS = 0;
501
502  ////////////////////////////////
503  // RM state store configs
504  ////////////////////////////////
505  /** The class to use as the persistent store.*/
506  public static final String RM_STORE = RM_PREFIX + "store.class";
507  
508  /** URI for FileSystemRMStateStore */
509  public static final String FS_RM_STATE_STORE_URI = RM_PREFIX
510      + "fs.state-store.uri";
511  public static final String FS_RM_STATE_STORE_RETRY_POLICY_SPEC = RM_PREFIX
512      + "fs.state-store.retry-policy-spec";
513  public static final String DEFAULT_FS_RM_STATE_STORE_RETRY_POLICY_SPEC =
514      "2000, 500";
515
516  /** The maximum number of completed applications RM keeps. */ 
517  public static final String RM_MAX_COMPLETED_APPLICATIONS =
518    RM_PREFIX + "max-completed-applications";
519  public static final int DEFAULT_RM_MAX_COMPLETED_APPLICATIONS = 10000;
520
521  /**
522   * The maximum number of completed applications RM state store keeps, by
523   * default equals to DEFAULT_RM_MAX_COMPLETED_APPLICATIONS
524   */
525  public static final String RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS =
526      RM_PREFIX + "state-store.max-completed-applications";
527  public static final int DEFAULT_RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS =
528      DEFAULT_RM_MAX_COMPLETED_APPLICATIONS;
529
530  /** Default application name */
531  public static final String DEFAULT_APPLICATION_NAME = "N/A";
532
533  /** Default application type */
534  public static final String DEFAULT_APPLICATION_TYPE = "YARN";
535
536  /** Default application type length */
537  public static final int APPLICATION_TYPE_LENGTH = 20;
538  
539  /** Default queue name */
540  public static final String DEFAULT_QUEUE_NAME = "default";
541
542  /**
543   * Buckets (in minutes) for the number of apps running in each queue.
544   */
545  public static final String RM_METRICS_RUNTIME_BUCKETS =
546    RM_PREFIX + "metrics.runtime.buckets";
547
548  /**
549   * Default sizes of the runtime metric buckets in minutes.
550   */
551  public static final String DEFAULT_RM_METRICS_RUNTIME_BUCKETS = 
552    "60,300,1440";
553
554  public static final String RM_AMRM_TOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS = RM_PREFIX
555      + "am-rm-tokens.master-key-rolling-interval-secs";
556
557  public static final long DEFAULT_RM_AMRM_TOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS =
558      24 * 60 * 60;
559
560  public static final String RM_CONTAINER_TOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS =
561      RM_PREFIX + "container-tokens.master-key-rolling-interval-secs";
562
563  public static final long DEFAULT_RM_CONTAINER_TOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS =
564      24 * 60 * 60;
565
566  public static final String RM_NMTOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS =
567      RM_PREFIX + "nm-tokens.master-key-rolling-interval-secs";
568  
569  public static final long DEFAULT_RM_NMTOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS =
570      24 * 60 * 60;
571
572  public static final String RM_NODEMANAGER_MINIMUM_VERSION =
573      RM_PREFIX + "nodemanager.minimum.version";
574
575  public static final String DEFAULT_RM_NODEMANAGER_MINIMUM_VERSION =
576      "NONE";
577
578  /**
579   * RM proxy users' prefix
580   */
581  public static final String RM_PROXY_USER_PREFIX = RM_PREFIX + "proxyuser.";
582
583  ////////////////////////////////
584  // Node Manager Configs
585  ////////////////////////////////
586  
587  /** Prefix for all node manager configs.*/
588  public static final String NM_PREFIX = "yarn.nodemanager.";
589
590  /** Environment variables that will be sent to containers.*/
591  public static final String NM_ADMIN_USER_ENV = NM_PREFIX + "admin-env";
592  public static final String DEFAULT_NM_ADMIN_USER_ENV = "MALLOC_ARENA_MAX=$MALLOC_ARENA_MAX";
593
594  /** Environment variables that containers may override rather than use NodeManager's default.*/
595  public static final String NM_ENV_WHITELIST = NM_PREFIX + "env-whitelist";
596  public static final String DEFAULT_NM_ENV_WHITELIST = StringUtils.join(",",
597    Arrays.asList(ApplicationConstants.Environment.JAVA_HOME.key(),
598      ApplicationConstants.Environment.HADOOP_COMMON_HOME.key(),
599      ApplicationConstants.Environment.HADOOP_HDFS_HOME.key(),
600      ApplicationConstants.Environment.HADOOP_CONF_DIR.key(),
601      ApplicationConstants.Environment.HADOOP_YARN_HOME.key()));
602  
603  /** address of node manager IPC.*/
604  public static final String NM_ADDRESS = NM_PREFIX + "address";
605  public static final int DEFAULT_NM_PORT = 0;
606  public static final String DEFAULT_NM_ADDRESS = "0.0.0.0:"
607      + DEFAULT_NM_PORT;
608  
609  /** The actual bind address or the NM.*/
610  public static final String NM_BIND_HOST =
611    NM_PREFIX + "bind-host";
612
613  /** who will execute(launch) the containers.*/
614  public static final String NM_CONTAINER_EXECUTOR = 
615    NM_PREFIX + "container-executor.class";
616
617  /**  
618   * Adjustment to make to the container os scheduling priority.
619   * The valid values for this could vary depending on the platform.
620   * On Linux, higher values mean run the containers at a less 
621   * favorable priority than the NM. 
622   * The value specified is an int.
623   */
624  public static final String NM_CONTAINER_EXECUTOR_SCHED_PRIORITY = 
625    NM_PREFIX + "container-executor.os.sched.priority.adjustment";
626  public static final int DEFAULT_NM_CONTAINER_EXECUTOR_SCHED_PRIORITY = 0;
627  
628  /** Number of threads container manager uses.*/
629  public static final String NM_CONTAINER_MGR_THREAD_COUNT =
630    NM_PREFIX + "container-manager.thread-count";
631  public static final int DEFAULT_NM_CONTAINER_MGR_THREAD_COUNT = 20;
632  
633  /** Number of threads used in cleanup.*/
634  public static final String NM_DELETE_THREAD_COUNT = 
635    NM_PREFIX +  "delete.thread-count";
636  public static final int DEFAULT_NM_DELETE_THREAD_COUNT = 4;
637  
638  /** Keytab for NM.*/
639  public static final String NM_KEYTAB = NM_PREFIX + "keytab";
640  
641  /**List of directories to store localized files in.*/
642  public static final String NM_LOCAL_DIRS = NM_PREFIX + "local-dirs";
643  public static final String DEFAULT_NM_LOCAL_DIRS = "/tmp/nm-local-dir";
644
645  /**
646   * Number of files in each localized directories
647   * Avoid tuning this too low. 
648   */
649  public static final String NM_LOCAL_CACHE_MAX_FILES_PER_DIRECTORY =
650    NM_PREFIX + "local-cache.max-files-per-directory";
651  public static final int DEFAULT_NM_LOCAL_CACHE_MAX_FILES_PER_DIRECTORY = 8192;
652
653  /** Address where the localizer IPC is.*/
654  public static final String NM_LOCALIZER_ADDRESS =
655    NM_PREFIX + "localizer.address";
656  public static final int DEFAULT_NM_LOCALIZER_PORT = 8040;
657  public static final String DEFAULT_NM_LOCALIZER_ADDRESS = "0.0.0.0:" +
658    DEFAULT_NM_LOCALIZER_PORT;
659  
660  /** Interval in between cache cleanups.*/
661  public static final String NM_LOCALIZER_CACHE_CLEANUP_INTERVAL_MS =
662    NM_PREFIX + "localizer.cache.cleanup.interval-ms";
663  public static final long DEFAULT_NM_LOCALIZER_CACHE_CLEANUP_INTERVAL_MS = 
664    10 * 60 * 1000;
665  
666  /**
667   * Target size of localizer cache in MB, per nodemanager. It is a target
668   * retention size that only includes resources with PUBLIC and PRIVATE
669   * visibility and excludes resources with APPLICATION visibility
670   */
671  public static final String NM_LOCALIZER_CACHE_TARGET_SIZE_MB =
672    NM_PREFIX + "localizer.cache.target-size-mb";
673  public static final long DEFAULT_NM_LOCALIZER_CACHE_TARGET_SIZE_MB = 10 * 1024;
674  
675  /** Number of threads to handle localization requests.*/
676  public static final String NM_LOCALIZER_CLIENT_THREAD_COUNT =
677    NM_PREFIX + "localizer.client.thread-count";
678  public static final int DEFAULT_NM_LOCALIZER_CLIENT_THREAD_COUNT = 5;
679  
680  /** Number of threads to use for localization fetching.*/
681  public static final String NM_LOCALIZER_FETCH_THREAD_COUNT = 
682    NM_PREFIX + "localizer.fetch.thread-count";
683  public static final int DEFAULT_NM_LOCALIZER_FETCH_THREAD_COUNT = 4;
684
685  /** Where to store container logs.*/
686  public static final String NM_LOG_DIRS = NM_PREFIX + "log-dirs";
687  public static final String DEFAULT_NM_LOG_DIRS = "/tmp/logs";
688
689  public static final String NM_RESOURCEMANAGER_MINIMUM_VERSION =
690      NM_PREFIX + "resourcemanager.minimum.version";
691  public static final String DEFAULT_NM_RESOURCEMANAGER_MINIMUM_VERSION = "NONE";
692
693  /** Interval at which the delayed token removal thread runs */
694  public static final String RM_DELAYED_DELEGATION_TOKEN_REMOVAL_INTERVAL_MS =
695      RM_PREFIX + "delayed.delegation-token.removal-interval-ms";
696  public static final long DEFAULT_RM_DELAYED_DELEGATION_TOKEN_REMOVAL_INTERVAL_MS =
697      30000l;
698  
699  /** Delegation Token renewer thread count */
700  public static final String RM_DELEGATION_TOKEN_RENEWER_THREAD_COUNT =
701      RM_PREFIX + "delegation-token-renewer.thread-count";
702  public static final int DEFAULT_RM_DELEGATION_TOKEN_RENEWER_THREAD_COUNT = 50;
703
704  public static final String RM_PROXY_USER_PRIVILEGES_ENABLED = RM_PREFIX
705      + "proxy-user-privileges.enabled";
706  public static boolean DEFAULT_RM_PROXY_USER_PRIVILEGES_ENABLED = false;
707
708  /** Whether to enable log aggregation */
709  public static final String LOG_AGGREGATION_ENABLED = YARN_PREFIX
710      + "log-aggregation-enable";
711  public static final boolean DEFAULT_LOG_AGGREGATION_ENABLED = false;
712  
713  /** 
714   * How long to wait before deleting aggregated logs, -1 disables.
715   * Be careful set this too small and you will spam the name node.
716   */
717  public static final String LOG_AGGREGATION_RETAIN_SECONDS = YARN_PREFIX
718      + "log-aggregation.retain-seconds";
719  public static final long DEFAULT_LOG_AGGREGATION_RETAIN_SECONDS = -1;
720  
721  /**
722   * How long to wait between aggregated log retention checks. If set to
723   * a value <= 0 then the value is computed as one-tenth of the log retention
724   * setting. Be careful set this too small and you will spam the name node.
725   */
726  public static final String LOG_AGGREGATION_RETAIN_CHECK_INTERVAL_SECONDS =
727      YARN_PREFIX + "log-aggregation.retain-check-interval-seconds";
728  public static final long DEFAULT_LOG_AGGREGATION_RETAIN_CHECK_INTERVAL_SECONDS = -1;
729
730  /**
731   * Number of seconds to retain logs on the NodeManager. Only applicable if Log
732   * aggregation is disabled
733   */
734  public static final String NM_LOG_RETAIN_SECONDS = NM_PREFIX
735      + "log.retain-seconds";
736  public static final long DEFAULT_NM_LOG_RETAIN_SECONDS = 3 * 60 * 60;
737
738  /**
739   * Define how often NMs wake up and upload log files
740   */
741  public static final String NM_LOG_AGGREGATION_ROLL_MONITORING_INTERVAL_SECONDS =
742      NM_PREFIX + "log-aggregation.roll-monitoring-interval-seconds";
743  public static final long
744      DEFAULT_NM_LOG_AGGREGATION_ROLL_MONITORING_INTERVAL_SECONDS = -1;
745  /**
746   * Number of threads used in log cleanup. Only applicable if Log aggregation
747   * is disabled
748   */
749  public static final String NM_LOG_DELETION_THREADS_COUNT = 
750    NM_PREFIX +  "log.deletion-threads-count";
751  public static final int DEFAULT_NM_LOG_DELETE_THREAD_COUNT = 4;
752
753  /** Where to aggregate logs to.*/
754  public static final String NM_REMOTE_APP_LOG_DIR = 
755    NM_PREFIX + "remote-app-log-dir";
756  public static final String DEFAULT_NM_REMOTE_APP_LOG_DIR = "/tmp/logs";
757
758  /**
759   * The remote log dir will be created at
760   * NM_REMOTE_APP_LOG_DIR/${user}/NM_REMOTE_APP_LOG_DIR_SUFFIX/${appId}
761   */
762  public static final String NM_REMOTE_APP_LOG_DIR_SUFFIX = 
763    NM_PREFIX + "remote-app-log-dir-suffix";
764  public static final String DEFAULT_NM_REMOTE_APP_LOG_DIR_SUFFIX="logs";
765
766  public static final String YARN_LOG_SERVER_URL =
767    YARN_PREFIX + "log.server.url";
768  
769  public static final String YARN_TRACKING_URL_GENERATOR = 
770      YARN_PREFIX + "tracking.url.generator";
771
772  /** Amount of memory in GB that can be allocated for containers.*/
773  public static final String NM_PMEM_MB = NM_PREFIX + "resource.memory-mb";
774  public static final int DEFAULT_NM_PMEM_MB = 8 * 1024;
775
776  /** Specifies whether physical memory check is enabled. */
777  public static final String NM_PMEM_CHECK_ENABLED = NM_PREFIX
778      + "pmem-check-enabled";
779  public static final boolean DEFAULT_NM_PMEM_CHECK_ENABLED = true;
780
781  /** Specifies whether physical memory check is enabled. */
782  public static final String NM_VMEM_CHECK_ENABLED = NM_PREFIX
783      + "vmem-check-enabled";
784  public static final boolean DEFAULT_NM_VMEM_CHECK_ENABLED = true;
785
786  /** Conversion ratio for physical memory to virtual memory. */
787  public static final String NM_VMEM_PMEM_RATIO =
788    NM_PREFIX + "vmem-pmem-ratio";
789  public static final float DEFAULT_NM_VMEM_PMEM_RATIO = 2.1f;
790  
791  /** Number of Virtual CPU Cores which can be allocated for containers.*/
792  public static final String NM_VCORES = NM_PREFIX + "resource.cpu-vcores";
793  public static final int DEFAULT_NM_VCORES = 8;
794
795  /** Percentage of overall CPU which can be allocated for containers. */
796  public static final String NM_RESOURCE_PERCENTAGE_PHYSICAL_CPU_LIMIT =
797      NM_PREFIX + "resource.percentage-physical-cpu-limit";
798  public static final int DEFAULT_NM_RESOURCE_PERCENTAGE_PHYSICAL_CPU_LIMIT =
799      100;
800  
801  /** NM Webapp address.**/
802  public static final String NM_WEBAPP_ADDRESS = NM_PREFIX + "webapp.address";
803  public static final int DEFAULT_NM_WEBAPP_PORT = 8042;
804  public static final String DEFAULT_NM_WEBAPP_ADDRESS = "0.0.0.0:" +
805    DEFAULT_NM_WEBAPP_PORT;
806  
807  /** NM Webapp https address.**/
808  public static final String NM_WEBAPP_HTTPS_ADDRESS = NM_PREFIX
809      + "webapp.https.address";
810  public static final int DEFAULT_NM_WEBAPP_HTTPS_PORT = 8044;
811  public static final String DEFAULT_NM_WEBAPP_HTTPS_ADDRESS = "0.0.0.0:"
812      + DEFAULT_NM_WEBAPP_HTTPS_PORT; 
813  
814  /** How often to monitor containers.*/
815  public final static String NM_CONTAINER_MON_INTERVAL_MS =
816    NM_PREFIX + "container-monitor.interval-ms";
817  public final static int DEFAULT_NM_CONTAINER_MON_INTERVAL_MS = 3000;
818
819  /** Class that calculates containers current resource utilization.*/
820  public static final String NM_CONTAINER_MON_RESOURCE_CALCULATOR =
821    NM_PREFIX + "container-monitor.resource-calculator.class";
822  /** Class that calculates process tree resource utilization.*/
823  public static final String NM_CONTAINER_MON_PROCESS_TREE =
824    NM_PREFIX + "container-monitor.process-tree.class";
825  public static final String PROCFS_USE_SMAPS_BASED_RSS_ENABLED = NM_PREFIX +
826      ".container-monitor.procfs-tree.smaps-based-rss.enabled";
827  public static final boolean DEFAULT_PROCFS_USE_SMAPS_BASED_RSS_ENABLED =
828      false;
829  
830  /** Prefix for all node manager disk health checker configs. */
831  private static final String NM_DISK_HEALTH_CHECK_PREFIX =
832      "yarn.nodemanager.disk-health-checker.";
833  /**
834   * Enable/Disable disks' health checker. Default is true. An expert level
835   * configuration property.
836   */
837  public static final String NM_DISK_HEALTH_CHECK_ENABLE =
838      NM_DISK_HEALTH_CHECK_PREFIX + "enable";
839  /** Frequency of running disks' health checker. */
840  public static final String NM_DISK_HEALTH_CHECK_INTERVAL_MS =
841      NM_DISK_HEALTH_CHECK_PREFIX + "interval-ms";
842  /** By default, disks' health is checked every 2 minutes. */
843  public static final long DEFAULT_NM_DISK_HEALTH_CHECK_INTERVAL_MS =
844      2 * 60 * 1000;
845
846  /**
847   * The minimum fraction of number of disks to be healthy for the nodemanager
848   * to launch new containers. This applies to nm-local-dirs and nm-log-dirs.
849   */
850  public static final String NM_MIN_HEALTHY_DISKS_FRACTION =
851      NM_DISK_HEALTH_CHECK_PREFIX + "min-healthy-disks";
852  /**
853   * By default, at least 25% of disks are to be healthy to say that the node is
854   * healthy in terms of disks.
855   */
856  public static final float DEFAULT_NM_MIN_HEALTHY_DISKS_FRACTION = 0.25F;
857
858  /**
859   * The maximum percentage of disk space that can be used after which a disk is
860   * marked as offline. Values can range from 0.0 to 100.0. If the value is
861   * greater than or equal to 100, NM will check for full disk. This applies to
862   * nm-local-dirs and nm-log-dirs.
863   */
864  public static final String NM_MAX_PER_DISK_UTILIZATION_PERCENTAGE =
865      NM_DISK_HEALTH_CHECK_PREFIX + "max-disk-utilization-per-disk-percentage";
866  /**
867   * By default, 90% of the disk can be used before it is marked as offline.
868   */
869  public static final float DEFAULT_NM_MAX_PER_DISK_UTILIZATION_PERCENTAGE =
870      90.0F;
871
872  /**
873   * The minimum space that must be available on a local dir for it to be used.
874   * This applies to nm-local-dirs and nm-log-dirs.
875   */
876  public static final String NM_MIN_PER_DISK_FREE_SPACE_MB =
877      NM_DISK_HEALTH_CHECK_PREFIX + "min-free-space-per-disk-mb";
878  /**
879   * By default, all of the disk can be used before it is marked as offline.
880   */
881  public static final long DEFAULT_NM_MIN_PER_DISK_FREE_SPACE_MB = 0;
882
883  /** Frequency of running node health script.*/
884  public static final String NM_HEALTH_CHECK_INTERVAL_MS = 
885    NM_PREFIX + "health-checker.interval-ms";
886  public static final long DEFAULT_NM_HEALTH_CHECK_INTERVAL_MS = 10 * 60 * 1000;
887
888  /** Health check script time out period.*/  
889  public static final String NM_HEALTH_CHECK_SCRIPT_TIMEOUT_MS = 
890    NM_PREFIX + "health-checker.script.timeout-ms";
891  public static final long DEFAULT_NM_HEALTH_CHECK_SCRIPT_TIMEOUT_MS = 
892    2 * DEFAULT_NM_HEALTH_CHECK_INTERVAL_MS;
893  
894  /** The health check script to run.*/
895  public static final String NM_HEALTH_CHECK_SCRIPT_PATH = 
896    NM_PREFIX + "health-checker.script.path";
897  
898  /** The arguments to pass to the health check script.*/
899  public static final String NM_HEALTH_CHECK_SCRIPT_OPTS = 
900    NM_PREFIX + "health-checker.script.opts";
901
902  /** The Docker image name(For DockerContainerExecutor).*/
903  public static final String NM_DOCKER_CONTAINER_EXECUTOR_IMAGE_NAME =
904    NM_PREFIX + "docker-container-executor.image-name";
905
906  /** The name of the docker executor (For DockerContainerExecutor).*/
907  public static final String NM_DOCKER_CONTAINER_EXECUTOR_EXEC_NAME =
908    NM_PREFIX + "docker-container-executor.exec-name";
909
910  /** The default docker executor (For DockerContainerExecutor).*/
911  public static final String NM_DEFAULT_DOCKER_CONTAINER_EXECUTOR_EXEC_NAME =
912          "/usr/bin/docker";
913
914  /** The path to the Linux container executor.*/
915  public static final String NM_LINUX_CONTAINER_EXECUTOR_PATH =
916    NM_PREFIX + "linux-container-executor.path";
917  
918  /** 
919   * The UNIX group that the linux-container-executor should run as.
920   * This is intended to be set as part of container-executor.cfg. 
921   */
922  public static final String NM_LINUX_CONTAINER_GROUP =
923    NM_PREFIX + "linux-container-executor.group";
924
925  /**
926   * If linux-container-executor should limit itself to one user
927   * when running in non-secure mode.
928   */
929  public static final String NM_NONSECURE_MODE_LIMIT_USERS= NM_PREFIX +
930     "linux-container-executor.nonsecure-mode.limit-users";
931
932  public static final boolean DEFAULT_NM_NONSECURE_MODE_LIMIT_USERS = true; 
933
934  /**
935   * The UNIX user that containers will run as when Linux-container-executor
936   * is used in nonsecure mode (a use case for this is using cgroups).
937   */
938  public static final String NM_NONSECURE_MODE_LOCAL_USER_KEY = NM_PREFIX +
939      "linux-container-executor.nonsecure-mode.local-user";
940
941  public static final String DEFAULT_NM_NONSECURE_MODE_LOCAL_USER = "nobody";
942
943  /**
944   * The allowed pattern for UNIX user names enforced by 
945   * Linux-container-executor when used in nonsecure mode (use case for this 
946   * is using cgroups). The default value is taken from /usr/sbin/adduser
947   */
948  public static final String NM_NONSECURE_MODE_USER_PATTERN_KEY = NM_PREFIX +
949      "linux-container-executor.nonsecure-mode.user-pattern";
950
951  public static final String DEFAULT_NM_NONSECURE_MODE_USER_PATTERN = 
952      "^[_.A-Za-z0-9][-@_.A-Za-z0-9]{0,255}?[$]?$";
953
954  /** The type of resource enforcement to use with the
955   *  linux container executor.
956   */
957  public static final String NM_LINUX_CONTAINER_RESOURCES_HANDLER = 
958  NM_PREFIX + "linux-container-executor.resources-handler.class";
959  
960  /** The path the linux container executor should use for cgroups */
961  public static final String NM_LINUX_CONTAINER_CGROUPS_HIERARCHY =
962    NM_PREFIX + "linux-container-executor.cgroups.hierarchy";
963  
964  /** Whether the linux container executor should mount cgroups if not found */
965  public static final String NM_LINUX_CONTAINER_CGROUPS_MOUNT =
966    NM_PREFIX + "linux-container-executor.cgroups.mount";
967  
968  /** Where the linux container executor should mount cgroups if not found */
969  public static final String NM_LINUX_CONTAINER_CGROUPS_MOUNT_PATH =
970    NM_PREFIX + "linux-container-executor.cgroups.mount-path";
971
972  /**
973   * Whether the apps should run in strict resource usage mode(not allowed to
974   * use spare CPU)
975   */
976  public static final String NM_LINUX_CONTAINER_CGROUPS_STRICT_RESOURCE_USAGE =
977      NM_PREFIX + "linux-container-executor.cgroups.strict-resource-usage";
978  public static final boolean DEFAULT_NM_LINUX_CONTAINER_CGROUPS_STRICT_RESOURCE_USAGE =
979      false;
980
981
982
983  /**
984   * Interval of time the linux container executor should try cleaning up
985   * cgroups entry when cleaning up a container. This is required due to what 
986   * it seems a race condition because the SIGTERM/SIGKILL is asynch.
987   */
988  public static final String NM_LINUX_CONTAINER_CGROUPS_DELETE_TIMEOUT =
989   NM_PREFIX + "linux-container-executor.cgroups.delete-timeout-ms";
990
991  public static final long DEFAULT_NM_LINUX_CONTAINER_CGROUPS_DELETE_TIMEOUT =
992      1000;
993  
994  /** 
995  /* The Windows group that the windows-secure-container-executor should run as.
996  */
997  public static final String NM_WINDOWS_SECURE_CONTAINER_GROUP =
998      NM_PREFIX + "windows-secure-container-executor.group";
999
1000  /** T-file compression types used to compress aggregated logs.*/
1001  public static final String NM_LOG_AGG_COMPRESSION_TYPE = 
1002    NM_PREFIX + "log-aggregation.compression-type";
1003  public static final String DEFAULT_NM_LOG_AGG_COMPRESSION_TYPE = "none";
1004  
1005  /** The kerberos principal for the node manager.*/
1006  public static final String NM_PRINCIPAL =
1007    NM_PREFIX + "principal";
1008  
1009  public static final String NM_AUX_SERVICES = 
1010    NM_PREFIX + "aux-services";
1011  
1012  public static final String NM_AUX_SERVICE_FMT =
1013    NM_PREFIX + "aux-services.%s.class";
1014
1015  public static final String NM_USER_HOME_DIR =
1016      NM_PREFIX + "user-home-dir";
1017  
1018  /**The kerberos principal to be used for spnego filter for NM.*/
1019  public static final String NM_WEBAPP_SPNEGO_USER_NAME_KEY =
1020      NM_PREFIX + "webapp.spnego-principal";
1021  
1022  /**The kerberos keytab to be used for spnego filter for NM.*/
1023  public static final String NM_WEBAPP_SPNEGO_KEYTAB_FILE_KEY =
1024      NM_PREFIX + "webapp.spnego-keytab-file";
1025  
1026  public static final String DEFAULT_NM_USER_HOME_DIR= "/home/";
1027
1028  public static final String NM_RECOVERY_PREFIX = NM_PREFIX + "recovery.";
1029  public static final String NM_RECOVERY_ENABLED =
1030      NM_RECOVERY_PREFIX + "enabled";
1031  public static final boolean DEFAULT_NM_RECOVERY_ENABLED = false;
1032
1033  public static final String NM_RECOVERY_DIR = NM_RECOVERY_PREFIX + "dir";
1034
1035  ////////////////////////////////
1036  // Web Proxy Configs
1037  ////////////////////////////////
1038  public static final String PROXY_PREFIX = "yarn.web-proxy.";
1039  
1040  /** The kerberos principal for the proxy.*/
1041  public static final String PROXY_PRINCIPAL =
1042    PROXY_PREFIX + "principal";
1043  
1044  /** Keytab for Proxy.*/
1045  public static final String PROXY_KEYTAB = PROXY_PREFIX + "keytab";
1046  
1047  /** The address for the web proxy.*/
1048  public static final String PROXY_ADDRESS =
1049    PROXY_PREFIX + "address";
1050  public static final int DEFAULT_PROXY_PORT = 9099;
1051  public static final String DEFAULT_PROXY_ADDRESS =
1052    "0.0.0.0:" + DEFAULT_PROXY_PORT;
1053  
1054  /**
1055   * YARN Service Level Authorization
1056   */
1057  public static final String 
1058  YARN_SECURITY_SERVICE_AUTHORIZATION_RESOURCETRACKER_PROTOCOL =
1059      "security.resourcetracker.protocol.acl";
1060  public static final String 
1061  YARN_SECURITY_SERVICE_AUTHORIZATION_APPLICATIONCLIENT_PROTOCOL =
1062      "security.applicationclient.protocol.acl";
1063  public static final String 
1064  YARN_SECURITY_SERVICE_AUTHORIZATION_RESOURCEMANAGER_ADMINISTRATION_PROTOCOL =
1065      "security.resourcemanager-administration.protocol.acl";
1066  public static final String 
1067  YARN_SECURITY_SERVICE_AUTHORIZATION_APPLICATIONMASTER_PROTOCOL =
1068      "security.applicationmaster.protocol.acl";
1069
1070  public static final String 
1071  YARN_SECURITY_SERVICE_AUTHORIZATION_CONTAINER_MANAGEMENT_PROTOCOL =
1072      "security.containermanagement.protocol.acl";
1073  public static final String 
1074  YARN_SECURITY_SERVICE_AUTHORIZATION_RESOURCE_LOCALIZER =
1075      "security.resourcelocalizer.protocol.acl";
1076
1077  public static final String
1078  YARN_SECURITY_SERVICE_AUTHORIZATION_APPLICATIONHISTORY_PROTOCOL =
1079      "security.applicationhistory.protocol.acl";
1080
1081  /** No. of milliseconds to wait between sending a SIGTERM and SIGKILL
1082   * to a running container */
1083  public static final String NM_SLEEP_DELAY_BEFORE_SIGKILL_MS =
1084      NM_PREFIX + "sleep-delay-before-sigkill.ms";
1085  public static final long DEFAULT_NM_SLEEP_DELAY_BEFORE_SIGKILL_MS =
1086      250;
1087
1088  /** Max time to wait for a process to come up when trying to cleanup
1089   * container resources */
1090  public static final String NM_PROCESS_KILL_WAIT_MS =
1091      NM_PREFIX + "process-kill-wait.ms";
1092  public static final long DEFAULT_NM_PROCESS_KILL_WAIT_MS =
1093      2000;
1094
1095  /** Max time to wait to establish a connection to RM */
1096  public static final String RESOURCEMANAGER_CONNECT_MAX_WAIT_MS =
1097      RM_PREFIX + "connect.max-wait.ms";
1098  public static final long DEFAULT_RESOURCEMANAGER_CONNECT_MAX_WAIT_MS =
1099      15 * 60 * 1000;
1100
1101  /** Time interval between each attempt to connect to RM */
1102  public static final String RESOURCEMANAGER_CONNECT_RETRY_INTERVAL_MS =
1103      RM_PREFIX + "connect.retry-interval.ms";
1104  public static final long DEFAULT_RESOURCEMANAGER_CONNECT_RETRY_INTERVAL_MS
1105      = 30 * 1000;
1106
1107  public static final String DISPATCHER_DRAIN_EVENTS_TIMEOUT =
1108      YARN_PREFIX + "dispatcher.drain-events.timeout";
1109
1110  public static final long DEFAULT_DISPATCHER_DRAIN_EVENTS_TIMEOUT = 300000;
1111
1112  /**
1113   * CLASSPATH for YARN applications. A comma-separated list of CLASSPATH
1114   * entries
1115   */
1116  public static final String YARN_APPLICATION_CLASSPATH = YARN_PREFIX
1117      + "application.classpath";
1118
1119  /**
1120   * Default platform-agnostic CLASSPATH for YARN applications. A
1121   * comma-separated list of CLASSPATH entries. The parameter expansion marker
1122   * will be replaced with real parameter expansion marker ('%' for Windows and
1123   * '$' for Linux) by NodeManager on container launch. For example: {{VAR}}
1124   * will be replaced as $VAR on Linux, and %VAR% on Windows.
1125   */
1126  @Public
1127  @Unstable
1128  public static final String[] DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH= {
1129      ApplicationConstants.Environment.HADOOP_CONF_DIR.$$(),
1130      ApplicationConstants.Environment.HADOOP_COMMON_HOME.$$()
1131          + "/share/hadoop/common/*",
1132      ApplicationConstants.Environment.HADOOP_COMMON_HOME.$$()
1133          + "/share/hadoop/common/lib/*",
1134      ApplicationConstants.Environment.HADOOP_HDFS_HOME.$$()
1135          + "/share/hadoop/hdfs/*",
1136      ApplicationConstants.Environment.HADOOP_HDFS_HOME.$$()
1137          + "/share/hadoop/hdfs/lib/*",
1138      ApplicationConstants.Environment.HADOOP_YARN_HOME.$$()
1139          + "/share/hadoop/yarn/*",
1140      ApplicationConstants.Environment.HADOOP_YARN_HOME.$$()
1141          + "/share/hadoop/yarn/lib/*" };
1142  /**
1143   * <p>
1144   * Default platform-specific CLASSPATH for YARN applications. A
1145   * comma-separated list of CLASSPATH entries constructed based on the client
1146   * OS environment expansion syntax.
1147   * </p>
1148   * <p>
1149   * Note: Use {@link DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH} for
1150   * cross-platform practice i.e. submit an application from a Windows client to
1151   * a Linux/Unix server or vice versa.
1152   * </p>
1153   */
1154  public static final String[] DEFAULT_YARN_APPLICATION_CLASSPATH = {
1155      ApplicationConstants.Environment.HADOOP_CONF_DIR.$(),
1156      ApplicationConstants.Environment.HADOOP_COMMON_HOME.$()
1157          + "/share/hadoop/common/*",
1158      ApplicationConstants.Environment.HADOOP_COMMON_HOME.$()
1159          + "/share/hadoop/common/lib/*",
1160      ApplicationConstants.Environment.HADOOP_HDFS_HOME.$()
1161          + "/share/hadoop/hdfs/*",
1162      ApplicationConstants.Environment.HADOOP_HDFS_HOME.$()
1163          + "/share/hadoop/hdfs/lib/*",
1164      ApplicationConstants.Environment.HADOOP_YARN_HOME.$()
1165          + "/share/hadoop/yarn/*",
1166      ApplicationConstants.Environment.HADOOP_YARN_HOME.$()
1167          + "/share/hadoop/yarn/lib/*" };
1168
1169  /** Container temp directory */
1170  public static final String DEFAULT_CONTAINER_TEMP_DIR = "./tmp";
1171
1172  public static final String IS_MINI_YARN_CLUSTER = YARN_PREFIX
1173      + "is.minicluster";
1174
1175  public static final String YARN_MC_PREFIX = YARN_PREFIX + "minicluster.";
1176
1177  /** Whether to use fixed ports with the minicluster. */
1178  public static final String YARN_MINICLUSTER_FIXED_PORTS =
1179      YARN_MC_PREFIX + "fixed.ports";
1180
1181  /**
1182   * Default is false to be able to run tests concurrently without port
1183   * conflicts.
1184   */
1185  public static final boolean DEFAULT_YARN_MINICLUSTER_FIXED_PORTS = false;
1186
1187  /**
1188   * Whether the NM should use RPC to connect to the RM. Default is false.
1189   * Can be set to true only when using fixed ports.
1190   */
1191  public static final String YARN_MINICLUSTER_USE_RPC = YARN_MC_PREFIX + "use-rpc";
1192  public static final boolean DEFAULT_YARN_MINICLUSTER_USE_RPC = false;
1193
1194  /**
1195   * Whether users are explicitly trying to control resource monitoring
1196   * configuration for the MiniYARNCluster. Disabled by default.
1197   */
1198  public static final String YARN_MINICLUSTER_CONTROL_RESOURCE_MONITORING =
1199      YARN_MC_PREFIX + "control-resource-monitoring";
1200  public static final boolean
1201      DEFAULT_YARN_MINICLUSTER_CONTROL_RESOURCE_MONITORING = false;
1202
1203  /** The log directory for the containers */
1204  public static final String YARN_APP_CONTAINER_LOG_DIR =
1205      YARN_PREFIX + "app.container.log.dir";
1206
1207  public static final String YARN_APP_CONTAINER_LOG_SIZE =
1208      YARN_PREFIX + "app.container.log.filesize";
1209
1210  public static final String YARN_APP_CONTAINER_LOG_BACKUPS =
1211      YARN_PREFIX + "app.container.log.backups";
1212
1213  ////////////////////////////////
1214  // Timeline Service Configs
1215  ////////////////////////////////
1216
1217  public static final String TIMELINE_SERVICE_PREFIX =
1218      YARN_PREFIX + "timeline-service.";
1219
1220
1221  // mark app-history related configs @Private as application history is going
1222  // to be integrated into the timeline service
1223  @Private
1224  public static final String APPLICATION_HISTORY_PREFIX =
1225      TIMELINE_SERVICE_PREFIX + "generic-application-history.";
1226
1227  /**
1228   *  The setting that controls whether application history service is
1229   *  enabled or not.
1230   */
1231  @Private
1232  public static final String APPLICATION_HISTORY_ENABLED =
1233      APPLICATION_HISTORY_PREFIX + "enabled";
1234  @Private
1235  public static final boolean DEFAULT_APPLICATION_HISTORY_ENABLED = false;
1236
1237  /** Application history store class */
1238  @Private
1239  public static final String APPLICATION_HISTORY_STORE =
1240      APPLICATION_HISTORY_PREFIX + "store-class";
1241
1242  /** Save container meta-info in the application history store. */
1243  @Private
1244  public static final String
1245      APPLICATION_HISTORY_SAVE_NON_AM_CONTAINER_META_INFO =
1246        APPLICATION_HISTORY_PREFIX + "save-non-am-container-meta-info";
1247  @Private
1248  public static final boolean
1249            DEFAULT_APPLICATION_HISTORY_SAVE_NON_AM_CONTAINER_META_INFO = true;
1250
1251  /** URI for FileSystemApplicationHistoryStore */
1252  @Private
1253  public static final String FS_APPLICATION_HISTORY_STORE_URI =
1254      APPLICATION_HISTORY_PREFIX + "fs-history-store.uri";
1255
1256  /** T-file compression types used to compress history data.*/
1257  @Private
1258  public static final String FS_APPLICATION_HISTORY_STORE_COMPRESSION_TYPE =
1259      APPLICATION_HISTORY_PREFIX + "fs-history-store.compression-type";
1260  @Private
1261  public static final String DEFAULT_FS_APPLICATION_HISTORY_STORE_COMPRESSION_TYPE =
1262      "none";
1263
1264  /** The setting that controls whether timeline service is enabled or not. */
1265  public static final String TIMELINE_SERVICE_ENABLED =
1266      TIMELINE_SERVICE_PREFIX + "enabled";
1267  public static final boolean DEFAULT_TIMELINE_SERVICE_ENABLED = false;
1268
1269  /** host:port address for timeline service RPC APIs. */
1270  public static final String TIMELINE_SERVICE_ADDRESS =
1271      TIMELINE_SERVICE_PREFIX + "address";
1272  public static final int DEFAULT_TIMELINE_SERVICE_PORT = 10200;
1273  public static final String DEFAULT_TIMELINE_SERVICE_ADDRESS = "0.0.0.0:"
1274      + DEFAULT_TIMELINE_SERVICE_PORT;
1275
1276  /** The listening endpoint for the timeline service application.*/
1277  public static final String TIMELINE_SERVICE_BIND_HOST =
1278      TIMELINE_SERVICE_PREFIX + "bind-host";
1279
1280  /** The number of threads to handle client RPC API requests. */
1281  public static final String TIMELINE_SERVICE_HANDLER_THREAD_COUNT =
1282      TIMELINE_SERVICE_PREFIX + "handler-thread-count";
1283  public static final int DEFAULT_TIMELINE_SERVICE_CLIENT_THREAD_COUNT = 10;
1284  
1285
1286  /** The address of the timeline service web application.*/
1287  public static final String TIMELINE_SERVICE_WEBAPP_ADDRESS =
1288      TIMELINE_SERVICE_PREFIX  + "webapp.address";
1289
1290  public static final int DEFAULT_TIMELINE_SERVICE_WEBAPP_PORT = 8188;
1291  public static final String DEFAULT_TIMELINE_SERVICE_WEBAPP_ADDRESS =
1292      "0.0.0.0:" + DEFAULT_TIMELINE_SERVICE_WEBAPP_PORT;
1293
1294  /** The https address of the timeline service web application.*/
1295  public static final String TIMELINE_SERVICE_WEBAPP_HTTPS_ADDRESS =
1296      TIMELINE_SERVICE_PREFIX + "webapp.https.address";
1297
1298  public static final int DEFAULT_TIMELINE_SERVICE_WEBAPP_HTTPS_PORT = 8190;
1299  public static final String DEFAULT_TIMELINE_SERVICE_WEBAPP_HTTPS_ADDRESS =
1300      "0.0.0.0:" + DEFAULT_TIMELINE_SERVICE_WEBAPP_HTTPS_PORT;
1301
1302  /**
1303   * Defines the max number of applications could be fetched using
1304   * REST API or application history protocol and shown in timeline
1305   * server web ui.
1306   */
1307  public static final String APPLICATION_HISTORY_MAX_APPS =
1308      APPLICATION_HISTORY_PREFIX + "max-applications";
1309  public static final long DEFAULT_APPLICATION_HISTORY_MAX_APPS = 10000;
1310
1311  /** Timeline service store class */
1312  public static final String TIMELINE_SERVICE_STORE =
1313      TIMELINE_SERVICE_PREFIX + "store-class";
1314
1315  /** Timeline service enable data age off */
1316  public static final String TIMELINE_SERVICE_TTL_ENABLE =
1317      TIMELINE_SERVICE_PREFIX + "ttl-enable";
1318
1319  /** Timeline service length of time to retain data */
1320  public static final String TIMELINE_SERVICE_TTL_MS =
1321      TIMELINE_SERVICE_PREFIX + "ttl-ms";
1322
1323  public static final long DEFAULT_TIMELINE_SERVICE_TTL_MS =
1324      1000 * 60 * 60 * 24 * 7;
1325
1326  public static final String TIMELINE_SERVICE_LEVELDB_PREFIX =
1327      TIMELINE_SERVICE_PREFIX + "leveldb-timeline-store.";
1328
1329  /** Timeline service leveldb path */
1330  public static final String TIMELINE_SERVICE_LEVELDB_PATH =
1331      TIMELINE_SERVICE_LEVELDB_PREFIX + "path";
1332
1333  /** Timeline service leveldb read cache (uncompressed blocks) */
1334  public static final String TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE =
1335      TIMELINE_SERVICE_LEVELDB_PREFIX + "read-cache-size";
1336
1337  public static final long DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE =
1338      100 * 1024 * 1024;
1339
1340  /** Timeline service leveldb start time read cache (number of entities) */
1341  public static final String
1342      TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE =
1343      TIMELINE_SERVICE_LEVELDB_PREFIX + "start-time-read-cache-size";
1344
1345  public static final int
1346      DEFAULT_TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE = 10000;
1347
1348  /** Timeline service leveldb start time write cache (number of entities) */
1349  public static final String
1350      TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE =
1351      TIMELINE_SERVICE_LEVELDB_PREFIX + "start-time-write-cache-size";
1352
1353  public static final int
1354      DEFAULT_TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE = 10000;
1355
1356  /** Timeline service leveldb interval to wait between deletion rounds */
1357  public static final String TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS =
1358      TIMELINE_SERVICE_LEVELDB_PREFIX + "ttl-interval-ms";
1359
1360  public static final long DEFAULT_TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS =
1361      1000 * 60 * 5;
1362
1363  /** The Kerberos principal for the timeline server.*/
1364  public static final String TIMELINE_SERVICE_PRINCIPAL =
1365      TIMELINE_SERVICE_PREFIX + "principal";
1366
1367  /** The Kerberos keytab for the timeline server.*/
1368  public static final String TIMELINE_SERVICE_KEYTAB =
1369      TIMELINE_SERVICE_PREFIX + "keytab";
1370
1371  /** Enables cross origin support for timeline server.*/
1372  public static final String TIMELINE_SERVICE_HTTP_CROSS_ORIGIN_ENABLED =
1373      TIMELINE_SERVICE_PREFIX + "http-cross-origin.enabled";
1374
1375  /** Default value for cross origin support for timeline server.*/
1376  public static final boolean
1377      TIMELINE_SERVICE_HTTP_CROSS_ORIGIN_ENABLED_DEFAULT = false;
1378
1379  /** Timeline client settings */
1380  public static final String TIMELINE_SERVICE_CLIENT_PREFIX =
1381      TIMELINE_SERVICE_PREFIX + "client.";
1382
1383  /** Timeline client call, max retries (-1 means no limit) */
1384  public static final String TIMELINE_SERVICE_CLIENT_MAX_RETRIES =
1385      TIMELINE_SERVICE_CLIENT_PREFIX + "max-retries";
1386
1387  public static final int DEFAULT_TIMELINE_SERVICE_CLIENT_MAX_RETRIES = 30;
1388
1389  /** Timeline client call, retry interval */
1390  public static final String TIMELINE_SERVICE_CLIENT_RETRY_INTERVAL_MS =
1391      TIMELINE_SERVICE_CLIENT_PREFIX + "retry-interval-ms";
1392
1393  public static final long
1394      DEFAULT_TIMELINE_SERVICE_CLIENT_RETRY_INTERVAL_MS = 1000;
1395
1396  ////////////////////////////////
1397  // Other Configs
1398  ////////////////////////////////
1399
1400  /**
1401   * Use YARN_CLIENT_APPLICATION_CLIENT_PROTOCOL_POLL_INTERVAL_MS instead.
1402   * The interval of the yarn client's querying application state after
1403   * application submission. The unit is millisecond.
1404   */
1405  @Deprecated
1406  public static final String YARN_CLIENT_APP_SUBMISSION_POLL_INTERVAL_MS =
1407      YARN_PREFIX + "client.app-submission.poll-interval";
1408
1409  /**
1410   * The interval that the yarn client library uses to poll the completion
1411   * status of the asynchronous API of application client protocol.
1412   */
1413  public static final String YARN_CLIENT_APPLICATION_CLIENT_PROTOCOL_POLL_INTERVAL_MS =
1414      YARN_PREFIX + "client.application-client-protocol.poll-interval-ms";
1415  public static final long DEFAULT_YARN_CLIENT_APPLICATION_CLIENT_PROTOCOL_POLL_INTERVAL_MS =
1416      200;
1417
1418  /**
1419   * The duration that the yarn client library waits, cumulatively across polls,
1420   * for an expected state change to occur. Defaults to -1, which indicates no
1421   * limit.
1422   */
1423  public static final String YARN_CLIENT_APPLICATION_CLIENT_PROTOCOL_POLL_TIMEOUT_MS =
1424      YARN_PREFIX + "client.application-client-protocol.poll-timeout-ms";
1425  public static final long DEFAULT_YARN_CLIENT_APPLICATION_CLIENT_PROTOCOL_POLL_TIMEOUT_MS =
1426      -1;
1427
1428  /**
1429   * Max number of threads in NMClientAsync to process container management
1430   * events
1431   */
1432  public static final String NM_CLIENT_ASYNC_THREAD_POOL_MAX_SIZE =
1433      YARN_PREFIX + "client.nodemanager-client-async.thread-pool-max-size";
1434  public static final int DEFAULT_NM_CLIENT_ASYNC_THREAD_POOL_MAX_SIZE = 500;
1435
1436  /**
1437   * Maximum number of proxy connections to cache for node managers. If set
1438   * to a value greater than zero then the cache is enabled and the NMClient
1439   * and MRAppMaster will cache the specified number of node manager proxies.
1440   * There will be at max one proxy per node manager. Ex. configuring it to a
1441   * value of 5 will make sure that client will at max have 5 proxies cached
1442   * with 5 different node managers. These connections for these proxies will
1443   * be timed out if idle for more than the system wide idle timeout period.
1444   * Note that this could cause issues on large clusters as many connections
1445   * could linger simultaneously and lead to a large number of connection
1446   * threads. The token used for authentication will be used only at
1447   * connection creation time. If a new token is received then the earlier
1448   * connection should be closed in order to use the new token. This and
1449   * {@link YarnConfiguration#NM_CLIENT_ASYNC_THREAD_POOL_MAX_SIZE} are related
1450   * and should be in sync (no need for them to be equal).
1451   * If the value of this property is zero then the connection cache is
1452   * disabled and connections will use a zero idle timeout to prevent too
1453   * many connection threads on large clusters.
1454   */
1455  public static final String NM_CLIENT_MAX_NM_PROXIES =
1456      YARN_PREFIX + "client.max-cached-nodemanagers-proxies";
1457  public static final int DEFAULT_NM_CLIENT_MAX_NM_PROXIES = 0;
1458
1459  /** Max time to wait to establish a connection to NM */
1460  public static final String CLIENT_NM_CONNECT_MAX_WAIT_MS =
1461      YARN_PREFIX + "client.nodemanager-connect.max-wait-ms";
1462  public static final long DEFAULT_CLIENT_NM_CONNECT_MAX_WAIT_MS =
1463      15 * 60 * 1000;
1464
1465  /** Time interval between each attempt to connect to NM */
1466  public static final String CLIENT_NM_CONNECT_RETRY_INTERVAL_MS =
1467      YARN_PREFIX + "client.nodemanager-connect.retry-interval-ms";
1468  public static final long DEFAULT_CLIENT_NM_CONNECT_RETRY_INTERVAL_MS
1469      = 10 * 1000;
1470
1471  public static final String YARN_HTTP_POLICY_KEY = YARN_PREFIX + "http.policy";
1472  public static final String YARN_HTTP_POLICY_DEFAULT = HttpConfig.Policy.HTTP_ONLY
1473      .name();
1474  
1475  public static final String NODE_LABELS_PREFIX = YARN_PREFIX + "node-labels.";
1476
1477  /**
1478   * Class for RMNodeLabelsManager Please note this value should be consistent
1479   * in client nodes and RM node(s)
1480   */
1481  public static final String RM_NODE_LABELS_MANAGER_CLASS = NODE_LABELS_PREFIX
1482      + "manager-class";
1483  
1484  /** URI for NodeLabelManager */
1485  public static final String FS_NODE_LABELS_STORE_ROOT_DIR = NODE_LABELS_PREFIX
1486      + "fs-store.root-dir";
1487  public static final String FS_NODE_LABELS_STORE_RETRY_POLICY_SPEC =
1488      NODE_LABELS_PREFIX + "fs-store.retry-policy-spec";
1489  public static final String DEFAULT_FS_NODE_LABELS_STORE_RETRY_POLICY_SPEC =
1490      "2000, 500";
1491
1492  public YarnConfiguration() {
1493    super();
1494  }
1495  
1496  public YarnConfiguration(Configuration conf) {
1497    super(conf);
1498    if (! (conf instanceof YarnConfiguration)) {
1499      this.reloadConfiguration();
1500    }
1501  }
1502
1503  @Private
1504  public static List<String> getServiceAddressConfKeys(Configuration conf) {
1505    return useHttps(conf) ? RM_SERVICES_ADDRESS_CONF_KEYS_HTTPS
1506        : RM_SERVICES_ADDRESS_CONF_KEYS_HTTP;
1507  }
1508
1509  /**
1510   * Get the socket address for <code>name</code> property as a
1511   * <code>InetSocketAddress</code>. On a HA cluster,
1512   * this fetches the address corresponding to the RM identified by
1513   * {@link #RM_HA_ID}.
1514   * @param name property name.
1515   * @param defaultAddress the default value
1516   * @param defaultPort the default port
1517   * @return InetSocketAddress
1518   */
1519  @Override
1520  public InetSocketAddress getSocketAddr(
1521      String name, String defaultAddress, int defaultPort) {
1522    String address;
1523    if (HAUtil.isHAEnabled(this) && getServiceAddressConfKeys(this).contains(name)) {
1524      address = HAUtil.getConfValueForRMInstance(name, defaultAddress, this);
1525    } else {
1526      address = get(name, defaultAddress);
1527    }
1528    return NetUtils.createSocketAddr(address, defaultPort, name);
1529  }
1530
1531  @Override
1532  public InetSocketAddress updateConnectAddr(String name,
1533                                             InetSocketAddress addr) {
1534    String prefix = name;
1535    if (HAUtil.isHAEnabled(this)) {
1536      prefix = HAUtil.addSuffix(prefix, HAUtil.getRMHAId(this));
1537    }
1538    return super.updateConnectAddr(prefix, addr);
1539  }
1540
1541  @Private
1542  public static int getRMDefaultPortNumber(String addressPrefix,
1543      Configuration conf) {
1544    if (addressPrefix.equals(YarnConfiguration.RM_ADDRESS)) {
1545      return YarnConfiguration.DEFAULT_RM_PORT;
1546    } else if (addressPrefix.equals(YarnConfiguration.RM_SCHEDULER_ADDRESS)) {
1547      return YarnConfiguration.DEFAULT_RM_SCHEDULER_PORT;
1548    } else if (addressPrefix.equals(YarnConfiguration.RM_WEBAPP_ADDRESS)) {
1549      return YarnConfiguration.DEFAULT_RM_WEBAPP_PORT;
1550    } else if (addressPrefix.equals(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS)) {
1551      return YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_PORT;
1552    } else if (addressPrefix
1553        .equals(YarnConfiguration.RM_RESOURCE_TRACKER_ADDRESS)) {
1554      return YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT;
1555    } else if (addressPrefix.equals(YarnConfiguration.RM_ADMIN_ADDRESS)) {
1556      return YarnConfiguration.DEFAULT_RM_ADMIN_PORT;
1557    } else {
1558      throw new HadoopIllegalArgumentException(
1559          "Invalid RM RPC address Prefix: " + addressPrefix
1560              + ". The valid value should be one of "
1561              + getServiceAddressConfKeys(conf));
1562    }
1563  }
1564
1565  public static boolean useHttps(Configuration conf) {
1566    return HttpConfig.Policy.HTTPS_ONLY == HttpConfig.Policy.fromString(conf
1567        .get(YARN_HTTP_POLICY_KEY,
1568            YARN_HTTP_POLICY_DEFAULT));
1569  }
1570
1571  @Private
1572  public static String getClusterId(Configuration conf) {
1573    String clusterId = conf.get(YarnConfiguration.RM_CLUSTER_ID);
1574    if (clusterId == null) {
1575      throw new HadoopIllegalArgumentException("Configuration doesn't specify " +
1576          YarnConfiguration.RM_CLUSTER_ID);
1577    }
1578    return clusterId;
1579  }
1580}