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.unmanaged;
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.yarn.YarnClasspathProvider;
031import org.apache.reef.runtime.yarn.client.YarnDriverConfigurationProviderImpl;
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.parameters.RootFolder;
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 UnmanagedAmYarnClientConfiguration 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<String> ROOT_FOLDER = new OptionalParameter<>();
054
055  /** Configuration provides whose Configuration will be merged into all Driver Configuration. */
056  public static final OptionalImpl<ConfigurationProvider> DRIVER_CONFIGURATION_PROVIDERS = new OptionalImpl<>();
057
058  public static final ConfigurationModule CONF = new UnmanagedAmYarnClientConfiguration()
059      .merge(CommonRuntimeConfiguration.CONF)
060      .bindNamedParameter(DriverIsUnmanaged.class, "true")
061      // Bind YARN
062      .bindImplementation(JobSubmissionHandler.class, UnmanagedAmYarnJobSubmissionHandler.class)
063      .bindImplementation(DriverConfigurationProvider.class, YarnDriverConfigurationProviderImpl.class)
064      .bindImplementation(RuntimeClasspathProvider.class, YarnClasspathProvider.class)
065      .bindImplementation(UserCredentials.class, YarnProxyUser.class)
066      // Bind the parameters given by the user
067      .bindNamedParameter(JobQueue.class, YARN_QUEUE_NAME)
068      .bindNamedParameter(JobPriority.class, YARN_PRIORITY)
069      .bindNamedParameter(RootFolder.class, ROOT_FOLDER)
070      // Bind external constructors. Taken from  YarnExternalConstructors.registerClientConstructors
071      .bindConstructor(org.apache.hadoop.yarn.conf.YarnConfiguration.class, YarnConfigurationConstructor.class)
072      .bindSetEntry(DriverConfigurationProviders.class, DRIVER_CONFIGURATION_PROVIDERS)
073      .build();
074}