This project has retired. For details please refer to its Attic page.
Source code
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,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.reef.runtime.yarn.client;
020
021import org.apache.reef.annotations.audience.ClientSide;
022import org.apache.reef.annotations.audience.Public;
023import org.apache.reef.client.parameters.DriverConfigurationProviders;
024import org.apache.reef.driver.parameters.DriverIsUnmanaged;
025import org.apache.reef.runtime.common.UserCredentials;
026import org.apache.reef.runtime.common.client.CommonRuntimeConfiguration;
027import org.apache.reef.runtime.common.client.DriverConfigurationProvider;
028import org.apache.reef.runtime.common.client.api.JobSubmissionHandler;
029import org.apache.reef.runtime.common.files.RuntimeClasspathProvider;
030import org.apache.reef.runtime.common.parameters.JVMHeapSlack;
031import org.apache.reef.runtime.yarn.YarnClasspathProvider;
032import org.apache.reef.runtime.yarn.client.parameters.JobPriority;
033import org.apache.reef.runtime.yarn.client.parameters.JobQueue;
034import org.apache.reef.runtime.yarn.client.unmanaged.YarnProxyUser;
035import org.apache.reef.runtime.yarn.util.YarnConfigurationConstructor;
036import org.apache.reef.tang.ConfigurationProvider;
037import org.apache.reef.tang.formats.*;
038import org.apache.reef.util.logging.LoggingSetup;
039
040/**
041 * A ConfigurationModule for the YARN resource manager.
042 */
043@Public
044@ClientSide
045public class YarnClientConfiguration extends ConfigurationModuleBuilder {
046
047  static {
048    LoggingSetup.setupCommonsLogging();
049  }
050
051  public static final OptionalParameter<String> YARN_QUEUE_NAME = new OptionalParameter<>();
052  public static final OptionalParameter<Integer> YARN_PRIORITY = new OptionalParameter<>();
053  public static final OptionalParameter<Double> JVM_HEAP_SLACK = new OptionalParameter<>();
054  public static final OptionalParameter<Boolean> UNMANAGED_DRIVER = new OptionalParameter<>();
055
056  /**
057   * Configuration provides whose Configuration will be merged into all Driver Configuration.
058   */
059  public static final OptionalImpl<ConfigurationProvider> DRIVER_CONFIGURATION_PROVIDERS = new OptionalImpl<>();
060
061  public static final ConfigurationModule CONF = new YarnClientConfiguration()
062          .merge(CommonRuntimeConfiguration.CONF)
063          // Bind YARN-specific classes
064          .bindImplementation(JobSubmissionHandler.class, YarnJobSubmissionHandler.class)
065          .bindImplementation(DriverConfigurationProvider.class, YarnDriverConfigurationProviderImpl.class)
066          .bindImplementation(RuntimeClasspathProvider.class, YarnClasspathProvider.class)
067          .bindImplementation(UserCredentials.class, YarnProxyUser.class)
068          // Bind the parameters given by the user
069          .bindNamedParameter(JobQueue.class, YARN_QUEUE_NAME)
070          .bindNamedParameter(JobPriority.class, YARN_PRIORITY)
071          .bindNamedParameter(JVMHeapSlack.class, JVM_HEAP_SLACK)
072          .bindNamedParameter(DriverIsUnmanaged.class, UNMANAGED_DRIVER)
073          // Bind external constructors. Taken from  YarnExternalConstructors.registerClientConstructors
074          .bindConstructor(org.apache.hadoop.yarn.conf.YarnConfiguration.class, YarnConfigurationConstructor.class)
075          .bindSetEntry(DriverConfigurationProviders.class, DRIVER_CONFIGURATION_PROVIDERS)
076          .build();
077}