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.util.StringUtils;
035import org.apache.hadoop.yarn.api.ApplicationConstants;
036
037@Public
038@Evolving
039public class YarnConfiguration extends Configuration {
040
041  @Private
042  public static final String CS_CONFIGURATION_FILE= "capacity-scheduler.xml";
043
044  @Private
045  public static final String HADOOP_POLICY_CONFIGURATION_FILE =
046      "hadoop-policy.xml";
047
048  @Private
049  public static final String YARN_SITE_CONFIGURATION_FILE = "yarn-site.xml";
050
051  private static final String YARN_DEFAULT_CONFIGURATION_FILE =
052      "yarn-default.xml";
053
054  @Private
055  public static final String CORE_SITE_CONFIGURATION_FILE = "core-site.xml";
056
057  @Private
058  public static final List<String> RM_CONFIGURATION_FILES =
059      Collections.unmodifiableList(Arrays.asList(
060          CS_CONFIGURATION_FILE,
061          HADOOP_POLICY_CONFIGURATION_FILE,
062          YARN_SITE_CONFIGURATION_FILE,
063          CORE_SITE_CONFIGURATION_FILE));
064
065  @Evolving
066  public static final int APPLICATION_MAX_TAGS = 10;
067
068  @Evolving
069  public static final int APPLICATION_MAX_TAG_LENGTH = 100;
070
071  static {
072    addDeprecatedKeys();
073    Configuration.addDefaultResource(YARN_DEFAULT_CONFIGURATION_FILE);
074    Configuration.addDefaultResource(YARN_SITE_CONFIGURATION_FILE);
075  }
076
077  private static void addDeprecatedKeys() {
078    Configuration.addDeprecations(new DeprecationDelta[] {
079        new DeprecationDelta("yarn.client.max-nodemanagers-proxies",
080            NM_CLIENT_MAX_NM_PROXIES)
081    });
082  }
083
084  //Configurations
085
086  public static final String YARN_PREFIX = "yarn.";
087
088  /** Delay before deleting resource to ease debugging of NM issues */
089  public static final String DEBUG_NM_DELETE_DELAY_SEC =
090    YarnConfiguration.NM_PREFIX + "delete.debug-delay-sec";
091  
092  ////////////////////////////////
093  // IPC Configs
094  ////////////////////////////////
095  public static final String IPC_PREFIX = YARN_PREFIX + "ipc.";
096
097  /** Factory to create client IPC classes.*/
098  public static final String IPC_CLIENT_FACTORY_CLASS =
099    IPC_PREFIX + "client.factory.class";
100  public static final String DEFAULT_IPC_CLIENT_FACTORY_CLASS = 
101      "org.apache.hadoop.yarn.factories.impl.pb.RpcClientFactoryPBImpl";
102
103  /** Factory to create server IPC classes.*/
104  public static final String IPC_SERVER_FACTORY_CLASS = 
105    IPC_PREFIX + "server.factory.class";
106  public static final String DEFAULT_IPC_SERVER_FACTORY_CLASS = 
107      "org.apache.hadoop.yarn.factories.impl.pb.RpcServerFactoryPBImpl";
108
109  /** Factory to create serializeable records.*/
110  public static final String IPC_RECORD_FACTORY_CLASS = 
111    IPC_PREFIX + "record.factory.class";
112  public static final String DEFAULT_IPC_RECORD_FACTORY_CLASS = 
113      "org.apache.hadoop.yarn.factories.impl.pb.RecordFactoryPBImpl";
114
115  /** RPC class implementation*/
116  public static final String IPC_RPC_IMPL =
117    IPC_PREFIX + "rpc.class";
118  public static final String DEFAULT_IPC_RPC_IMPL = 
119    "org.apache.hadoop.yarn.ipc.HadoopYarnProtoRPC";
120  
121  ////////////////////////////////
122  // Resource Manager Configs
123  ////////////////////////////////
124  public static final String RM_PREFIX = "yarn.resourcemanager.";
125
126  public static final String RM_CLUSTER_ID = RM_PREFIX + "cluster-id";
127
128  public static final String RM_HOSTNAME = RM_PREFIX + "hostname";
129
130  /** The address of the applications manager interface in the RM.*/
131  public static final String RM_ADDRESS = 
132    RM_PREFIX + "address";
133  public static final int DEFAULT_RM_PORT = 8032;
134  public static final String DEFAULT_RM_ADDRESS =
135    "0.0.0.0:" + DEFAULT_RM_PORT;
136
137  /** The actual bind address for the RM.*/
138  public static final String RM_BIND_HOST =
139    RM_PREFIX + "bind-host";
140
141  /** The number of threads used to handle applications manager requests.*/
142  public static final String RM_CLIENT_THREAD_COUNT =
143    RM_PREFIX + "client.thread-count";
144  public static final int DEFAULT_RM_CLIENT_THREAD_COUNT = 50;
145
146  /** Number of threads used to launch/cleanup AM.*/
147  public static final String RM_AMLAUNCHER_THREAD_COUNT =
148      RM_PREFIX + "amlauncher.thread-count";
149  public static final int DEFAULT_RM_AMLAUNCHER_THREAD_COUNT = 50;
150
151  /** Retry times to connect with NM.*/
152  public static final String RM_NODEMANAGER_CONNECT_RETIRES =
153      RM_PREFIX + "nodemanager-connect-retries";
154  public static final int DEFAULT_RM_NODEMANAGER_CONNECT_RETIRES = 10;
155
156  /** The Kerberos principal for the resource manager.*/
157  public static final String RM_PRINCIPAL =
158    RM_PREFIX + "principal";
159  
160  /** The address of the scheduler interface.*/
161  public static final String RM_SCHEDULER_ADDRESS = 
162    RM_PREFIX + "scheduler.address";
163  public static final int DEFAULT_RM_SCHEDULER_PORT = 8030;
164  public static final String DEFAULT_RM_SCHEDULER_ADDRESS = "0.0.0.0:" +
165    DEFAULT_RM_SCHEDULER_PORT;
166
167  /** Miniumum request grant-able by the RM scheduler. */
168  public static final String RM_SCHEDULER_MINIMUM_ALLOCATION_MB =
169    YARN_PREFIX + "scheduler.minimum-allocation-mb";
170  public static final int DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB = 1024;
171  public static final String RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES =
172      YARN_PREFIX + "scheduler.minimum-allocation-vcores";
173    public static final int DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES = 1;
174
175  /** Maximum request grant-able by the RM scheduler. */
176  public static final String RM_SCHEDULER_MAXIMUM_ALLOCATION_MB =
177    YARN_PREFIX + "scheduler.maximum-allocation-mb";
178  public static final int DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB = 8192;
179  public static final String RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES =
180      YARN_PREFIX + "scheduler.maximum-allocation-vcores";
181  public static final int DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES = 4;
182
183  /** Number of threads to handle scheduler interface.*/
184  public static final String RM_SCHEDULER_CLIENT_THREAD_COUNT =
185    RM_PREFIX + "scheduler.client.thread-count";
186  public static final int DEFAULT_RM_SCHEDULER_CLIENT_THREAD_COUNT = 50;
187
188  /** If the port should be included or not in the node name. The node name
189   * is used by the scheduler for resource requests allocation location 
190   * matching. Typically this is just the hostname, using the port is needed
191   * when using minicluster and specific NM are required.*/
192  public static final String RM_SCHEDULER_INCLUDE_PORT_IN_NODE_NAME =
193      YARN_PREFIX + "scheduler.include-port-in-node-name";
194  public static final boolean DEFAULT_RM_SCHEDULER_USE_PORT_FOR_NODE_NAME = 
195      false;
196
197  /** Enable Resource Manager webapp ui actions */
198  public static final String RM_WEBAPP_UI_ACTIONS_ENABLED =
199    RM_PREFIX + "webapp.ui-actions.enabled";
200  public static final boolean DEFAULT_RM_WEBAPP_UI_ACTIONS_ENABLED =
201    true;
202
203  /** Whether the RM should enable Reservation System */
204  public static final String RM_RESERVATION_SYSTEM_ENABLE = RM_PREFIX
205      + "reservation-system.enable";
206  public static final boolean DEFAULT_RM_RESERVATION_SYSTEM_ENABLE = false;
207
208  /** The class to use as the Reservation System. */
209  public static final String RM_RESERVATION_SYSTEM_CLASS = RM_PREFIX
210      + "reservation-system.class";
211
212  /** The PlanFollower for the Reservation System. */
213  public static final String RM_RESERVATION_SYSTEM_PLAN_FOLLOWER = RM_PREFIX
214      + "reservation-system.plan.follower";
215
216  /** The step size of the Reservation System. */
217  public static final String RM_RESERVATION_SYSTEM_PLAN_FOLLOWER_TIME_STEP =
218      RM_PREFIX + "reservation-system.planfollower.time-step";
219  public static final long DEFAULT_RM_RESERVATION_SYSTEM_PLAN_FOLLOWER_TIME_STEP =
220      1000L;
221
222  /**
223   * Enable periodic monitor threads.
224   * @see #RM_SCHEDULER_MONITOR_POLICIES
225   */
226  public static final String RM_SCHEDULER_ENABLE_MONITORS =
227    RM_PREFIX + "scheduler.monitor.enable";
228  public static final boolean DEFAULT_RM_SCHEDULER_ENABLE_MONITORS = false;
229
230  /** List of SchedulingEditPolicy classes affecting the scheduler. */
231  public static final String RM_SCHEDULER_MONITOR_POLICIES =
232    RM_PREFIX + "scheduler.monitor.policies";
233
234  /** The address of the RM web application.*/
235  public static final String RM_WEBAPP_ADDRESS = 
236    RM_PREFIX + "webapp.address";
237
238  public static final int DEFAULT_RM_WEBAPP_PORT = 8088;
239  public static final String DEFAULT_RM_WEBAPP_ADDRESS = "0.0.0.0:" +
240    DEFAULT_RM_WEBAPP_PORT;
241  
242  /** The https address of the RM web application.*/
243  public static final String RM_WEBAPP_HTTPS_ADDRESS =
244      RM_PREFIX + "webapp.https.address";
245  public static final boolean YARN_SSL_CLIENT_HTTPS_NEED_AUTH_DEFAULT = false;
246  public static final String YARN_SSL_SERVER_RESOURCE_DEFAULT = "ssl-server.xml";
247  
248  public static final int DEFAULT_RM_WEBAPP_HTTPS_PORT = 8090;
249  public static final String DEFAULT_RM_WEBAPP_HTTPS_ADDRESS = "0.0.0.0:"
250      + DEFAULT_RM_WEBAPP_HTTPS_PORT;
251  
252  public static final String RM_RESOURCE_TRACKER_ADDRESS =
253    RM_PREFIX + "resource-tracker.address";
254  public static final int DEFAULT_RM_RESOURCE_TRACKER_PORT = 8031;
255  public static final String DEFAULT_RM_RESOURCE_TRACKER_ADDRESS =
256    "0.0.0.0:" + DEFAULT_RM_RESOURCE_TRACKER_PORT;
257
258  /** The expiry interval for application master reporting.*/
259  public static final String RM_AM_EXPIRY_INTERVAL_MS = 
260    YARN_PREFIX  + "am.liveness-monitor.expiry-interval-ms";
261  public static final int DEFAULT_RM_AM_EXPIRY_INTERVAL_MS = 600000;
262
263  /** How long to wait until a node manager is considered dead.*/
264  public static final String RM_NM_EXPIRY_INTERVAL_MS = 
265    YARN_PREFIX + "nm.liveness-monitor.expiry-interval-ms";
266  public static final int DEFAULT_RM_NM_EXPIRY_INTERVAL_MS = 600000;
267
268  /** Are acls enabled.*/
269  public static final String YARN_ACL_ENABLE = 
270    YARN_PREFIX + "acl.enable";
271  public static final boolean DEFAULT_YARN_ACL_ENABLE = false;
272  
273  /** ACL of who can be admin of YARN cluster.*/
274  public static final String YARN_ADMIN_ACL = 
275    YARN_PREFIX + "admin.acl";
276  public static final String DEFAULT_YARN_ADMIN_ACL = "*";
277  
278  /** ACL used in case none is found. Allows nothing. */
279  public static final String DEFAULT_YARN_APP_ACL = " ";
280
281  /**
282   * Enable/disable intermediate-data encryption at YARN level. For now, this
283   * only is used by the FileSystemRMStateStore to setup right file-system
284   * security attributes.
285   */
286  @Private
287  public static final String YARN_INTERMEDIATE_DATA_ENCRYPTION = YARN_PREFIX
288      + "intermediate-data-encryption.enable";
289
290  @Private
291  public static final boolean DEFAULT_YARN_INTERMEDIATE_DATA_ENCRYPTION = false;
292
293  /** The address of the RM admin interface.*/
294  public static final String RM_ADMIN_ADDRESS = 
295    RM_PREFIX + "admin.address";
296  public static final int DEFAULT_RM_ADMIN_PORT = 8033;
297  public static final String DEFAULT_RM_ADMIN_ADDRESS = "0.0.0.0:" +
298      DEFAULT_RM_ADMIN_PORT;
299  
300  /**Number of threads used to handle RM admin interface.*/
301  public static final String RM_ADMIN_CLIENT_THREAD_COUNT =
302    RM_PREFIX + "admin.client.thread-count";
303  public static final int DEFAULT_RM_ADMIN_CLIENT_THREAD_COUNT = 1;
304  
305  /**
306   * The maximum number of application attempts.
307   * It's a global setting for all application masters.
308   */
309  public static final String RM_AM_MAX_ATTEMPTS =
310    RM_PREFIX + "am.max-attempts";
311  public static final int DEFAULT_RM_AM_MAX_ATTEMPTS = 2;
312  
313  /** The keytab for the resource manager.*/
314  public static final String RM_KEYTAB = 
315    RM_PREFIX + "keytab";
316
317  /**The kerberos principal to be used for spnego filter for RM.*/
318  public static final String RM_WEBAPP_SPNEGO_USER_NAME_KEY =
319      RM_PREFIX + "webapp.spnego-principal";
320  
321  /**The kerberos keytab to be used for spnego filter for RM.*/
322  public static final String RM_WEBAPP_SPNEGO_KEYTAB_FILE_KEY =
323      RM_PREFIX + "webapp.spnego-keytab-file";
324
325  /**
326   * Flag to enable override of the default kerberos authentication filter with
327   * the RM authentication filter to allow authentication using delegation
328   * tokens(fallback to kerberos if the tokens are missing). Only applicable
329   * when the http authentication type is kerberos.
330   */
331  public static final String RM_WEBAPP_DELEGATION_TOKEN_AUTH_FILTER = RM_PREFIX
332      + "webapp.delegation-token-auth-filter.enabled";
333  public static final boolean DEFAULT_RM_WEBAPP_DELEGATION_TOKEN_AUTH_FILTER =
334      true;
335
336  /** How long to wait until a container is considered dead.*/
337  public static final String RM_CONTAINER_ALLOC_EXPIRY_INTERVAL_MS = 
338    RM_PREFIX + "rm.container-allocation.expiry-interval-ms";
339  public static final int DEFAULT_RM_CONTAINER_ALLOC_EXPIRY_INTERVAL_MS = 600000;
340  
341  /** Path to file with nodes to include.*/
342  public static final String RM_NODES_INCLUDE_FILE_PATH = 
343    RM_PREFIX + "nodes.include-path";
344  public static final String DEFAULT_RM_NODES_INCLUDE_FILE_PATH = "";
345  
346  /** Path to file with nodes to exclude.*/
347  public static final String RM_NODES_EXCLUDE_FILE_PATH = 
348    RM_PREFIX + "nodes.exclude-path";
349  public static final String DEFAULT_RM_NODES_EXCLUDE_FILE_PATH = "";
350  
351  /** Number of threads to handle resource tracker calls.*/
352  public static final String RM_RESOURCE_TRACKER_CLIENT_THREAD_COUNT =
353    RM_PREFIX + "resource-tracker.client.thread-count";
354  public static final int DEFAULT_RM_RESOURCE_TRACKER_CLIENT_THREAD_COUNT = 50;
355  
356  /** The class to use as the resource scheduler.*/
357  public static final String RM_SCHEDULER = 
358    RM_PREFIX + "scheduler.class";
359 
360  public static final String DEFAULT_RM_SCHEDULER = 
361      "org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler";
362
363  /** RM set next Heartbeat interval for NM */
364  public static final String RM_NM_HEARTBEAT_INTERVAL_MS =
365      RM_PREFIX + "nodemanagers.heartbeat-interval-ms";
366  public static final long DEFAULT_RM_NM_HEARTBEAT_INTERVAL_MS = 1000;
367
368  /** Number of worker threads that write the history data. */
369  public static final String RM_HISTORY_WRITER_MULTI_THREADED_DISPATCHER_POOL_SIZE =
370      RM_PREFIX + "history-writer.multi-threaded-dispatcher.pool-size";
371  public static final int DEFAULT_RM_HISTORY_WRITER_MULTI_THREADED_DISPATCHER_POOL_SIZE =
372      10;
373
374  /**
375   *  The setting that controls whether yarn system metrics is published on the
376   *  timeline server or not by RM.
377   */
378  public static final String RM_SYSTEM_METRICS_PUBLISHER_ENABLED =
379      RM_PREFIX + "system-metrics-publisher.enabled";
380  public static final boolean DEFAULT_RM_SYSTEM_METRICS_PUBLISHER_ENABLED = false;
381
382  public static final String RM_SYSTEM_METRICS_PUBLISHER_DISPATCHER_POOL_SIZE =
383      RM_PREFIX + "system-metrics-publisher.dispatcher.pool-size";
384  public static final int DEFAULT_RM_SYSTEM_METRICS_PUBLISHER_DISPATCHER_POOL_SIZE =
385      10;
386
387  //RM delegation token related keys
388  public static final String RM_DELEGATION_KEY_UPDATE_INTERVAL_KEY =
389    RM_PREFIX + "delegation.key.update-interval";
390  public static final long RM_DELEGATION_KEY_UPDATE_INTERVAL_DEFAULT =
391    24*60*60*1000; // 1 day
392  public static final String RM_DELEGATION_TOKEN_RENEW_INTERVAL_KEY =
393    RM_PREFIX + "delegation.token.renew-interval";
394  public static final long RM_DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT =
395    24*60*60*1000;  // 1 day
396  public static final String RM_DELEGATION_TOKEN_MAX_LIFETIME_KEY =
397     RM_PREFIX + "delegation.token.max-lifetime";
398  public static final long RM_DELEGATION_TOKEN_MAX_LIFETIME_DEFAULT =
399    7*24*60*60*1000; // 7 days
400  
401  public static final String RECOVERY_ENABLED = RM_PREFIX + "recovery.enabled";
402  public static final boolean DEFAULT_RM_RECOVERY_ENABLED = false;
403
404  public static final String YARN_FAIL_FAST = YARN_PREFIX + "fail-fast";
405  public static final boolean DEFAULT_YARN_FAIL_FAST = true;
406
407  public static final String RM_FAIL_FAST = RM_PREFIX + "fail-fast";
408
409  @Private
410  public static final String RM_WORK_PRESERVING_RECOVERY_ENABLED = RM_PREFIX
411      + "work-preserving-recovery.enabled";
412  @Private
413  public static final boolean DEFAULT_RM_WORK_PRESERVING_RECOVERY_ENABLED =
414      true;
415
416  public static final String RM_WORK_PRESERVING_RECOVERY_SCHEDULING_WAIT_MS =
417      RM_PREFIX + "work-preserving-recovery.scheduling-wait-ms";
418  public static final long DEFAULT_RM_WORK_PRESERVING_RECOVERY_SCHEDULING_WAIT_MS =
419      10000;
420
421  /** Zookeeper interaction configs */
422  public static final String RM_ZK_PREFIX = RM_PREFIX + "zk-";
423
424  public static final String RM_ZK_ADDRESS = RM_ZK_PREFIX + "address";
425
426  public static final String RM_ZK_NUM_RETRIES = RM_ZK_PREFIX + "num-retries";
427  public static final int DEFAULT_ZK_RM_NUM_RETRIES = 1000;
428
429  public static final String RM_ZK_RETRY_INTERVAL_MS =
430      RM_ZK_PREFIX + "retry-interval-ms";
431  public static final int DEFAULT_RM_ZK_RETRY_INTERVAL_MS = 1000;
432
433  public static final String RM_ZK_TIMEOUT_MS = RM_ZK_PREFIX + "timeout-ms";
434  public static final int DEFAULT_RM_ZK_TIMEOUT_MS = 10000;
435
436  public static final String RM_ZK_ACL = RM_ZK_PREFIX + "acl";
437  public static final String DEFAULT_RM_ZK_ACL = "world:anyone:rwcda";
438
439  public static final String RM_ZK_AUTH = RM_ZK_PREFIX + "auth";
440
441  public static final String ZK_STATE_STORE_PREFIX =
442      RM_PREFIX + "zk-state-store.";
443
444  /** Parent znode path under which ZKRMStateStore will create znodes */
445  public static final String ZK_RM_STATE_STORE_PARENT_PATH =
446      ZK_STATE_STORE_PREFIX + "parent-path";
447  public static final String DEFAULT_ZK_RM_STATE_STORE_PARENT_PATH = "/rmstore";
448
449  /** Root node ACLs for fencing */
450  public static final String ZK_RM_STATE_STORE_ROOT_NODE_ACL =
451      ZK_STATE_STORE_PREFIX + "root-node.acl";
452
453  /** HA related configs */
454  public static final String RM_HA_PREFIX = RM_PREFIX + "ha.";
455  public static final String RM_HA_ENABLED = RM_HA_PREFIX + "enabled";
456  public static final boolean DEFAULT_RM_HA_ENABLED = false;
457
458  public static final String RM_HA_IDS = RM_HA_PREFIX + "rm-ids";
459  public static final String RM_HA_ID = RM_HA_PREFIX + "id";
460
461  /** Store the related configuration files in File System */
462  public static final String FS_BASED_RM_CONF_STORE = RM_PREFIX
463      + "configuration.file-system-based-store";
464  public static final String DEFAULT_FS_BASED_RM_CONF_STORE = "/yarn/conf";
465
466  public static final String RM_CONFIGURATION_PROVIDER_CLASS = RM_PREFIX
467      + "configuration.provider-class";
468  public static final String DEFAULT_RM_CONFIGURATION_PROVIDER_CLASS =
469      "org.apache.hadoop.yarn.LocalConfigurationProvider";
470
471  public static final String YARN_AUTHORIZATION_PROVIDER = YARN_PREFIX
472      + "authorization-provider";
473  private static final List<String> RM_SERVICES_ADDRESS_CONF_KEYS_HTTP =
474      Collections.unmodifiableList(Arrays.asList(
475          RM_ADDRESS,
476          RM_SCHEDULER_ADDRESS,
477          RM_ADMIN_ADDRESS,
478          RM_RESOURCE_TRACKER_ADDRESS,
479          RM_WEBAPP_ADDRESS));
480
481  private static final List<String> RM_SERVICES_ADDRESS_CONF_KEYS_HTTPS =
482      Collections.unmodifiableList(Arrays.asList(
483          RM_ADDRESS,
484          RM_SCHEDULER_ADDRESS,
485          RM_ADMIN_ADDRESS,
486          RM_RESOURCE_TRACKER_ADDRESS,
487          RM_WEBAPP_HTTPS_ADDRESS));
488
489  public static final String AUTO_FAILOVER_PREFIX =
490      RM_HA_PREFIX + "automatic-failover.";
491
492  public static final String AUTO_FAILOVER_ENABLED =
493      AUTO_FAILOVER_PREFIX + "enabled";
494  public static final boolean DEFAULT_AUTO_FAILOVER_ENABLED = true;
495
496  public static final String AUTO_FAILOVER_EMBEDDED =
497      AUTO_FAILOVER_PREFIX + "embedded";
498  public static final boolean DEFAULT_AUTO_FAILOVER_EMBEDDED = true;
499
500  public static final String AUTO_FAILOVER_ZK_BASE_PATH =
501      AUTO_FAILOVER_PREFIX + "zk-base-path";
502  public static final String DEFAULT_AUTO_FAILOVER_ZK_BASE_PATH =
503      "/yarn-leader-election";
504
505  public static final String CLIENT_FAILOVER_PREFIX =
506      YARN_PREFIX + "client.failover-";
507  public static final String CLIENT_FAILOVER_PROXY_PROVIDER =
508      CLIENT_FAILOVER_PREFIX + "proxy-provider";
509  public static final String DEFAULT_CLIENT_FAILOVER_PROXY_PROVIDER =
510      "org.apache.hadoop.yarn.client.ConfiguredRMFailoverProxyProvider";
511
512  public static final String CLIENT_FAILOVER_MAX_ATTEMPTS =
513      CLIENT_FAILOVER_PREFIX + "max-attempts";
514
515  public static final String CLIENT_FAILOVER_SLEEPTIME_BASE_MS =
516      CLIENT_FAILOVER_PREFIX + "sleep-base-ms";
517
518  public static final String CLIENT_FAILOVER_SLEEPTIME_MAX_MS =
519      CLIENT_FAILOVER_PREFIX + "sleep-max-ms";
520
521  public static final String CLIENT_FAILOVER_RETRIES =
522      CLIENT_FAILOVER_PREFIX + "retries";
523  public static final int DEFAULT_CLIENT_FAILOVER_RETRIES = 0;
524
525  public static final String CLIENT_FAILOVER_RETRIES_ON_SOCKET_TIMEOUTS =
526      CLIENT_FAILOVER_PREFIX + "retries-on-socket-timeouts";
527  public static final int
528      DEFAULT_CLIENT_FAILOVER_RETRIES_ON_SOCKET_TIMEOUTS = 0;
529
530  ////////////////////////////////
531  // RM state store configs
532  ////////////////////////////////
533  /** The class to use as the persistent store.*/
534  public static final String RM_STORE = RM_PREFIX + "store.class";
535  
536  /** URI for FileSystemRMStateStore */
537  public static final String FS_RM_STATE_STORE_URI = RM_PREFIX
538      + "fs.state-store.uri";
539  public static final String FS_RM_STATE_STORE_RETRY_POLICY_SPEC = RM_PREFIX
540      + "fs.state-store.retry-policy-spec";
541  public static final String DEFAULT_FS_RM_STATE_STORE_RETRY_POLICY_SPEC =
542      "2000, 500";
543
544  public static final String FS_RM_STATE_STORE_NUM_RETRIES =
545      RM_PREFIX + "fs.state-store.num-retries";
546  public static final int DEFAULT_FS_RM_STATE_STORE_NUM_RETRIES = 0;
547
548  public static final String FS_RM_STATE_STORE_RETRY_INTERVAL_MS =
549      RM_PREFIX + "fs.state-store.retry-interval-ms";
550  public static final long DEFAULT_FS_RM_STATE_STORE_RETRY_INTERVAL_MS =
551      1000L;
552
553  public static final String RM_LEVELDB_STORE_PATH = RM_PREFIX
554      + "leveldb-state-store.path";
555
556  /** The maximum number of completed applications RM keeps. */ 
557  public static final String RM_MAX_COMPLETED_APPLICATIONS =
558    RM_PREFIX + "max-completed-applications";
559  public static final int DEFAULT_RM_MAX_COMPLETED_APPLICATIONS = 10000;
560
561  /**
562   * The maximum number of completed applications RM state store keeps, by
563   * default equals to DEFAULT_RM_MAX_COMPLETED_APPLICATIONS
564   */
565  public static final String RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS =
566      RM_PREFIX + "state-store.max-completed-applications";
567  public static final int DEFAULT_RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS =
568      DEFAULT_RM_MAX_COMPLETED_APPLICATIONS;
569
570  /** Default application name */
571  public static final String DEFAULT_APPLICATION_NAME = "N/A";
572
573  /** Default application type */
574  public static final String DEFAULT_APPLICATION_TYPE = "YARN";
575
576  /** Default application type length */
577  public static final int APPLICATION_TYPE_LENGTH = 20;
578  
579  /** Default queue name */
580  public static final String DEFAULT_QUEUE_NAME = "default";
581
582  /**
583   * Buckets (in minutes) for the number of apps running in each queue.
584   */
585  public static final String RM_METRICS_RUNTIME_BUCKETS =
586    RM_PREFIX + "metrics.runtime.buckets";
587
588  /**
589   * Default sizes of the runtime metric buckets in minutes.
590   */
591  public static final String DEFAULT_RM_METRICS_RUNTIME_BUCKETS = 
592    "60,300,1440";
593
594  public static final String RM_AMRM_TOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS = RM_PREFIX
595      + "am-rm-tokens.master-key-rolling-interval-secs";
596
597  public static final long DEFAULT_RM_AMRM_TOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS =
598      24 * 60 * 60;
599
600  public static final String RM_CONTAINER_TOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS =
601      RM_PREFIX + "container-tokens.master-key-rolling-interval-secs";
602
603  public static final long DEFAULT_RM_CONTAINER_TOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS =
604      24 * 60 * 60;
605
606  public static final String RM_NMTOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS =
607      RM_PREFIX + "nm-tokens.master-key-rolling-interval-secs";
608  
609  public static final long DEFAULT_RM_NMTOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS =
610      24 * 60 * 60;
611
612  public static final String RM_NODEMANAGER_MINIMUM_VERSION =
613      RM_PREFIX + "nodemanager.minimum.version";
614
615  public static final String DEFAULT_RM_NODEMANAGER_MINIMUM_VERSION =
616      "NONE";
617
618  /**
619   * RM proxy users' prefix
620   */
621  public static final String RM_PROXY_USER_PREFIX = RM_PREFIX + "proxyuser.";
622
623  ////////////////////////////////
624  // Node Manager Configs
625  ////////////////////////////////
626  
627  /** Prefix for all node manager configs.*/
628  public static final String NM_PREFIX = "yarn.nodemanager.";
629
630  /** Environment variables that will be sent to containers.*/
631  public static final String NM_ADMIN_USER_ENV = NM_PREFIX + "admin-env";
632  public static final String DEFAULT_NM_ADMIN_USER_ENV = "MALLOC_ARENA_MAX=$MALLOC_ARENA_MAX";
633
634  /** Environment variables that containers may override rather than use NodeManager's default.*/
635  public static final String NM_ENV_WHITELIST = NM_PREFIX + "env-whitelist";
636  public static final String DEFAULT_NM_ENV_WHITELIST = StringUtils.join(",",
637    Arrays.asList(ApplicationConstants.Environment.JAVA_HOME.key(),
638      ApplicationConstants.Environment.HADOOP_COMMON_HOME.key(),
639      ApplicationConstants.Environment.HADOOP_HDFS_HOME.key(),
640      ApplicationConstants.Environment.HADOOP_CONF_DIR.key(),
641      ApplicationConstants.Environment.CLASSPATH_PREPEND_DISTCACHE.key(),
642      ApplicationConstants.Environment.HADOOP_YARN_HOME.key()));
643  
644  /** address of node manager IPC.*/
645  public static final String NM_ADDRESS = NM_PREFIX + "address";
646  public static final int DEFAULT_NM_PORT = 0;
647  public static final String DEFAULT_NM_ADDRESS = "0.0.0.0:"
648      + DEFAULT_NM_PORT;
649  
650  /** The actual bind address or the NM.*/
651  public static final String NM_BIND_HOST =
652    NM_PREFIX + "bind-host";
653
654  /** who will execute(launch) the containers.*/
655  public static final String NM_CONTAINER_EXECUTOR = 
656    NM_PREFIX + "container-executor.class";
657
658  /**  
659   * Adjustment to make to the container os scheduling priority.
660   * The valid values for this could vary depending on the platform.
661   * On Linux, higher values mean run the containers at a less 
662   * favorable priority than the NM. 
663   * The value specified is an int.
664   */
665  public static final String NM_CONTAINER_EXECUTOR_SCHED_PRIORITY = 
666    NM_PREFIX + "container-executor.os.sched.priority.adjustment";
667  public static final int DEFAULT_NM_CONTAINER_EXECUTOR_SCHED_PRIORITY = 0;
668  
669  /** Number of threads container manager uses.*/
670  public static final String NM_CONTAINER_MGR_THREAD_COUNT =
671    NM_PREFIX + "container-manager.thread-count";
672  public static final int DEFAULT_NM_CONTAINER_MGR_THREAD_COUNT = 20;
673  
674  /** Number of threads used in cleanup.*/
675  public static final String NM_DELETE_THREAD_COUNT = 
676    NM_PREFIX +  "delete.thread-count";
677  public static final int DEFAULT_NM_DELETE_THREAD_COUNT = 4;
678  
679  /** Keytab for NM.*/
680  public static final String NM_KEYTAB = NM_PREFIX + "keytab";
681  
682  /**List of directories to store localized files in.*/
683  public static final String NM_LOCAL_DIRS = NM_PREFIX + "local-dirs";
684  public static final String DEFAULT_NM_LOCAL_DIRS = "/tmp/nm-local-dir";
685
686  /**
687   * Number of files in each localized directories
688   * Avoid tuning this too low. 
689   */
690  public static final String NM_LOCAL_CACHE_MAX_FILES_PER_DIRECTORY =
691    NM_PREFIX + "local-cache.max-files-per-directory";
692  public static final int DEFAULT_NM_LOCAL_CACHE_MAX_FILES_PER_DIRECTORY = 8192;
693
694  /** Address where the localizer IPC is.*/
695  public static final String NM_LOCALIZER_ADDRESS =
696    NM_PREFIX + "localizer.address";
697  public static final int DEFAULT_NM_LOCALIZER_PORT = 8040;
698  public static final String DEFAULT_NM_LOCALIZER_ADDRESS = "0.0.0.0:" +
699    DEFAULT_NM_LOCALIZER_PORT;
700  
701  /** Interval in between cache cleanups.*/
702  public static final String NM_LOCALIZER_CACHE_CLEANUP_INTERVAL_MS =
703    NM_PREFIX + "localizer.cache.cleanup.interval-ms";
704  public static final long DEFAULT_NM_LOCALIZER_CACHE_CLEANUP_INTERVAL_MS = 
705    10 * 60 * 1000;
706  
707  /**
708   * Target size of localizer cache in MB, per nodemanager. It is a target
709   * retention size that only includes resources with PUBLIC and PRIVATE
710   * visibility and excludes resources with APPLICATION visibility
711   */
712  public static final String NM_LOCALIZER_CACHE_TARGET_SIZE_MB =
713    NM_PREFIX + "localizer.cache.target-size-mb";
714  public static final long DEFAULT_NM_LOCALIZER_CACHE_TARGET_SIZE_MB = 10 * 1024;
715  
716  /** Number of threads to handle localization requests.*/
717  public static final String NM_LOCALIZER_CLIENT_THREAD_COUNT =
718    NM_PREFIX + "localizer.client.thread-count";
719  public static final int DEFAULT_NM_LOCALIZER_CLIENT_THREAD_COUNT = 5;
720  
721  /** Number of threads to use for localization fetching.*/
722  public static final String NM_LOCALIZER_FETCH_THREAD_COUNT = 
723    NM_PREFIX + "localizer.fetch.thread-count";
724  public static final int DEFAULT_NM_LOCALIZER_FETCH_THREAD_COUNT = 4;
725
726  /** Where to store container logs.*/
727  public static final String NM_LOG_DIRS = NM_PREFIX + "log-dirs";
728  public static final String DEFAULT_NM_LOG_DIRS = "/tmp/logs";
729
730  public static final String NM_RESOURCEMANAGER_MINIMUM_VERSION =
731      NM_PREFIX + "resourcemanager.minimum.version";
732  public static final String DEFAULT_NM_RESOURCEMANAGER_MINIMUM_VERSION = "NONE";
733
734  /** Interval at which the delayed token removal thread runs */
735  public static final String RM_DELAYED_DELEGATION_TOKEN_REMOVAL_INTERVAL_MS =
736      RM_PREFIX + "delayed.delegation-token.removal-interval-ms";
737  public static final long DEFAULT_RM_DELAYED_DELEGATION_TOKEN_REMOVAL_INTERVAL_MS =
738      30000l;
739  
740  /** Delegation Token renewer thread count */
741  public static final String RM_DELEGATION_TOKEN_RENEWER_THREAD_COUNT =
742      RM_PREFIX + "delegation-token-renewer.thread-count";
743  public static final int DEFAULT_RM_DELEGATION_TOKEN_RENEWER_THREAD_COUNT = 50;
744
745  public static final String RM_PROXY_USER_PRIVILEGES_ENABLED = RM_PREFIX
746      + "proxy-user-privileges.enabled";
747  public static final boolean DEFAULT_RM_PROXY_USER_PRIVILEGES_ENABLED = false;
748
749  /**
750   * How many diagnostics/failure messages can be saved in RM for
751   * log aggregation. It also defines the number of diagnostics/failure
752   * messages can be shown in log aggregation web ui.
753   */
754  public static final String RM_MAX_LOG_AGGREGATION_DIAGNOSTICS_IN_MEMORY =
755      RM_PREFIX + "max-log-aggregation-diagnostics-in-memory";
756  public static final int DEFAULT_RM_MAX_LOG_AGGREGATION_DIAGNOSTICS_IN_MEMORY =
757      10;
758
759  /** Whether to enable log aggregation */
760  public static final String LOG_AGGREGATION_ENABLED = YARN_PREFIX
761      + "log-aggregation-enable";
762  public static final boolean DEFAULT_LOG_AGGREGATION_ENABLED = false;
763  
764  /** 
765   * How long to wait before deleting aggregated logs, -1 disables.
766   * Be careful set this too small and you will spam the name node.
767   */
768  public static final String LOG_AGGREGATION_RETAIN_SECONDS = YARN_PREFIX
769      + "log-aggregation.retain-seconds";
770  public static final long DEFAULT_LOG_AGGREGATION_RETAIN_SECONDS = -1;
771  
772  /**
773   * How long to wait between aggregated log retention checks. If set to
774   * a value {@literal <=} 0 then the value is computed as one-tenth of the
775   * log retention setting. Be careful set this too small and you will spam
776   * the name node.
777   */
778  public static final String LOG_AGGREGATION_RETAIN_CHECK_INTERVAL_SECONDS =
779      YARN_PREFIX + "log-aggregation.retain-check-interval-seconds";
780  public static final long DEFAULT_LOG_AGGREGATION_RETAIN_CHECK_INTERVAL_SECONDS = -1;
781
782  /**
783   * How long for ResourceManager to wait for NodeManager to report its
784   * log aggregation status. If waiting time of which the log aggregation status
785   * is reported from NodeManager exceeds the configured value, RM will report
786   * log aggregation status for this NodeManager as TIME_OUT
787   */
788  public static final String LOG_AGGREGATION_STATUS_TIME_OUT_MS =
789      YARN_PREFIX + "log-aggregation-status.time-out.ms";
790  public static final long DEFAULT_LOG_AGGREGATION_STATUS_TIME_OUT_MS
791      = 10 * 60 * 1000;
792
793  /**
794   * Number of seconds to retain logs on the NodeManager. Only applicable if Log
795   * aggregation is disabled
796   */
797  public static final String NM_LOG_RETAIN_SECONDS = NM_PREFIX
798      + "log.retain-seconds";
799  public static final long DEFAULT_NM_LOG_RETAIN_SECONDS = 3 * 60 * 60;
800
801  /**
802   * Define how often NMs wake up and upload log files
803   */
804  public static final String NM_LOG_AGGREGATION_ROLL_MONITORING_INTERVAL_SECONDS =
805      NM_PREFIX + "log-aggregation.roll-monitoring-interval-seconds";
806  public static final long
807      DEFAULT_NM_LOG_AGGREGATION_ROLL_MONITORING_INTERVAL_SECONDS = -1;
808  /**
809   * Number of threads used in log cleanup. Only applicable if Log aggregation
810   * is disabled
811   */
812  public static final String NM_LOG_DELETION_THREADS_COUNT = 
813    NM_PREFIX +  "log.deletion-threads-count";
814  public static final int DEFAULT_NM_LOG_DELETE_THREAD_COUNT = 4;
815
816  /** Where to aggregate logs to.*/
817  public static final String NM_REMOTE_APP_LOG_DIR = 
818    NM_PREFIX + "remote-app-log-dir";
819  public static final String DEFAULT_NM_REMOTE_APP_LOG_DIR = "/tmp/logs";
820
821  /**
822   * The remote log dir will be created at
823   * NM_REMOTE_APP_LOG_DIR/${user}/NM_REMOTE_APP_LOG_DIR_SUFFIX/${appId}
824   */
825  public static final String NM_REMOTE_APP_LOG_DIR_SUFFIX = 
826    NM_PREFIX + "remote-app-log-dir-suffix";
827  public static final String DEFAULT_NM_REMOTE_APP_LOG_DIR_SUFFIX="logs";
828
829  public static final String YARN_LOG_SERVER_URL =
830    YARN_PREFIX + "log.server.url";
831  
832  public static final String YARN_TRACKING_URL_GENERATOR = 
833      YARN_PREFIX + "tracking.url.generator";
834
835  /** Amount of memory in MB that can be allocated for containers.*/
836  public static final String NM_PMEM_MB = NM_PREFIX + "resource.memory-mb";
837  public static final int DEFAULT_NM_PMEM_MB = 8 * 1024;
838
839  /** Amount of memory in MB that has been reserved for non-yarn use. */
840  public static final String NM_SYSTEM_RESERVED_PMEM_MB = NM_PREFIX
841      + "resource.system-reserved-memory-mb";
842
843  /** Specifies whether physical memory check is enabled. */
844  public static final String NM_PMEM_CHECK_ENABLED = NM_PREFIX
845      + "pmem-check-enabled";
846  public static final boolean DEFAULT_NM_PMEM_CHECK_ENABLED = true;
847
848  /** Specifies whether physical memory check is enabled. */
849  public static final String NM_VMEM_CHECK_ENABLED = NM_PREFIX
850      + "vmem-check-enabled";
851  public static final boolean DEFAULT_NM_VMEM_CHECK_ENABLED = true;
852
853  /** Conversion ratio for physical memory to virtual memory. */
854  public static final String NM_VMEM_PMEM_RATIO =
855    NM_PREFIX + "vmem-pmem-ratio";
856  public static final float DEFAULT_NM_VMEM_PMEM_RATIO = 2.1f;
857  
858  /** Number of Virtual CPU Cores which can be allocated for containers.*/
859  public static final String NM_VCORES = NM_PREFIX + "resource.cpu-vcores";
860  public static final int DEFAULT_NM_VCORES = 8;
861
862  /** Count logical processors(like hyperthreads) as cores. */
863  public static final String NM_COUNT_LOGICAL_PROCESSORS_AS_CORES = NM_PREFIX
864      + "resource.count-logical-processors-as-cores";
865  public static final boolean DEFAULT_NM_COUNT_LOGICAL_PROCESSORS_AS_CORES =
866      false;
867
868  /** Multiplier to convert physical cores to vcores. */
869  public static final String NM_PCORES_VCORES_MULTIPLIER = NM_PREFIX
870      + "resource.pcores-vcores-multiplier";
871  public static final float DEFAULT_NM_PCORES_VCORES_MULTIPLIER = 1.0f;
872
873  /** Percentage of overall CPU which can be allocated for containers. */
874  public static final String NM_RESOURCE_PERCENTAGE_PHYSICAL_CPU_LIMIT =
875      NM_PREFIX + "resource.percentage-physical-cpu-limit";
876  public static final int DEFAULT_NM_RESOURCE_PERCENTAGE_PHYSICAL_CPU_LIMIT =
877      100;
878
879  /** Enable or disable node hardware capability detection. */
880  public static final String NM_ENABLE_HARDWARE_CAPABILITY_DETECTION =
881      NM_PREFIX + "resource.detect-hardware-capabilities";
882  public static final boolean DEFAULT_NM_ENABLE_HARDWARE_CAPABILITY_DETECTION =
883      false;
884
885  /**
886   * Prefix for disk configurations. Work in progress: This configuration
887   * parameter may be changed/removed in the future.
888   */
889  @Private
890  public static final String NM_DISK_RESOURCE_PREFIX = NM_PREFIX
891      + "resource.disk.";
892  /**
893   * This setting controls if resource handling for disk operations is enabled.
894   * Work in progress: This configuration parameter may be changed/removed in
895   * the future
896   */
897  @Private
898  public static final String NM_DISK_RESOURCE_ENABLED = NM_DISK_RESOURCE_PREFIX
899      + "enabled";
900  /** Disk as a resource is disabled by default. **/
901  @Private
902  public static final boolean DEFAULT_NM_DISK_RESOURCE_ENABLED = false;
903
904  public static final String NM_NETWORK_RESOURCE_PREFIX = NM_PREFIX
905      + "resource.network.";
906
907  /**
908   * This setting controls if resource handling for network bandwidth is
909   * enabled. Work in progress: This configuration parameter may be
910   * changed/removed in the future
911   */
912  @Private
913  public static final String NM_NETWORK_RESOURCE_ENABLED =
914      NM_NETWORK_RESOURCE_PREFIX + "enabled";
915  /** Network as a resource is disabled by default. **/
916  @Private
917  public static final boolean DEFAULT_NM_NETWORK_RESOURCE_ENABLED = false;
918
919  /**
920   * Specifies the interface to be used for applying network throttling rules.
921   * Work in progress: This configuration parameter may be changed/removed in
922   * the future
923   */
924  @Private
925  public static final String NM_NETWORK_RESOURCE_INTERFACE =
926      NM_NETWORK_RESOURCE_PREFIX + "interface";
927  @Private
928  public static final String DEFAULT_NM_NETWORK_RESOURCE_INTERFACE = "eth0";
929
930  /**
931   * Specifies the total available outbound bandwidth on the node. Work in
932   * progress: This configuration parameter may be changed/removed in the future
933   */
934  @Private
935  public static final String NM_NETWORK_RESOURCE_OUTBOUND_BANDWIDTH_MBIT =
936      NM_NETWORK_RESOURCE_PREFIX + "outbound-bandwidth-mbit";
937  @Private
938  public static final int DEFAULT_NM_NETWORK_RESOURCE_OUTBOUND_BANDWIDTH_MBIT =
939      1000;
940
941  /**
942   * Specifies the total outbound bandwidth available to YARN containers.
943   * defaults to NM_NETWORK_RESOURCE_OUTBOUND_BANDWIDTH_MBIT if not specified.
944   * Work in progress: This configuration parameter may be changed/removed in
945   * the future
946   */
947  @Private
948  public static final String NM_NETWORK_RESOURCE_OUTBOUND_BANDWIDTH_YARN_MBIT =
949      NM_NETWORK_RESOURCE_PREFIX + "outbound-bandwidth-yarn-mbit";
950
951  /** NM Webapp address.**/
952  public static final String NM_WEBAPP_ADDRESS = NM_PREFIX + "webapp.address";
953  public static final int DEFAULT_NM_WEBAPP_PORT = 8042;
954  public static final String DEFAULT_NM_WEBAPP_ADDRESS = "0.0.0.0:" +
955    DEFAULT_NM_WEBAPP_PORT;
956  
957  /** NM Webapp https address.**/
958  public static final String NM_WEBAPP_HTTPS_ADDRESS = NM_PREFIX
959      + "webapp.https.address";
960  public static final int DEFAULT_NM_WEBAPP_HTTPS_PORT = 8044;
961  public static final String DEFAULT_NM_WEBAPP_HTTPS_ADDRESS = "0.0.0.0:"
962      + DEFAULT_NM_WEBAPP_HTTPS_PORT; 
963
964  /** How often to monitor resource in a node.*/
965  public static final String NM_RESOURCE_MON_INTERVAL_MS =
966      NM_PREFIX + "resource-monitor.interval-ms";
967  public static final int DEFAULT_NM_RESOURCE_MON_INTERVAL_MS = 3000;
968
969  /** How often to monitor containers.*/
970  public final static String NM_CONTAINER_MON_INTERVAL_MS =
971    NM_PREFIX + "container-monitor.interval-ms";
972  @Deprecated
973  public final static int DEFAULT_NM_CONTAINER_MON_INTERVAL_MS = 3000;
974
975  /** Class that calculates current resource utilization.*/
976  public static final String NM_MON_RESOURCE_CALCULATOR =
977      NM_PREFIX + "resource-calculator.class";
978  /** Class that calculates containers current resource utilization.*/
979  public static final String NM_CONTAINER_MON_RESOURCE_CALCULATOR =
980    NM_PREFIX + "container-monitor.resource-calculator.class";
981  /** Class that calculates process tree resource utilization.*/
982  public static final String NM_CONTAINER_MON_PROCESS_TREE =
983    NM_PREFIX + "container-monitor.process-tree.class";
984  public static final String PROCFS_USE_SMAPS_BASED_RSS_ENABLED = NM_PREFIX +
985      "container-monitor.procfs-tree.smaps-based-rss.enabled";
986  public static final boolean DEFAULT_PROCFS_USE_SMAPS_BASED_RSS_ENABLED =
987      false;
988
989  /** Enable/disable container metrics. */
990  @Private
991  public static final String NM_CONTAINER_METRICS_ENABLE =
992      NM_PREFIX + "container-metrics.enable";
993  @Private
994  public static final boolean DEFAULT_NM_CONTAINER_METRICS_ENABLE = true;
995
996  /** Container metrics flush period. -1 for flush on completion. */
997  @Private
998  public static final String NM_CONTAINER_METRICS_PERIOD_MS =
999      NM_PREFIX + "container-metrics.period-ms";
1000  @Private
1001  public static final int DEFAULT_NM_CONTAINER_METRICS_PERIOD_MS = -1;
1002  
1003  /** Prefix for all node manager disk health checker configs. */
1004  private static final String NM_DISK_HEALTH_CHECK_PREFIX =
1005      "yarn.nodemanager.disk-health-checker.";
1006  /**
1007   * Enable/Disable disks' health checker. Default is true. An expert level
1008   * configuration property.
1009   */
1010  public static final String NM_DISK_HEALTH_CHECK_ENABLE =
1011      NM_DISK_HEALTH_CHECK_PREFIX + "enable";
1012  /** Frequency of running disks' health checker. */
1013  public static final String NM_DISK_HEALTH_CHECK_INTERVAL_MS =
1014      NM_DISK_HEALTH_CHECK_PREFIX + "interval-ms";
1015  /** By default, disks' health is checked every 2 minutes. */
1016  public static final long DEFAULT_NM_DISK_HEALTH_CHECK_INTERVAL_MS =
1017      2 * 60 * 1000;
1018
1019  /**
1020   * The minimum fraction of number of disks to be healthy for the nodemanager
1021   * to launch new containers. This applies to nm-local-dirs and nm-log-dirs.
1022   */
1023  public static final String NM_MIN_HEALTHY_DISKS_FRACTION =
1024      NM_DISK_HEALTH_CHECK_PREFIX + "min-healthy-disks";
1025  /**
1026   * By default, at least 25% of disks are to be healthy to say that the node is
1027   * healthy in terms of disks.
1028   */
1029  public static final float DEFAULT_NM_MIN_HEALTHY_DISKS_FRACTION = 0.25F;
1030
1031  /**
1032   * The maximum percentage of disk space that can be used after which a disk is
1033   * marked as offline. Values can range from 0.0 to 100.0. If the value is
1034   * greater than or equal to 100, NM will check for full disk. This applies to
1035   * nm-local-dirs and nm-log-dirs.
1036   */
1037  public static final String NM_MAX_PER_DISK_UTILIZATION_PERCENTAGE =
1038      NM_DISK_HEALTH_CHECK_PREFIX + "max-disk-utilization-per-disk-percentage";
1039  /**
1040   * By default, 90% of the disk can be used before it is marked as offline.
1041   */
1042  public static final float DEFAULT_NM_MAX_PER_DISK_UTILIZATION_PERCENTAGE =
1043      90.0F;
1044
1045  /**
1046   * The minimum space that must be available on a local dir for it to be used.
1047   * This applies to nm-local-dirs and nm-log-dirs.
1048   */
1049  public static final String NM_MIN_PER_DISK_FREE_SPACE_MB =
1050      NM_DISK_HEALTH_CHECK_PREFIX + "min-free-space-per-disk-mb";
1051  /**
1052   * By default, all of the disk can be used before it is marked as offline.
1053   */
1054  public static final long DEFAULT_NM_MIN_PER_DISK_FREE_SPACE_MB = 0;
1055
1056  /** Frequency of running node health script.*/
1057  public static final String NM_HEALTH_CHECK_INTERVAL_MS = 
1058    NM_PREFIX + "health-checker.interval-ms";
1059  public static final long DEFAULT_NM_HEALTH_CHECK_INTERVAL_MS = 10 * 60 * 1000;
1060
1061  /** Health check script time out period.*/  
1062  public static final String NM_HEALTH_CHECK_SCRIPT_TIMEOUT_MS = 
1063    NM_PREFIX + "health-checker.script.timeout-ms";
1064  public static final long DEFAULT_NM_HEALTH_CHECK_SCRIPT_TIMEOUT_MS = 
1065    2 * DEFAULT_NM_HEALTH_CHECK_INTERVAL_MS;
1066  
1067  /** The health check script to run.*/
1068  public static final String NM_HEALTH_CHECK_SCRIPT_PATH = 
1069    NM_PREFIX + "health-checker.script.path";
1070  
1071  /** The arguments to pass to the health check script.*/
1072  public static final String NM_HEALTH_CHECK_SCRIPT_OPTS = 
1073    NM_PREFIX + "health-checker.script.opts";
1074
1075  /** The JVM options used on forking ContainerLocalizer process
1076      by container executor. */
1077  public static final String NM_CONTAINER_LOCALIZER_JAVA_OPTS_KEY =
1078      NM_PREFIX + "container-localizer.java.opts";
1079  public static final String NM_CONTAINER_LOCALIZER_JAVA_OPTS_DEFAULT =
1080      "-Xmx256m";
1081
1082  /** The Docker image name(For DockerContainerExecutor).*/
1083  public static final String NM_DOCKER_CONTAINER_EXECUTOR_IMAGE_NAME =
1084    NM_PREFIX + "docker-container-executor.image-name";
1085
1086  /** The name of the docker executor (For DockerContainerExecutor).*/
1087  public static final String NM_DOCKER_CONTAINER_EXECUTOR_EXEC_NAME =
1088    NM_PREFIX + "docker-container-executor.exec-name";
1089
1090  /** The default docker executor (For DockerContainerExecutor).*/
1091  public static final String NM_DEFAULT_DOCKER_CONTAINER_EXECUTOR_EXEC_NAME =
1092          "/usr/bin/docker";
1093
1094  /** The path to the Linux container executor.*/
1095  public static final String NM_LINUX_CONTAINER_EXECUTOR_PATH =
1096    NM_PREFIX + "linux-container-executor.path";
1097  
1098  /** 
1099   * The UNIX group that the linux-container-executor should run as.
1100   * This is intended to be set as part of container-executor.cfg. 
1101   */
1102  public static final String NM_LINUX_CONTAINER_GROUP =
1103    NM_PREFIX + "linux-container-executor.group";
1104
1105  /**
1106   * True if linux-container-executor should limit itself to one user
1107   * when running in non-secure mode.
1108   */
1109  public static final String NM_NONSECURE_MODE_LIMIT_USERS = NM_PREFIX +
1110     "linux-container-executor.nonsecure-mode.limit-users";
1111
1112  public static final boolean DEFAULT_NM_NONSECURE_MODE_LIMIT_USERS = true;
1113
1114  /**
1115   * The UNIX user that containers will run as when Linux-container-executor
1116   * is used in nonsecure mode (a use case for this is using cgroups).
1117   */
1118  public static final String NM_NONSECURE_MODE_LOCAL_USER_KEY = NM_PREFIX +
1119      "linux-container-executor.nonsecure-mode.local-user";
1120
1121  public static final String DEFAULT_NM_NONSECURE_MODE_LOCAL_USER = "nobody";
1122
1123  /**
1124   * The allowed pattern for UNIX user names enforced by 
1125   * Linux-container-executor when used in nonsecure mode (use case for this 
1126   * is using cgroups). The default value is taken from /usr/sbin/adduser
1127   */
1128  public static final String NM_NONSECURE_MODE_USER_PATTERN_KEY = NM_PREFIX +
1129      "linux-container-executor.nonsecure-mode.user-pattern";
1130
1131  public static final String DEFAULT_NM_NONSECURE_MODE_USER_PATTERN = 
1132      "^[_.A-Za-z0-9][-@_.A-Za-z0-9]{0,255}?[$]?$";
1133
1134  /** The type of resource enforcement to use with the
1135   *  linux container executor.
1136   */
1137  public static final String NM_LINUX_CONTAINER_RESOURCES_HANDLER = 
1138  NM_PREFIX + "linux-container-executor.resources-handler.class";
1139  
1140  /** The path the linux container executor should use for cgroups */
1141  public static final String NM_LINUX_CONTAINER_CGROUPS_HIERARCHY =
1142    NM_PREFIX + "linux-container-executor.cgroups.hierarchy";
1143  
1144  /** Whether the linux container executor should mount cgroups if not found */
1145  public static final String NM_LINUX_CONTAINER_CGROUPS_MOUNT =
1146    NM_PREFIX + "linux-container-executor.cgroups.mount";
1147  
1148  /** Where the linux container executor should mount cgroups if not found */
1149  public static final String NM_LINUX_CONTAINER_CGROUPS_MOUNT_PATH =
1150    NM_PREFIX + "linux-container-executor.cgroups.mount-path";
1151
1152  /**
1153   * Whether the apps should run in strict resource usage mode(not allowed to
1154   * use spare CPU)
1155   */
1156  public static final String NM_LINUX_CONTAINER_CGROUPS_STRICT_RESOURCE_USAGE =
1157      NM_PREFIX + "linux-container-executor.cgroups.strict-resource-usage";
1158  public static final boolean DEFAULT_NM_LINUX_CONTAINER_CGROUPS_STRICT_RESOURCE_USAGE =
1159      false;
1160
1161
1162
1163  /**
1164   * Interval of time the linux container executor should try cleaning up
1165   * cgroups entry when cleaning up a container. This is required due to what 
1166   * it seems a race condition because the SIGTERM/SIGKILL is asynch.
1167   */
1168  public static final String NM_LINUX_CONTAINER_CGROUPS_DELETE_TIMEOUT =
1169   NM_PREFIX + "linux-container-executor.cgroups.delete-timeout-ms";
1170
1171  public static final long DEFAULT_NM_LINUX_CONTAINER_CGROUPS_DELETE_TIMEOUT =
1172      1000;
1173
1174  /**
1175   * Delay between attempts to remove linux cgroup.
1176   */
1177  public static final String NM_LINUX_CONTAINER_CGROUPS_DELETE_DELAY =
1178      NM_PREFIX + "linux-container-executor.cgroups.delete-delay-ms";
1179
1180  public static final long DEFAULT_NM_LINUX_CONTAINER_CGROUPS_DELETE_DELAY =
1181      20;
1182
1183  /**
1184   * Indicates if memory and CPU limits will be set for the Windows Job
1185   * Object for the containers launched by the default container executor.
1186   */
1187  public static final String NM_WINDOWS_CONTAINER_MEMORY_LIMIT_ENABLED =
1188      NM_PREFIX + "windows-container.memory-limit.enabled";
1189  public static final boolean DEFAULT_NM_WINDOWS_CONTAINER_MEMORY_LIMIT_ENABLED = false;
1190
1191  public static final String NM_WINDOWS_CONTAINER_CPU_LIMIT_ENABLED =
1192      NM_PREFIX + "windows-container.cpu-limit.enabled";
1193  public static final boolean DEFAULT_NM_WINDOWS_CONTAINER_CPU_LIMIT_ENABLED = false;
1194
1195  /** 
1196  /* The Windows group that the windows-secure-container-executor should run as.
1197  */
1198  public static final String NM_WINDOWS_SECURE_CONTAINER_GROUP =
1199      NM_PREFIX + "windows-secure-container-executor.group";
1200
1201  /** T-file compression types used to compress aggregated logs.*/
1202  public static final String NM_LOG_AGG_COMPRESSION_TYPE = 
1203    NM_PREFIX + "log-aggregation.compression-type";
1204  public static final String DEFAULT_NM_LOG_AGG_COMPRESSION_TYPE = "none";
1205  
1206  /** The kerberos principal for the node manager.*/
1207  public static final String NM_PRINCIPAL =
1208    NM_PREFIX + "principal";
1209  
1210  public static final String NM_AUX_SERVICES = 
1211    NM_PREFIX + "aux-services";
1212  
1213  public static final String NM_AUX_SERVICE_FMT =
1214    NM_PREFIX + "aux-services.%s.class";
1215
1216  public static final String NM_USER_HOME_DIR =
1217      NM_PREFIX + "user-home-dir";
1218  
1219  /**The kerberos principal to be used for spnego filter for NM.*/
1220  public static final String NM_WEBAPP_SPNEGO_USER_NAME_KEY =
1221      NM_PREFIX + "webapp.spnego-principal";
1222  
1223  /**The kerberos keytab to be used for spnego filter for NM.*/
1224  public static final String NM_WEBAPP_SPNEGO_KEYTAB_FILE_KEY =
1225      NM_PREFIX + "webapp.spnego-keytab-file";
1226  
1227  public static final String DEFAULT_NM_USER_HOME_DIR= "/home/";
1228
1229  public static final String NM_RECOVERY_PREFIX = NM_PREFIX + "recovery.";
1230  public static final String NM_RECOVERY_ENABLED =
1231      NM_RECOVERY_PREFIX + "enabled";
1232  public static final boolean DEFAULT_NM_RECOVERY_ENABLED = false;
1233
1234  public static final String NM_RECOVERY_DIR = NM_RECOVERY_PREFIX + "dir";
1235
1236  public static final String NM_RECOVERY_SUPERVISED =
1237      NM_RECOVERY_PREFIX + "supervised";
1238  public static final boolean DEFAULT_NM_RECOVERY_SUPERVISED = false;
1239
1240  public static final String NM_LOG_AGG_POLICY_CLASS =
1241      NM_PREFIX + "log-aggregation.policy.class";
1242
1243  public static final String NM_LOG_AGG_POLICY_CLASS_PARAMETERS = NM_PREFIX
1244      + "log-aggregation.policy.parameters";
1245
1246  ////////////////////////////////
1247  // Web Proxy Configs
1248  ////////////////////////////////
1249  public static final String PROXY_PREFIX = "yarn.web-proxy.";
1250  
1251  /** The kerberos principal for the proxy.*/
1252  public static final String PROXY_PRINCIPAL =
1253    PROXY_PREFIX + "principal";
1254  
1255  /** Keytab for Proxy.*/
1256  public static final String PROXY_KEYTAB = PROXY_PREFIX + "keytab";
1257  
1258  /** The address for the web proxy.*/
1259  public static final String PROXY_ADDRESS =
1260    PROXY_PREFIX + "address";
1261  public static final int DEFAULT_PROXY_PORT = 9099;
1262  public static final String DEFAULT_PROXY_ADDRESS =
1263    "0.0.0.0:" + DEFAULT_PROXY_PORT;
1264  
1265  /**
1266   * YARN Service Level Authorization
1267   */
1268  public static final String 
1269  YARN_SECURITY_SERVICE_AUTHORIZATION_RESOURCETRACKER_PROTOCOL =
1270      "security.resourcetracker.protocol.acl";
1271  public static final String 
1272  YARN_SECURITY_SERVICE_AUTHORIZATION_APPLICATIONCLIENT_PROTOCOL =
1273      "security.applicationclient.protocol.acl";
1274  public static final String 
1275  YARN_SECURITY_SERVICE_AUTHORIZATION_RESOURCEMANAGER_ADMINISTRATION_PROTOCOL =
1276      "security.resourcemanager-administration.protocol.acl";
1277  public static final String 
1278  YARN_SECURITY_SERVICE_AUTHORIZATION_APPLICATIONMASTER_PROTOCOL =
1279      "security.applicationmaster.protocol.acl";
1280
1281  public static final String 
1282  YARN_SECURITY_SERVICE_AUTHORIZATION_CONTAINER_MANAGEMENT_PROTOCOL =
1283      "security.containermanagement.protocol.acl";
1284  public static final String 
1285  YARN_SECURITY_SERVICE_AUTHORIZATION_RESOURCE_LOCALIZER =
1286      "security.resourcelocalizer.protocol.acl";
1287
1288  public static final String
1289  YARN_SECURITY_SERVICE_AUTHORIZATION_APPLICATIONHISTORY_PROTOCOL =
1290      "security.applicationhistory.protocol.acl";
1291
1292  /** No. of milliseconds to wait between sending a SIGTERM and SIGKILL
1293   * to a running container */
1294  public static final String NM_SLEEP_DELAY_BEFORE_SIGKILL_MS =
1295      NM_PREFIX + "sleep-delay-before-sigkill.ms";
1296  public static final long DEFAULT_NM_SLEEP_DELAY_BEFORE_SIGKILL_MS =
1297      250;
1298
1299  /** Max time to wait for a process to come up when trying to cleanup
1300   * container resources */
1301  public static final String NM_PROCESS_KILL_WAIT_MS =
1302      NM_PREFIX + "process-kill-wait.ms";
1303  public static final long DEFAULT_NM_PROCESS_KILL_WAIT_MS =
1304      2000;
1305
1306  /** Max time to wait to establish a connection to RM */
1307  public static final String RESOURCEMANAGER_CONNECT_MAX_WAIT_MS =
1308      RM_PREFIX + "connect.max-wait.ms";
1309  public static final long DEFAULT_RESOURCEMANAGER_CONNECT_MAX_WAIT_MS =
1310      15 * 60 * 1000;
1311
1312  /** Time interval between each attempt to connect to RM */
1313  public static final String RESOURCEMANAGER_CONNECT_RETRY_INTERVAL_MS =
1314      RM_PREFIX + "connect.retry-interval.ms";
1315  public static final long DEFAULT_RESOURCEMANAGER_CONNECT_RETRY_INTERVAL_MS
1316      = 30 * 1000;
1317
1318  public static final String DISPATCHER_DRAIN_EVENTS_TIMEOUT =
1319      YARN_PREFIX + "dispatcher.drain-events.timeout";
1320
1321  public static final long DEFAULT_DISPATCHER_DRAIN_EVENTS_TIMEOUT = 300000;
1322
1323  /**
1324   * CLASSPATH for YARN applications. A comma-separated list of CLASSPATH
1325   * entries
1326   */
1327  public static final String YARN_APPLICATION_CLASSPATH = YARN_PREFIX
1328      + "application.classpath";
1329
1330  /**
1331   * Default platform-agnostic CLASSPATH for YARN applications. A
1332   * comma-separated list of CLASSPATH entries. The parameter expansion marker
1333   * will be replaced with real parameter expansion marker ('%' for Windows and
1334   * '$' for Linux) by NodeManager on container launch. For example: {{VAR}}
1335   * will be replaced as $VAR on Linux, and %VAR% on Windows.
1336   */
1337  @Public
1338  @Unstable
1339  public static final String[] DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH= {
1340      ApplicationConstants.Environment.HADOOP_CONF_DIR.$$(),
1341      ApplicationConstants.Environment.HADOOP_COMMON_HOME.$$()
1342          + "/share/hadoop/common/*",
1343      ApplicationConstants.Environment.HADOOP_COMMON_HOME.$$()
1344          + "/share/hadoop/common/lib/*",
1345      ApplicationConstants.Environment.HADOOP_HDFS_HOME.$$()
1346          + "/share/hadoop/hdfs/*",
1347      ApplicationConstants.Environment.HADOOP_HDFS_HOME.$$()
1348          + "/share/hadoop/hdfs/lib/*",
1349      ApplicationConstants.Environment.HADOOP_YARN_HOME.$$()
1350          + "/share/hadoop/yarn/*",
1351      ApplicationConstants.Environment.HADOOP_YARN_HOME.$$()
1352          + "/share/hadoop/yarn/lib/*" };
1353  /**
1354   * <p>
1355   * Default platform-specific CLASSPATH for YARN applications. A
1356   * comma-separated list of CLASSPATH entries constructed based on the client
1357   * OS environment expansion syntax.
1358   * </p>
1359   * <p>
1360   * Note: Use {@link #DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH} for
1361   * cross-platform practice i.e. submit an application from a Windows client to
1362   * a Linux/Unix server or vice versa.
1363   * </p>
1364   */
1365  public static final String[] DEFAULT_YARN_APPLICATION_CLASSPATH = {
1366      ApplicationConstants.Environment.HADOOP_CONF_DIR.$(),
1367      ApplicationConstants.Environment.HADOOP_COMMON_HOME.$()
1368          + "/share/hadoop/common/*",
1369      ApplicationConstants.Environment.HADOOP_COMMON_HOME.$()
1370          + "/share/hadoop/common/lib/*",
1371      ApplicationConstants.Environment.HADOOP_HDFS_HOME.$()
1372          + "/share/hadoop/hdfs/*",
1373      ApplicationConstants.Environment.HADOOP_HDFS_HOME.$()
1374          + "/share/hadoop/hdfs/lib/*",
1375      ApplicationConstants.Environment.HADOOP_YARN_HOME.$()
1376          + "/share/hadoop/yarn/*",
1377      ApplicationConstants.Environment.HADOOP_YARN_HOME.$()
1378          + "/share/hadoop/yarn/lib/*" };
1379
1380  /** Container temp directory */
1381  public static final String DEFAULT_CONTAINER_TEMP_DIR = "./tmp";
1382
1383  public static final String IS_MINI_YARN_CLUSTER = YARN_PREFIX
1384      + "is.minicluster";
1385
1386  public static final String YARN_MC_PREFIX = YARN_PREFIX + "minicluster.";
1387
1388  /** Whether to use fixed ports with the minicluster. */
1389  public static final String YARN_MINICLUSTER_FIXED_PORTS =
1390      YARN_MC_PREFIX + "fixed.ports";
1391
1392  /**
1393   * Default is false to be able to run tests concurrently without port
1394   * conflicts.
1395   */
1396  public static final boolean DEFAULT_YARN_MINICLUSTER_FIXED_PORTS = false;
1397
1398  /**
1399   * Whether the NM should use RPC to connect to the RM. Default is false.
1400   * Can be set to true only when using fixed ports.
1401   */
1402  public static final String YARN_MINICLUSTER_USE_RPC = YARN_MC_PREFIX + "use-rpc";
1403  public static final boolean DEFAULT_YARN_MINICLUSTER_USE_RPC = false;
1404
1405  /**
1406   * Whether users are explicitly trying to control resource monitoring
1407   * configuration for the MiniYARNCluster. Disabled by default.
1408   */
1409  public static final String YARN_MINICLUSTER_CONTROL_RESOURCE_MONITORING =
1410      YARN_MC_PREFIX + "control-resource-monitoring";
1411  public static final boolean
1412      DEFAULT_YARN_MINICLUSTER_CONTROL_RESOURCE_MONITORING = false;
1413
1414  /** Allow changing the memory for the NodeManager in the MiniYARNCluster */
1415  public static final String YARN_MINICLUSTER_NM_PMEM_MB =
1416      YARN_MC_PREFIX + YarnConfiguration.NM_PMEM_MB;
1417  public static final int DEFAULT_YARN_MINICLUSTER_NM_PMEM_MB = 4 * 1024;
1418
1419  /** The log directory for the containers */
1420  public static final String YARN_APP_CONTAINER_LOG_DIR =
1421      YARN_PREFIX + "app.container.log.dir";
1422
1423  public static final String YARN_APP_CONTAINER_LOG_SIZE =
1424      YARN_PREFIX + "app.container.log.filesize";
1425
1426  public static final String YARN_APP_CONTAINER_LOG_BACKUPS =
1427      YARN_PREFIX + "app.container.log.backups";
1428
1429  ////////////////////////////////
1430  // Timeline Service Configs
1431  ////////////////////////////////
1432
1433  public static final String TIMELINE_SERVICE_PREFIX =
1434      YARN_PREFIX + "timeline-service.";
1435
1436
1437  // mark app-history related configs @Private as application history is going
1438  // to be integrated into the timeline service
1439  @Private
1440  public static final String APPLICATION_HISTORY_PREFIX =
1441      TIMELINE_SERVICE_PREFIX + "generic-application-history.";
1442
1443  /**
1444   *  The setting that controls whether application history service is
1445   *  enabled or not.
1446   */
1447  @Private
1448  public static final String APPLICATION_HISTORY_ENABLED =
1449      APPLICATION_HISTORY_PREFIX + "enabled";
1450  @Private
1451  public static final boolean DEFAULT_APPLICATION_HISTORY_ENABLED = false;
1452
1453  /** Application history store class */
1454  @Private
1455  public static final String APPLICATION_HISTORY_STORE =
1456      APPLICATION_HISTORY_PREFIX + "store-class";
1457
1458  /** Save container meta-info in the application history store. */
1459  @Private
1460  public static final String
1461      APPLICATION_HISTORY_SAVE_NON_AM_CONTAINER_META_INFO =
1462        APPLICATION_HISTORY_PREFIX + "save-non-am-container-meta-info";
1463  @Private
1464  public static final boolean
1465            DEFAULT_APPLICATION_HISTORY_SAVE_NON_AM_CONTAINER_META_INFO = true;
1466
1467  /** URI for FileSystemApplicationHistoryStore */
1468  @Private
1469  public static final String FS_APPLICATION_HISTORY_STORE_URI =
1470      APPLICATION_HISTORY_PREFIX + "fs-history-store.uri";
1471
1472  /** T-file compression types used to compress history data.*/
1473  @Private
1474  public static final String FS_APPLICATION_HISTORY_STORE_COMPRESSION_TYPE =
1475      APPLICATION_HISTORY_PREFIX + "fs-history-store.compression-type";
1476  @Private
1477  public static final String DEFAULT_FS_APPLICATION_HISTORY_STORE_COMPRESSION_TYPE =
1478      "none";
1479
1480  /** The setting that controls whether timeline service is enabled or not. */
1481  public static final String TIMELINE_SERVICE_ENABLED =
1482      TIMELINE_SERVICE_PREFIX + "enabled";
1483  public static final boolean DEFAULT_TIMELINE_SERVICE_ENABLED = false;
1484
1485  /** host:port address for timeline service RPC APIs. */
1486  public static final String TIMELINE_SERVICE_ADDRESS =
1487      TIMELINE_SERVICE_PREFIX + "address";
1488  public static final int DEFAULT_TIMELINE_SERVICE_PORT = 10200;
1489  public static final String DEFAULT_TIMELINE_SERVICE_ADDRESS = "0.0.0.0:"
1490      + DEFAULT_TIMELINE_SERVICE_PORT;
1491
1492  /** The listening endpoint for the timeline service application.*/
1493  public static final String TIMELINE_SERVICE_BIND_HOST =
1494      TIMELINE_SERVICE_PREFIX + "bind-host";
1495
1496  /** The number of threads to handle client RPC API requests. */
1497  public static final String TIMELINE_SERVICE_HANDLER_THREAD_COUNT =
1498      TIMELINE_SERVICE_PREFIX + "handler-thread-count";
1499  public static final int DEFAULT_TIMELINE_SERVICE_CLIENT_THREAD_COUNT = 10;
1500  
1501
1502  /** The address of the timeline service web application.*/
1503  public static final String TIMELINE_SERVICE_WEBAPP_ADDRESS =
1504      TIMELINE_SERVICE_PREFIX  + "webapp.address";
1505
1506  public static final int DEFAULT_TIMELINE_SERVICE_WEBAPP_PORT = 8188;
1507  public static final String DEFAULT_TIMELINE_SERVICE_WEBAPP_ADDRESS =
1508      "0.0.0.0:" + DEFAULT_TIMELINE_SERVICE_WEBAPP_PORT;
1509
1510  /** The https address of the timeline service web application.*/
1511  public static final String TIMELINE_SERVICE_WEBAPP_HTTPS_ADDRESS =
1512      TIMELINE_SERVICE_PREFIX + "webapp.https.address";
1513
1514  public static final int DEFAULT_TIMELINE_SERVICE_WEBAPP_HTTPS_PORT = 8190;
1515  public static final String DEFAULT_TIMELINE_SERVICE_WEBAPP_HTTPS_ADDRESS =
1516      "0.0.0.0:" + DEFAULT_TIMELINE_SERVICE_WEBAPP_HTTPS_PORT;
1517
1518  /**
1519   * Defines the max number of applications could be fetched using
1520   * REST API or application history protocol and shown in timeline
1521   * server web ui.
1522   */
1523  public static final String APPLICATION_HISTORY_MAX_APPS =
1524      APPLICATION_HISTORY_PREFIX + "max-applications";
1525  public static final long DEFAULT_APPLICATION_HISTORY_MAX_APPS = 10000;
1526
1527  /** Timeline service store class */
1528  public static final String TIMELINE_SERVICE_STORE =
1529      TIMELINE_SERVICE_PREFIX + "store-class";
1530
1531  /** Timeline service enable data age off */
1532  public static final String TIMELINE_SERVICE_TTL_ENABLE =
1533      TIMELINE_SERVICE_PREFIX + "ttl-enable";
1534
1535  /** Timeline service length of time to retain data */
1536  public static final String TIMELINE_SERVICE_TTL_MS =
1537      TIMELINE_SERVICE_PREFIX + "ttl-ms";
1538
1539  public static final long DEFAULT_TIMELINE_SERVICE_TTL_MS =
1540      1000 * 60 * 60 * 24 * 7;
1541
1542  /** Timeline service rolling period. Valid values are daily, half_daily,
1543   * quarter_daily, and hourly. */
1544  public static final String TIMELINE_SERVICE_ROLLING_PERIOD =
1545      TIMELINE_SERVICE_PREFIX + "rolling-period";
1546
1547  /** Roll a new database each hour. */
1548  public static final String DEFAULT_TIMELINE_SERVICE_ROLLING_PERIOD =
1549      "hourly";
1550
1551  /** Implementation specific configuration prefix for Timeline Service
1552   * leveldb.
1553   */
1554  public static final String TIMELINE_SERVICE_LEVELDB_PREFIX =
1555      TIMELINE_SERVICE_PREFIX + "leveldb-timeline-store.";
1556
1557  /** Timeline service leveldb path */
1558  public static final String TIMELINE_SERVICE_LEVELDB_PATH =
1559      TIMELINE_SERVICE_LEVELDB_PREFIX + "path";
1560
1561  /** Timeline service leveldb read cache (uncompressed blocks). This is
1562   * per rolling instance so should be tuned if using rolling leveldb
1563   * timeline store */
1564  public static final String TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE =
1565      TIMELINE_SERVICE_LEVELDB_PREFIX + "read-cache-size";
1566
1567  /** Default leveldb read cache size if no configuration is specified. */
1568  public static final long DEFAULT_TIMELINE_SERVICE_LEVELDB_READ_CACHE_SIZE =
1569      100 * 1024 * 1024;
1570
1571  /** Timeline service leveldb write buffer size. */
1572  public static final String TIMELINE_SERVICE_LEVELDB_WRITE_BUFFER_SIZE =
1573      TIMELINE_SERVICE_LEVELDB_PREFIX + "write-buffer-size";
1574
1575  /** Default leveldb write buffer size if no configuration is specified. This
1576   * is per rolling instance so should be tuned if using rolling leveldb
1577   * timeline store. */
1578  public static final int DEFAULT_TIMELINE_SERVICE_LEVELDB_WRITE_BUFFER_SIZE =
1579      16 * 1024 * 1024;
1580
1581  /** Timeline service leveldb write batch size. This value can be tuned down
1582   * to reduce lock time for ttl eviction. */
1583  public static final String
1584      TIMELINE_SERVICE_LEVELDB_WRITE_BATCH_SIZE =
1585      TIMELINE_SERVICE_LEVELDB_PREFIX + "write-batch-size";
1586
1587  /** Default leveldb write batch size is no configuration is specified */
1588  public static final int
1589      DEFAULT_TIMELINE_SERVICE_LEVELDB_WRITE_BATCH_SIZE = 10000;
1590
1591  /** Timeline service leveldb start time read cache (number of entities) */
1592  public static final String
1593      TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE =
1594      TIMELINE_SERVICE_LEVELDB_PREFIX + "start-time-read-cache-size";
1595
1596  public static final int
1597      DEFAULT_TIMELINE_SERVICE_LEVELDB_START_TIME_READ_CACHE_SIZE = 10000;
1598
1599  /** Timeline service leveldb start time write cache (number of entities) */
1600  public static final String
1601      TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE =
1602      TIMELINE_SERVICE_LEVELDB_PREFIX + "start-time-write-cache-size";
1603
1604  public static final int
1605      DEFAULT_TIMELINE_SERVICE_LEVELDB_START_TIME_WRITE_CACHE_SIZE = 10000;
1606
1607  /** Timeline service leveldb interval to wait between deletion rounds */
1608  public static final String TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS =
1609      TIMELINE_SERVICE_LEVELDB_PREFIX + "ttl-interval-ms";
1610
1611  public static final long DEFAULT_TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS =
1612      1000 * 60 * 5;
1613
1614  /** Timeline service leveldb number of concurrent open files. Tuned this
1615   * configuration to stay within system limits. This is per rolling instance
1616   * so should be tuned if using rolling leveldb timeline store. */
1617  public static final String TIMELINE_SERVICE_LEVELDB_MAX_OPEN_FILES =
1618      TIMELINE_SERVICE_LEVELDB_PREFIX + "max-open-files";
1619
1620  /** Default leveldb max open files if no configuration is specified. */
1621  public static final int DEFAULT_TIMELINE_SERVICE_LEVELDB_MAX_OPEN_FILES =
1622      1000;
1623
1624  /** The Kerberos principal for the timeline server.*/
1625  public static final String TIMELINE_SERVICE_PRINCIPAL =
1626      TIMELINE_SERVICE_PREFIX + "principal";
1627
1628  /** The Kerberos keytab for the timeline server.*/
1629  public static final String TIMELINE_SERVICE_KEYTAB =
1630      TIMELINE_SERVICE_PREFIX + "keytab";
1631
1632  /** Enables cross origin support for timeline server.*/
1633  public static final String TIMELINE_SERVICE_HTTP_CROSS_ORIGIN_ENABLED =
1634      TIMELINE_SERVICE_PREFIX + "http-cross-origin.enabled";
1635
1636  /** Default value for cross origin support for timeline server.*/
1637  public static final boolean
1638      TIMELINE_SERVICE_HTTP_CROSS_ORIGIN_ENABLED_DEFAULT = false;
1639
1640  /** Timeline client settings */
1641  public static final String TIMELINE_SERVICE_CLIENT_PREFIX =
1642      TIMELINE_SERVICE_PREFIX + "client.";
1643
1644  /** Timeline client call, max retries (-1 means no limit) */
1645  public static final String TIMELINE_SERVICE_CLIENT_MAX_RETRIES =
1646      TIMELINE_SERVICE_CLIENT_PREFIX + "max-retries";
1647
1648  public static final int DEFAULT_TIMELINE_SERVICE_CLIENT_MAX_RETRIES = 30;
1649
1650  /** Timeline client call, retry interval */
1651  public static final String TIMELINE_SERVICE_CLIENT_RETRY_INTERVAL_MS =
1652      TIMELINE_SERVICE_CLIENT_PREFIX + "retry-interval-ms";
1653
1654  public static final long
1655      DEFAULT_TIMELINE_SERVICE_CLIENT_RETRY_INTERVAL_MS = 1000;
1656
1657  /** Timeline client policy for whether connections are fatal */
1658  public static final String TIMELINE_SERVICE_CLIENT_BEST_EFFORT =
1659      TIMELINE_SERVICE_CLIENT_PREFIX + "best-effort";
1660
1661  public static final boolean
1662      DEFAULT_TIMELINE_SERVICE_CLIENT_BEST_EFFORT = false;
1663
1664  /** Flag to enable recovery of timeline service */
1665  public static final String TIMELINE_SERVICE_RECOVERY_ENABLED =
1666      TIMELINE_SERVICE_PREFIX + "recovery.enabled";
1667  public static final boolean DEFAULT_TIMELINE_SERVICE_RECOVERY_ENABLED = false;
1668
1669  /** Timeline service state store class */
1670  public static final String TIMELINE_SERVICE_STATE_STORE_CLASS =
1671      TIMELINE_SERVICE_PREFIX + "state-store-class";
1672
1673  public static final String TIMELINE_SERVICE_LEVELDB_STATE_STORE_PREFIX =
1674      TIMELINE_SERVICE_PREFIX + "leveldb-state-store.";
1675
1676  /** Timeline service state store leveldb path */
1677  public static final String TIMELINE_SERVICE_LEVELDB_STATE_STORE_PATH =
1678      TIMELINE_SERVICE_LEVELDB_STATE_STORE_PREFIX + "path";
1679
1680  // Timeline delegation token related keys
1681  public static final String  TIMELINE_DELEGATION_KEY_UPDATE_INTERVAL =
1682      TIMELINE_SERVICE_PREFIX + "delegation.key.update-interval";
1683  public static final long    DEFAULT_TIMELINE_DELEGATION_KEY_UPDATE_INTERVAL =
1684      24*60*60*1000; // 1 day
1685  public static final String  TIMELINE_DELEGATION_TOKEN_RENEW_INTERVAL =
1686      TIMELINE_SERVICE_PREFIX + "delegation.token.renew-interval";
1687  public static final long    DEFAULT_TIMELINE_DELEGATION_TOKEN_RENEW_INTERVAL =
1688      24*60*60*1000;  // 1 day
1689  public static final String  TIMELINE_DELEGATION_TOKEN_MAX_LIFETIME =
1690      TIMELINE_SERVICE_PREFIX + "delegation.token.max-lifetime";
1691  public static final long    DEFAULT_TIMELINE_DELEGATION_TOKEN_MAX_LIFETIME =
1692      7*24*60*60*1000; // 7 days
1693
1694  // ///////////////////////////////
1695  // Shared Cache Configs
1696  // ///////////////////////////////
1697  public static final String SHARED_CACHE_PREFIX = "yarn.sharedcache.";
1698
1699  // common configs
1700  /** whether the shared cache is enabled/disabled */
1701  public static final String SHARED_CACHE_ENABLED =
1702      SHARED_CACHE_PREFIX + "enabled";
1703  public static final boolean DEFAULT_SHARED_CACHE_ENABLED = false;
1704
1705  /** The config key for the shared cache root directory. */
1706  public static final String SHARED_CACHE_ROOT =
1707      SHARED_CACHE_PREFIX + "root-dir";
1708  public static final String DEFAULT_SHARED_CACHE_ROOT = "/sharedcache";
1709
1710  /** The config key for the level of nested directories before getting to the
1711   * checksum directory. */
1712  public static final String SHARED_CACHE_NESTED_LEVEL =
1713      SHARED_CACHE_PREFIX + "nested-level";
1714  public static final int DEFAULT_SHARED_CACHE_NESTED_LEVEL = 3;
1715  
1716  // Shared Cache Manager Configs
1717
1718  public static final String SCM_STORE_PREFIX = SHARED_CACHE_PREFIX + "store.";
1719
1720  public static final String SCM_STORE_CLASS = SCM_STORE_PREFIX + "class";
1721  public static final String DEFAULT_SCM_STORE_CLASS =
1722      "org.apache.hadoop.yarn.server.sharedcachemanager.store.InMemorySCMStore";
1723
1724  public static final String SCM_APP_CHECKER_CLASS = SHARED_CACHE_PREFIX
1725      + "app-checker.class";
1726  public static final String DEFAULT_SCM_APP_CHECKER_CLASS =
1727      "org.apache.hadoop.yarn.server.sharedcachemanager.RemoteAppChecker";
1728
1729  /** The address of the SCM admin interface. */
1730  public static final String SCM_ADMIN_ADDRESS =
1731      SHARED_CACHE_PREFIX + "admin.address";
1732  public static final int DEFAULT_SCM_ADMIN_PORT = 8047;
1733  public static final String DEFAULT_SCM_ADMIN_ADDRESS =
1734      "0.0.0.0:" + DEFAULT_SCM_ADMIN_PORT;
1735
1736  /** Number of threads used to handle SCM admin interface. */
1737  public static final String SCM_ADMIN_CLIENT_THREAD_COUNT =
1738      SHARED_CACHE_PREFIX + "admin.thread-count";
1739  public static final int DEFAULT_SCM_ADMIN_CLIENT_THREAD_COUNT = 1;
1740
1741  /** The address of the SCM web application. */
1742  public static final String SCM_WEBAPP_ADDRESS =
1743      SHARED_CACHE_PREFIX + "webapp.address";
1744  public static final int DEFAULT_SCM_WEBAPP_PORT = 8788;
1745  public static final String DEFAULT_SCM_WEBAPP_ADDRESS =
1746      "0.0.0.0:" + DEFAULT_SCM_WEBAPP_PORT;
1747
1748  // In-memory SCM store configuration
1749  
1750  public static final String IN_MEMORY_STORE_PREFIX =
1751      SCM_STORE_PREFIX + "in-memory.";
1752
1753  /**
1754   * A resource in the InMemorySCMStore is considered stale if the time since
1755   * the last reference exceeds the staleness period. This value is specified in
1756   * minutes.
1757   */
1758  public static final String IN_MEMORY_STALENESS_PERIOD_MINS =
1759      IN_MEMORY_STORE_PREFIX + "staleness-period-mins";
1760  public static final int DEFAULT_IN_MEMORY_STALENESS_PERIOD_MINS =
1761      7 * 24 * 60;
1762
1763  /**
1764   * Initial delay before the in-memory store runs its first check to remove
1765   * dead initial applications. Specified in minutes.
1766   */
1767  public static final String IN_MEMORY_INITIAL_DELAY_MINS =
1768      IN_MEMORY_STORE_PREFIX + "initial-delay-mins";
1769  public static final int DEFAULT_IN_MEMORY_INITIAL_DELAY_MINS = 10;
1770  
1771  /**
1772   * The frequency at which the in-memory store checks to remove dead initial
1773   * applications. Specified in minutes.
1774   */
1775  public static final String IN_MEMORY_CHECK_PERIOD_MINS =
1776      IN_MEMORY_STORE_PREFIX + "check-period-mins";
1777  public static final int DEFAULT_IN_MEMORY_CHECK_PERIOD_MINS = 12 * 60;
1778
1779  // SCM Cleaner service configuration
1780
1781  private static final String SCM_CLEANER_PREFIX = SHARED_CACHE_PREFIX
1782      + "cleaner.";
1783
1784  /**
1785   * The frequency at which a cleaner task runs. Specified in minutes.
1786   */
1787  public static final String SCM_CLEANER_PERIOD_MINS =
1788      SCM_CLEANER_PREFIX + "period-mins";
1789  public static final int DEFAULT_SCM_CLEANER_PERIOD_MINS = 24 * 60;
1790
1791  /**
1792   * Initial delay before the first cleaner task is scheduled. Specified in
1793   * minutes.
1794   */
1795  public static final String SCM_CLEANER_INITIAL_DELAY_MINS =
1796      SCM_CLEANER_PREFIX + "initial-delay-mins";
1797  public static final int DEFAULT_SCM_CLEANER_INITIAL_DELAY_MINS = 10;
1798
1799  /**
1800   * The time to sleep between processing each shared cache resource. Specified
1801   * in milliseconds.
1802   */
1803  public static final String SCM_CLEANER_RESOURCE_SLEEP_MS =
1804      SCM_CLEANER_PREFIX + "resource-sleep-ms";
1805  public static final long DEFAULT_SCM_CLEANER_RESOURCE_SLEEP_MS = 0L;
1806
1807  /** The address of the node manager interface in the SCM. */
1808  public static final String SCM_UPLOADER_SERVER_ADDRESS = SHARED_CACHE_PREFIX
1809      + "uploader.server.address";
1810  public static final int DEFAULT_SCM_UPLOADER_SERVER_PORT = 8046;
1811  public static final String DEFAULT_SCM_UPLOADER_SERVER_ADDRESS = "0.0.0.0:"
1812      + DEFAULT_SCM_UPLOADER_SERVER_PORT;
1813
1814  /**
1815   * The number of SCM threads used to handle notify requests from the node
1816   * manager.
1817   */
1818  public static final String SCM_UPLOADER_SERVER_THREAD_COUNT =
1819      SHARED_CACHE_PREFIX + "uploader.server.thread-count";
1820  public static final int DEFAULT_SCM_UPLOADER_SERVER_THREAD_COUNT = 50;
1821
1822  /** The address of the client interface in the SCM. */
1823  public static final String SCM_CLIENT_SERVER_ADDRESS =
1824      SHARED_CACHE_PREFIX + "client-server.address";
1825  public static final int DEFAULT_SCM_CLIENT_SERVER_PORT = 8045;
1826  public static final String DEFAULT_SCM_CLIENT_SERVER_ADDRESS = "0.0.0.0:"
1827      + DEFAULT_SCM_CLIENT_SERVER_PORT;
1828
1829  /** The number of threads used to handle shared cache manager requests. */
1830  public static final String SCM_CLIENT_SERVER_THREAD_COUNT =
1831      SHARED_CACHE_PREFIX + "client-server.thread-count";
1832  public static final int DEFAULT_SCM_CLIENT_SERVER_THREAD_COUNT = 50;
1833
1834  /** the checksum algorithm implementation **/
1835  public static final String SHARED_CACHE_CHECKSUM_ALGO_IMPL =
1836      SHARED_CACHE_PREFIX + "checksum.algo.impl";
1837  public static final String DEFAULT_SHARED_CACHE_CHECKSUM_ALGO_IMPL =
1838      "org.apache.hadoop.yarn.sharedcache.ChecksumSHA256Impl";
1839
1840  // node manager (uploader) configs
1841  /**
1842   * The replication factor for the node manager uploader for the shared cache.
1843   */
1844  public static final String SHARED_CACHE_NM_UPLOADER_REPLICATION_FACTOR =
1845      SHARED_CACHE_PREFIX + "nm.uploader.replication.factor";
1846  public static final int DEFAULT_SHARED_CACHE_NM_UPLOADER_REPLICATION_FACTOR =
1847      10;
1848
1849  public static final String SHARED_CACHE_NM_UPLOADER_THREAD_COUNT =
1850      SHARED_CACHE_PREFIX + "nm.uploader.thread-count";
1851  public static final int DEFAULT_SHARED_CACHE_NM_UPLOADER_THREAD_COUNT = 20;
1852
1853  ////////////////////////////////
1854  // Other Configs
1855  ////////////////////////////////
1856
1857  /**
1858   * Use YARN_CLIENT_APPLICATION_CLIENT_PROTOCOL_POLL_INTERVAL_MS instead.
1859   * The interval of the yarn client's querying application state after
1860   * application submission. The unit is millisecond.
1861   */
1862  @Deprecated
1863  public static final String YARN_CLIENT_APP_SUBMISSION_POLL_INTERVAL_MS =
1864      YARN_PREFIX + "client.app-submission.poll-interval";
1865
1866  /**
1867   * The interval that the yarn client library uses to poll the completion
1868   * status of the asynchronous API of application client protocol.
1869   */
1870  public static final String YARN_CLIENT_APPLICATION_CLIENT_PROTOCOL_POLL_INTERVAL_MS =
1871      YARN_PREFIX + "client.application-client-protocol.poll-interval-ms";
1872  public static final long DEFAULT_YARN_CLIENT_APPLICATION_CLIENT_PROTOCOL_POLL_INTERVAL_MS =
1873      200;
1874
1875  /**
1876   * The duration that the yarn client library waits, cumulatively across polls,
1877   * for an expected state change to occur. Defaults to -1, which indicates no
1878   * limit.
1879   */
1880  public static final String YARN_CLIENT_APPLICATION_CLIENT_PROTOCOL_POLL_TIMEOUT_MS =
1881      YARN_PREFIX + "client.application-client-protocol.poll-timeout-ms";
1882  public static final long DEFAULT_YARN_CLIENT_APPLICATION_CLIENT_PROTOCOL_POLL_TIMEOUT_MS =
1883      -1;
1884
1885  /**
1886   * Max number of threads in NMClientAsync to process container management
1887   * events
1888   */
1889  public static final String NM_CLIENT_ASYNC_THREAD_POOL_MAX_SIZE =
1890      YARN_PREFIX + "client.nodemanager-client-async.thread-pool-max-size";
1891  public static final int DEFAULT_NM_CLIENT_ASYNC_THREAD_POOL_MAX_SIZE = 500;
1892
1893  /**
1894   * Maximum number of proxy connections to cache for node managers. If set
1895   * to a value greater than zero then the cache is enabled and the NMClient
1896   * and MRAppMaster will cache the specified number of node manager proxies.
1897   * There will be at max one proxy per node manager. Ex. configuring it to a
1898   * value of 5 will make sure that client will at max have 5 proxies cached
1899   * with 5 different node managers. These connections for these proxies will
1900   * be timed out if idle for more than the system wide idle timeout period.
1901   * Note that this could cause issues on large clusters as many connections
1902   * could linger simultaneously and lead to a large number of connection
1903   * threads. The token used for authentication will be used only at
1904   * connection creation time. If a new token is received then the earlier
1905   * connection should be closed in order to use the new token. This and
1906   * {@link YarnConfiguration#NM_CLIENT_ASYNC_THREAD_POOL_MAX_SIZE} are related
1907   * and should be in sync (no need for them to be equal).
1908   * If the value of this property is zero then the connection cache is
1909   * disabled and connections will use a zero idle timeout to prevent too
1910   * many connection threads on large clusters.
1911   */
1912  public static final String NM_CLIENT_MAX_NM_PROXIES =
1913      YARN_PREFIX + "client.max-cached-nodemanagers-proxies";
1914  public static final int DEFAULT_NM_CLIENT_MAX_NM_PROXIES = 0;
1915
1916  /** Max time to wait to establish a connection to NM */
1917  public static final String CLIENT_NM_CONNECT_MAX_WAIT_MS =
1918      YARN_PREFIX + "client.nodemanager-connect.max-wait-ms";
1919  public static final long DEFAULT_CLIENT_NM_CONNECT_MAX_WAIT_MS =
1920      3 * 60 * 1000;
1921
1922  /** Time interval between each attempt to connect to NM */
1923  public static final String CLIENT_NM_CONNECT_RETRY_INTERVAL_MS =
1924      YARN_PREFIX + "client.nodemanager-connect.retry-interval-ms";
1925  public static final long DEFAULT_CLIENT_NM_CONNECT_RETRY_INTERVAL_MS
1926      = 10 * 1000;
1927
1928  public static final String YARN_HTTP_POLICY_KEY = YARN_PREFIX + "http.policy";
1929  public static final String YARN_HTTP_POLICY_DEFAULT = HttpConfig.Policy.HTTP_ONLY
1930      .name();
1931  
1932  /**
1933   * Node-labels configurations
1934   */
1935  public static final String NODE_LABELS_PREFIX = YARN_PREFIX + "node-labels.";
1936  
1937  /** URI for NodeLabelManager */
1938  public static final String FS_NODE_LABELS_STORE_ROOT_DIR = NODE_LABELS_PREFIX
1939      + "fs-store.root-dir";
1940  public static final String FS_NODE_LABELS_STORE_RETRY_POLICY_SPEC =
1941      NODE_LABELS_PREFIX + "fs-store.retry-policy-spec";
1942  public static final String DEFAULT_FS_NODE_LABELS_STORE_RETRY_POLICY_SPEC =
1943      "2000, 500";
1944  
1945  /**
1946   * Flag to indicate if the node labels feature enabled, by default it's
1947   * disabled
1948   */
1949  public static final String NODE_LABELS_ENABLED = NODE_LABELS_PREFIX
1950      + "enabled";
1951  public static final boolean DEFAULT_NODE_LABELS_ENABLED = false;
1952  
1953  public static final String NODELABEL_CONFIGURATION_TYPE =
1954      NODE_LABELS_PREFIX + "configuration-type";
1955  
1956  public static final String CENTALIZED_NODELABEL_CONFIGURATION_TYPE =
1957      "centralized";
1958  
1959  public static final String DISTRIBUTED_NODELABEL_CONFIGURATION_TYPE =
1960      "distributed";
1961  
1962  public static final String DEFAULT_NODELABEL_CONFIGURATION_TYPE =
1963      CENTALIZED_NODELABEL_CONFIGURATION_TYPE;
1964
1965  public static final String MAX_CLUSTER_LEVEL_APPLICATION_PRIORITY =
1966      YARN_PREFIX + "cluster.max-application-priority";
1967
1968  public static final int DEFAULT_CLUSTER_LEVEL_APPLICATION_PRIORITY = 0;
1969
1970  @Private
1971  public static boolean isDistributedNodeLabelConfiguration(Configuration conf) {
1972    return DISTRIBUTED_NODELABEL_CONFIGURATION_TYPE.equals(conf.get(
1973        NODELABEL_CONFIGURATION_TYPE, DEFAULT_NODELABEL_CONFIGURATION_TYPE));
1974  }
1975
1976  private static final String NM_NODE_LABELS_PREFIX = NM_PREFIX
1977      + "node-labels.";
1978
1979  public static final String NM_NODE_LABELS_PROVIDER_CONFIG =
1980      NM_NODE_LABELS_PREFIX + "provider";
1981
1982  // whitelist names for the yarn.nodemanager.node-labels.provider
1983  public static final String CONFIG_NODE_LABELS_PROVIDER = "config";
1984
1985  private static final String NM_NODE_LABELS_PROVIDER_PREFIX =
1986      NM_NODE_LABELS_PREFIX + "provider.";
1987
1988  // If -1 is configured then no timer task should be created
1989  public static final String NM_NODE_LABELS_PROVIDER_FETCH_INTERVAL_MS =
1990      NM_NODE_LABELS_PROVIDER_PREFIX + "fetch-interval-ms";
1991
1992  public static final String NM_NODE_LABELS_PROVIDER_FETCH_TIMEOUT_MS =
1993      NM_NODE_LABELS_PROVIDER_PREFIX + "fetch-timeout-ms";
1994
1995  // once in 10 mins
1996  public static final long DEFAULT_NM_NODE_LABELS_PROVIDER_FETCH_INTERVAL_MS =
1997      10 * 60 * 1000;
1998
1999  // Twice of default interval time
2000  public static final long DEFAULT_NM_NODE_LABELS_PROVIDER_FETCH_TIMEOUT_MS =
2001      DEFAULT_NM_NODE_LABELS_PROVIDER_FETCH_INTERVAL_MS * 2;
2002
2003  public static final String NM_PROVIDER_CONFIGURED_NODE_LABELS =
2004      NM_NODE_LABELS_PROVIDER_PREFIX + "configured-node-labels";
2005
2006  public YarnConfiguration() {
2007    super();
2008  }
2009  
2010  public YarnConfiguration(Configuration conf) {
2011    super(conf);
2012    if (! (conf instanceof YarnConfiguration)) {
2013      this.reloadConfiguration();
2014    }
2015  }
2016
2017  @Private
2018  public static List<String> getServiceAddressConfKeys(Configuration conf) {
2019    return useHttps(conf) ? RM_SERVICES_ADDRESS_CONF_KEYS_HTTPS
2020        : RM_SERVICES_ADDRESS_CONF_KEYS_HTTP;
2021  }
2022
2023  /**
2024   * Get the socket address for <code>name</code> property as a
2025   * <code>InetSocketAddress</code>. On a HA cluster,
2026   * this fetches the address corresponding to the RM identified by
2027   * {@link #RM_HA_ID}.
2028   * @param name property name.
2029   * @param defaultAddress the default value
2030   * @param defaultPort the default port
2031   * @return InetSocketAddress
2032   */
2033  @Override
2034  public InetSocketAddress getSocketAddr(
2035      String name, String defaultAddress, int defaultPort) {
2036    String address;
2037    if (HAUtil.isHAEnabled(this) && getServiceAddressConfKeys(this).contains(name)) {
2038      address = HAUtil.getConfValueForRMInstance(name, defaultAddress, this);
2039    } else {
2040      address = get(name, defaultAddress);
2041    }
2042    return NetUtils.createSocketAddr(address, defaultPort, name);
2043  }
2044
2045  @Override
2046  public InetSocketAddress updateConnectAddr(String name,
2047                                             InetSocketAddress addr) {
2048    String prefix = name;
2049    if (HAUtil.isHAEnabled(this) && getServiceAddressConfKeys(this).contains(name)) {
2050      prefix = HAUtil.addSuffix(prefix, HAUtil.getRMHAId(this));
2051    }
2052    return super.updateConnectAddr(prefix, addr);
2053  }
2054
2055  @Private
2056  public static int getRMDefaultPortNumber(String addressPrefix,
2057      Configuration conf) {
2058    if (addressPrefix.equals(YarnConfiguration.RM_ADDRESS)) {
2059      return YarnConfiguration.DEFAULT_RM_PORT;
2060    } else if (addressPrefix.equals(YarnConfiguration.RM_SCHEDULER_ADDRESS)) {
2061      return YarnConfiguration.DEFAULT_RM_SCHEDULER_PORT;
2062    } else if (addressPrefix.equals(YarnConfiguration.RM_WEBAPP_ADDRESS)) {
2063      return YarnConfiguration.DEFAULT_RM_WEBAPP_PORT;
2064    } else if (addressPrefix.equals(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS)) {
2065      return YarnConfiguration.DEFAULT_RM_WEBAPP_HTTPS_PORT;
2066    } else if (addressPrefix
2067        .equals(YarnConfiguration.RM_RESOURCE_TRACKER_ADDRESS)) {
2068      return YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_PORT;
2069    } else if (addressPrefix.equals(YarnConfiguration.RM_ADMIN_ADDRESS)) {
2070      return YarnConfiguration.DEFAULT_RM_ADMIN_PORT;
2071    } else {
2072      throw new HadoopIllegalArgumentException(
2073          "Invalid RM RPC address Prefix: " + addressPrefix
2074              + ". The valid value should be one of "
2075              + getServiceAddressConfKeys(conf));
2076    }
2077  }
2078
2079  public static boolean useHttps(Configuration conf) {
2080    return HttpConfig.Policy.HTTPS_ONLY == HttpConfig.Policy.fromString(conf
2081        .get(YARN_HTTP_POLICY_KEY,
2082            YARN_HTTP_POLICY_DEFAULT));
2083  }
2084
2085  public static boolean shouldRMFailFast(Configuration conf) {
2086    return conf.getBoolean(YarnConfiguration.RM_FAIL_FAST,
2087        conf.getBoolean(YarnConfiguration.YARN_FAIL_FAST,
2088            YarnConfiguration.DEFAULT_YARN_FAIL_FAST));
2089  }
2090
2091  @Private
2092  public static String getClusterId(Configuration conf) {
2093    String clusterId = conf.get(YarnConfiguration.RM_CLUSTER_ID);
2094    if (clusterId == null) {
2095      throw new HadoopIllegalArgumentException("Configuration doesn't specify " +
2096          YarnConfiguration.RM_CLUSTER_ID);
2097    }
2098    return clusterId;
2099  }
2100
2101  /* For debugging. mp configurations to system output as XML format. */
2102  public static void main(String[] args) throws Exception {
2103    new YarnConfiguration(new Configuration()).writeXml(System.out);
2104  }
2105}