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