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