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.mesos.driver; 020 021import org.apache.hadoop.conf.Configuration; 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.EvaluatorTimeout; 027import org.apache.reef.runtime.common.driver.parameters.JobIdentifier; 028import org.apache.reef.runtime.common.files.RuntimeClasspathProvider; 029import org.apache.reef.runtime.common.launch.parameters.ErrorHandlerRID; 030import org.apache.reef.runtime.common.launch.parameters.LaunchID; 031import org.apache.reef.runtime.common.parameters.JVMHeapSlack; 032import org.apache.reef.runtime.mesos.MesosClasspathProvider; 033import org.apache.reef.runtime.mesos.driver.parameters.MesosMasterIp; 034import org.apache.reef.runtime.mesos.driver.parameters.MesosSlavePort; 035import org.apache.reef.runtime.mesos.driver.parameters.JobSubmissionDirectoryPrefix; 036import org.apache.reef.runtime.mesos.util.HDFSConfigurationConstructor; 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.EStage; 042import org.apache.reef.wake.StageConfiguration; 043import org.apache.reef.wake.impl.SingleThreadStage; 044 045/** 046 * Binds Driver's runtime event handlers. 047 */ 048public final class MesosDriverConfiguration extends ConfigurationModuleBuilder { 049 /** 050 * @see JobIdentifier 051 */ 052 public static final RequiredParameter<String> JOB_IDENTIFIER = new RequiredParameter<>(); 053 054 /** 055 * @see EvaluatorTimeout 056 */ 057 public static final OptionalParameter<Long> EVALUATOR_TIMEOUT = new OptionalParameter<>(); 058 059 /** 060 * The ip address of Mesos Master. 061 */ 062 public static final RequiredParameter<String> MESOS_MASTER_IP = new RequiredParameter<>(); 063 064 /** 065 * The port number of Mesos Slave. 066 */ 067 public static final OptionalParameter<Integer> MESOS_SLAVE_PORT = new OptionalParameter<>(); 068 069 /** 070 * The client remote identifier. 071 */ 072 public static final OptionalParameter<String> CLIENT_REMOTE_IDENTIFIER = new OptionalParameter<>(); 073 074 /** 075 * The fraction of the container memory NOT to use for the Java Heap. 076 */ 077 public static final OptionalParameter<Double> JVM_HEAP_SLACK = new OptionalParameter<>(); 078 079 /** 080 * Capacity for running Mesos Scheduler Driver. 081 */ 082 public static final RequiredParameter<Integer> SCHEDULER_DRIVER_CAPACITY = new RequiredParameter<>(); 083 084 /** 085 * The client remote identifier. 086 */ 087 public static final OptionalParameter<String> JOB_SUBMISSION_DIRECTORY_PREFIX = new OptionalParameter<>(); 088 089 public static final ConfigurationModule CONF = new MesosDriverConfiguration() 090 .bindImplementation(ResourceLaunchHandler.class, MesosResourceLaunchHandler.class) 091 .bindImplementation(ResourceReleaseHandler.class, MesosResourceReleaseHandler.class) 092 .bindImplementation(ResourceRequestHandler.class, MesosResourceRequestHandler.class) 093 .bindImplementation(ResourceManagerStartHandler.class, MesosRuntimeStartHandler.class) 094 .bindImplementation(ResourceManagerStopHandler.class, MesosRuntimeStopHandler.class) 095 .bindImplementation(TempFileCreator.class, WorkingDirectoryTempFileCreator.class) 096 097 .bindNamedParameter(MesosMasterIp.class, MESOS_MASTER_IP) 098 .bindNamedParameter(MesosSlavePort.class, MESOS_SLAVE_PORT) 099 .bindConstructor(Configuration.class, HDFSConfigurationConstructor.class) 100 .bindImplementation(RuntimeClasspathProvider.class, MesosClasspathProvider.class) 101 102 .bindNamedParameter(StageConfiguration.Capacity.class, SCHEDULER_DRIVER_CAPACITY) 103 .bindNamedParameter(JobSubmissionDirectoryPrefix.class, JOB_SUBMISSION_DIRECTORY_PREFIX) 104 .bindNamedParameter(StageConfiguration.StageHandler.class, MesosSchedulerDriverExecutor.class) 105 .bindImplementation(EStage.class, SingleThreadStage.class) 106 107 // Bind the fields bound in AbstractDriverRuntimeConfiguration 108 .bindNamedParameter(JobIdentifier.class, JOB_IDENTIFIER) 109 .bindNamedParameter(LaunchID.class, JOB_IDENTIFIER) 110 .bindNamedParameter(EvaluatorTimeout.class, EVALUATOR_TIMEOUT) 111 .bindNamedParameter(ClientRemoteIdentifier.class, CLIENT_REMOTE_IDENTIFIER) 112 .bindNamedParameter(ErrorHandlerRID.class, CLIENT_REMOTE_IDENTIFIER) 113 .bindNamedParameter(JVMHeapSlack.class, JVM_HEAP_SLACK) 114 .build(); 115}