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.REEF; 024import org.apache.reef.client.RunningJob; 025import org.apache.reef.runtime.common.client.REEFImplementation; 026import org.apache.reef.runtime.common.client.RunningJobImpl; 027import org.apache.reef.runtime.common.client.api.JobSubmissionHandler; 028import org.apache.reef.runtime.common.files.RuntimeClasspathProvider; 029import org.apache.reef.runtime.common.launch.REEFMessageCodec; 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.util.YarnConfigurationConstructor; 035import org.apache.reef.tang.formats.ConfigurationModule; 036import org.apache.reef.tang.formats.ConfigurationModuleBuilder; 037import org.apache.reef.tang.formats.OptionalParameter; 038import org.apache.reef.util.logging.LoggingSetup; 039import org.apache.reef.wake.remote.RemoteConfiguration; 040 041/** 042 * A ConfigurationModule for the YARN resourcemanager. 043 */ 044@Public 045@ClientSide 046public class YarnClientConfiguration extends ConfigurationModuleBuilder { 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 054 public static final OptionalParameter<Double> JVM_HEAP_SLACK = new OptionalParameter<>(); 055 056 public static final ConfigurationModule CONF = new YarnClientConfiguration() 057 // Bind the common resourcemanager 058 .bindImplementation(REEF.class, REEFImplementation.class) 059 .bindImplementation(RunningJob.class, RunningJobImpl.class) 060 // Bind the message codec for REEF. 061 .bindNamedParameter(RemoteConfiguration.MessageCodec.class, REEFMessageCodec.class) 062 // Bind YARN 063 .bindImplementation(JobSubmissionHandler.class, YarnJobSubmissionHandler.class) 064 // Bind the parameters given by the user 065 .bindNamedParameter(JobQueue.class, YARN_QUEUE_NAME) 066 .bindNamedParameter(JobPriority.class, YARN_PRIORITY) 067 .bindNamedParameter(JVMHeapSlack.class, JVM_HEAP_SLACK) 068 .bindImplementation(RuntimeClasspathProvider.class, YarnClasspathProvider.class) 069 // Bind external constructors. Taken from YarnExternalConstructors.registerClientConstructors 070 .bindConstructor(org.apache.hadoop.yarn.conf.YarnConfiguration.class, YarnConfigurationConstructor.class) 071 .build(); 072 073}