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.Private; 022import org.apache.reef.runtime.common.client.DriverConfigurationProvider; 023import org.apache.reef.runtime.common.parameters.JVMHeapSlack; 024import org.apache.reef.runtime.yarn.driver.RuntimeIdentifier; 025import org.apache.reef.tang.Configuration; 026import org.apache.reef.tang.Configurations; 027import org.apache.reef.tang.annotations.Parameter; 028 029import javax.inject.Inject; 030import java.net.URI; 031 032import static org.apache.reef.runtime.yarn.driver.YarnDriverConfiguration.*; 033 034/** 035 * Default driver configuration provider for yarn runtime. 036 */ 037@Private 038public final class YarnDriverConfigurationProviderImpl implements DriverConfigurationProvider { 039 040 private final double jvmSlack; 041 042 @Inject 043 YarnDriverConfigurationProviderImpl(@Parameter(JVMHeapSlack.class) final double jvmSlack) { 044 this.jvmSlack = jvmSlack; 045 } 046 047 @Override 048 public Configuration getDriverConfiguration(final URI jobFolder, 049 final String clientRemoteId, 050 final String jobId, 051 final Configuration applicationConfiguration) { 052 return Configurations.merge( 053 org.apache.reef.runtime.yarn.driver.YarnDriverConfiguration.CONF 054 .set(JOB_SUBMISSION_DIRECTORY, jobFolder.toString()) 055 .set(JOB_IDENTIFIER, jobId) 056 .set(CLIENT_REMOTE_IDENTIFIER, clientRemoteId) 057 .set(JVM_HEAP_SLACK, this.jvmSlack) 058 .set(RUNTIME_NAMES, RuntimeIdentifier.RUNTIME_NAME) 059 .build(), 060 applicationConfiguration); 061 } 062}