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.driver; 020 021import org.apache.hadoop.yarn.conf.YarnConfiguration; 022import org.apache.reef.io.TempFileCreator; 023import org.apache.reef.io.WorkingDirectoryTempFileCreator; 024import org.apache.reef.runtime.common.driver.api.*; 025import org.apache.reef.runtime.common.driver.parameters.ClientRemoteIdentifier; 026import org.apache.reef.runtime.common.driver.parameters.DefinedRuntimes; 027import org.apache.reef.runtime.common.driver.parameters.EvaluatorTimeout; 028import org.apache.reef.runtime.common.driver.parameters.JobIdentifier; 029import org.apache.reef.runtime.common.files.RuntimeClasspathProvider; 030import org.apache.reef.runtime.common.launch.parameters.ErrorHandlerRID; 031import org.apache.reef.runtime.common.launch.parameters.LaunchID; 032import org.apache.reef.runtime.common.parameters.JVMHeapSlack; 033import org.apache.reef.runtime.yarn.YarnClasspathProvider; 034import org.apache.reef.runtime.yarn.driver.parameters.JobSubmissionDirectory; 035import org.apache.reef.runtime.yarn.driver.parameters.YarnHeartbeatPeriod; 036import org.apache.reef.runtime.yarn.util.YarnConfigurationConstructor; 037import org.apache.reef.tang.formats.*; 038 039/** 040 * ConfigurationModule to create YARN Driver configurations. 041 */ 042public class YarnDriverConfiguration extends ConfigurationModuleBuilder { 043 /** 044 * @see org.apache.reef.driver.parameters.JobSubmissionDirectory 045 */ 046 public static final RequiredParameter<String> JOB_SUBMISSION_DIRECTORY = new RequiredParameter<>(); 047 048 /** 049 * @see org.apache.reef.runtime.yarn.driver.parameters.YarnHeartbeatPeriod 050 */ 051 public static final OptionalParameter<Integer> YARN_HEARTBEAT_INTERVAL = new OptionalParameter<>(); 052 053 /** 054 * @see JobIdentifier 055 */ 056 public static final RequiredParameter<String> JOB_IDENTIFIER = new RequiredParameter<>(); 057 058 /** 059 * @see DefinedRuntimes 060 */ 061 public static final RequiredParameter<String> RUNTIME_NAMES = new RequiredParameter<>(); 062 /** 063 * @see RackNameFormatter 064 */ 065 public static final OptionalImpl<RackNameFormatter> RACK_NAME_FORMATTER = new OptionalImpl<>(); 066 067 /** 068 * @see EvaluatorTimeout 069 */ 070 public static final OptionalParameter<Long> EVALUATOR_TIMEOUT = new OptionalParameter<>(); 071 072 /** 073 * The client remote identifier. 074 */ 075 public static final OptionalParameter<String> CLIENT_REMOTE_IDENTIFIER = new OptionalParameter<>(); 076 077 /** 078 * The fraction of the container memory NOT to use for the Java Heap. 079 */ 080 public static final OptionalParameter<Double> JVM_HEAP_SLACK = new OptionalParameter<>(); 081 082 083 public static final ConfigurationModule CONF = new YarnDriverConfiguration() 084 // Bind the YARN runtime for the resource manager. 085 .bindImplementation(ResourceLaunchHandler.class, YARNResourceLaunchHandler.class) 086 .bindImplementation(ResourceReleaseHandler.class, YARNResourceReleaseHandler.class) 087 .bindImplementation(ResourceRequestHandler.class, YarnResourceRequestHandler.class) 088 .bindImplementation(ResourceManagerStartHandler.class, YARNRuntimeStartHandler.class) 089 .bindImplementation(ResourceManagerStopHandler.class, YARNRuntimeStopHandler.class) 090 .bindConstructor(YarnConfiguration.class, YarnConfigurationConstructor.class) 091 .bindImplementation(TempFileCreator.class, WorkingDirectoryTempFileCreator.class) 092 093 // Bind the YARN Configuration parameters 094 .bindNamedParameter(JobSubmissionDirectory.class, JOB_SUBMISSION_DIRECTORY) 095 .bindNamedParameter(YarnHeartbeatPeriod.class, YARN_HEARTBEAT_INTERVAL) 096 097 // Bind the fields bound in AbstractDriverRuntimeConfiguration 098 .bindNamedParameter(JobIdentifier.class, JOB_IDENTIFIER) 099 .bindNamedParameter(LaunchID.class, JOB_IDENTIFIER) 100 .bindNamedParameter(EvaluatorTimeout.class, EVALUATOR_TIMEOUT) 101 .bindNamedParameter(ClientRemoteIdentifier.class, CLIENT_REMOTE_IDENTIFIER) 102 .bindNamedParameter(ErrorHandlerRID.class, CLIENT_REMOTE_IDENTIFIER) 103 .bindNamedParameter(JVMHeapSlack.class, JVM_HEAP_SLACK) 104 .bindImplementation(RackNameFormatter.class, RACK_NAME_FORMATTER) 105 .bindImplementation(RuntimeClasspathProvider.class, YarnClasspathProvider.class) 106 .bindSetEntry(DefinedRuntimes.class, RUNTIME_NAMES) 107 .build(); 108}