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.runtime.common.client.CommonRuntimeConfiguration; 025import org.apache.reef.runtime.common.client.DriverConfigurationProvider; 026import org.apache.reef.runtime.common.client.api.JobSubmissionHandler; 027import org.apache.reef.runtime.common.files.RuntimeClasspathProvider; 028import org.apache.reef.runtime.common.parameters.JVMHeapSlack; 029import org.apache.reef.runtime.yarn.YarnClasspathProvider; 030import org.apache.reef.runtime.yarn.client.parameters.JobPriority; 031import org.apache.reef.runtime.yarn.client.parameters.JobQueue; 032import org.apache.reef.runtime.yarn.util.YarnConfigurationConstructor; 033import org.apache.reef.tang.ConfigurationProvider; 034import org.apache.reef.tang.formats.*; 035import org.apache.reef.util.logging.LoggingSetup; 036 037/** 038 * A ConfigurationModule for the YARN resourcemanager. 039 */ 040@Public 041@ClientSide 042public class YarnClientConfiguration extends ConfigurationModuleBuilder { 043 static { 044 LoggingSetup.setupCommonsLogging(); 045 } 046 047 public static final OptionalParameter<String> YARN_QUEUE_NAME = new OptionalParameter<>(); 048 public static final OptionalParameter<Integer> YARN_PRIORITY = new OptionalParameter<>(); 049 050 public static final OptionalParameter<Double> JVM_HEAP_SLACK = new OptionalParameter<>(); 051 052 /** 053 * Configuration provides whose Configuration will be merged into all Driver Configuration. 054 */ 055 public static final OptionalImpl<ConfigurationProvider> DRIVER_CONFIGURATION_PROVIDERS = new OptionalImpl<>(); 056 057 public static final ConfigurationModule CONF = new YarnClientConfiguration() 058 .merge(CommonRuntimeConfiguration.CONF) 059 // Bind YARN 060 .bindImplementation(JobSubmissionHandler.class, YarnJobSubmissionHandler.class) 061 .bindImplementation(DriverConfigurationProvider.class, YarnDriverConfigurationProviderImpl.class) 062 // Bind the parameters given by the user 063 .bindNamedParameter(JobQueue.class, YARN_QUEUE_NAME) 064 .bindNamedParameter(JobPriority.class, YARN_PRIORITY) 065 .bindNamedParameter(JVMHeapSlack.class, JVM_HEAP_SLACK) 066 .bindImplementation(RuntimeClasspathProvider.class, YarnClasspathProvider.class) 067 // Bind external constructors. Taken from YarnExternalConstructors.registerClientConstructors 068 .bindConstructor(org.apache.hadoop.yarn.conf.YarnConfiguration.class, YarnConfigurationConstructor.class) 069 .bindSetEntry(DriverConfigurationProviders.class, DRIVER_CONFIGURATION_PROVIDERS) 070 .build(); 071}