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.hdinsight.client; 020 021import org.apache.hadoop.yarn.conf.YarnConfiguration; 022import org.apache.reef.annotations.audience.ClientSide; 023import org.apache.reef.annotations.audience.Private; 024import org.apache.reef.io.TempFileCreator; 025import org.apache.reef.io.WorkingDirectoryTempFileCreator; 026import org.apache.reef.runtime.common.driver.api.AbstractDriverRuntimeConfiguration; 027import org.apache.reef.runtime.common.driver.api.ResourceLaunchHandler; 028import org.apache.reef.runtime.common.driver.api.ResourceReleaseHandler; 029import org.apache.reef.runtime.common.driver.api.ResourceRequestHandler; 030import org.apache.reef.runtime.common.files.RuntimeClasspathProvider; 031import org.apache.reef.runtime.common.parameters.JVMHeapSlack; 032import org.apache.reef.runtime.hdinsight.HDInsightClasspathProvider; 033import org.apache.reef.runtime.yarn.driver.*; 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.ConfigurationModule; 038import org.apache.reef.tang.formats.ConfigurationModuleBuilder; 039import org.apache.reef.tang.formats.OptionalParameter; 040import org.apache.reef.tang.formats.RequiredParameter; 041import org.apache.reef.wake.time.Clock; 042 043/** 044 * ConfigurationModule to create a Driver configuration. 045 */ 046@Private 047@ClientSide 048public final class HDInsightDriverConfiguration extends ConfigurationModuleBuilder { 049 050 /** 051 * @see org.apache.reef.runtime.yarn.driver.parameters.JobSubmissionDirectory 052 */ 053 public static final RequiredParameter<String> JOB_SUBMISSION_DIRECTORY = new RequiredParameter<>(); 054 /** 055 * @see org.apache.reef.runtime.yarn.driver.parameters.YarnHeartbeatPeriod.class 056 */ 057 public static final OptionalParameter<Integer> YARN_HEARTBEAT_INTERVAL = new OptionalParameter<>(); 058 059 /** 060 * @see AbstractDriverRuntimeConfiguration.JobIdentifier.class 061 */ 062 public static final RequiredParameter<String> JOB_IDENTIFIER = new RequiredParameter<>(); 063 064 /** 065 * @see AbstractDriverRuntimeConfiguration.EvaluatorTimeout 066 */ 067 public static final OptionalParameter<Long> EVALUATOR_TIMEOUT = new OptionalParameter<>(); 068 069 /** 070 * The fraction of the container memory NOT to use for the Java Heap. 071 */ 072 public static final OptionalParameter<Double> JVM_HEAP_SLACK = new OptionalParameter<>(); 073 074 public static final ConfigurationModule CONF = new HDInsightDriverConfiguration() 075 076 // Bind the YARN runtime for the resource manager. 077 .bindImplementation(ResourceLaunchHandler.class, YARNResourceLaunchHandler.class) 078 .bindImplementation(ResourceReleaseHandler.class, YARNResourceReleaseHandler.class) 079 .bindImplementation(ResourceRequestHandler.class, YarnResourceRequestHandler.class) 080 .bindConstructor(YarnConfiguration.class, YarnConfigurationConstructor.class) 081 .bindSetEntry(Clock.RuntimeStartHandler.class, YARNRuntimeStartHandler.class) 082 .bindSetEntry(Clock.RuntimeStopHandler.class, YARNRuntimeStopHandler.class) 083 .bindImplementation(TempFileCreator.class, WorkingDirectoryTempFileCreator.class) 084 085 // Bind the YARN Configuration parameters 086 .bindNamedParameter(JobSubmissionDirectory.class, JOB_SUBMISSION_DIRECTORY) 087 .bindNamedParameter(YarnHeartbeatPeriod.class, YARN_HEARTBEAT_INTERVAL) 088 089 // Bind the fields bound in AbstractDriverRuntimeConfiguration 090 .bindNamedParameter(AbstractDriverRuntimeConfiguration.JobIdentifier.class, JOB_IDENTIFIER) 091 .bindNamedParameter(AbstractDriverRuntimeConfiguration.EvaluatorTimeout.class, EVALUATOR_TIMEOUT) 092 .bindNamedParameter(JVMHeapSlack.class, JVM_HEAP_SLACK) 093 .bindImplementation(RuntimeClasspathProvider.class, HDInsightClasspathProvider.class) 094 .build(); 095}