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.local.driver; 020 021import org.apache.reef.runtime.common.driver.api.*; 022import org.apache.reef.runtime.common.driver.parameters.ClientRemoteIdentifier; 023import org.apache.reef.runtime.common.driver.parameters.JobIdentifier; 024import org.apache.reef.runtime.common.files.RuntimeClasspathProvider; 025import org.apache.reef.runtime.common.launch.parameters.ErrorHandlerRID; 026import org.apache.reef.runtime.common.launch.parameters.LaunchID; 027import org.apache.reef.runtime.common.parameters.JVMHeapSlack; 028import org.apache.reef.runtime.local.LocalClasspathProvider; 029import org.apache.reef.runtime.local.client.parameters.MaxNumberOfEvaluators; 030import org.apache.reef.runtime.local.client.parameters.RackNames; 031import org.apache.reef.runtime.local.client.parameters.RootFolder; 032import org.apache.reef.tang.formats.ConfigurationModule; 033import org.apache.reef.tang.formats.ConfigurationModuleBuilder; 034import org.apache.reef.tang.formats.OptionalParameter; 035import org.apache.reef.tang.formats.RequiredParameter; 036 037/** 038 * ConfigurationModule for the Driver executed in the local resourcemanager. This is meant to eventually replace 039 * LocalDriverRuntimeConfiguration. 040 */ 041public class LocalDriverConfiguration extends ConfigurationModuleBuilder { 042 /** 043 * The maximum number of evaluators. 044 */ 045 public static final RequiredParameter<Integer> MAX_NUMBER_OF_EVALUATORS = new RequiredParameter<>(); 046 /** 047 * The root folder of the job. Assumed to be an absolute path. 048 */ 049 public static final RequiredParameter<String> ROOT_FOLDER = new RequiredParameter<>(); 050 /** 051 * The fraction of the container memory NOT to use for the Java Heap. 052 */ 053 public static final OptionalParameter<Double> JVM_HEAP_SLACK = new OptionalParameter<>(); 054 055 /** 056 * The rack names that will be available in the local runtime. 057 */ 058 public static final OptionalParameter<String> RACK_NAMES = new OptionalParameter<>(); 059 060 /** 061 * The remote identifier to use for communications back to the client. 062 */ 063 public static final OptionalParameter<String> CLIENT_REMOTE_IDENTIFIER = new OptionalParameter<>(); 064 065 /** 066 * The identifier of the Job submitted. 067 */ 068 public static final RequiredParameter<String> JOB_IDENTIFIER = new RequiredParameter<>(); 069 070 public static final ConfigurationModule CONF = new LocalDriverConfiguration() 071 .bindImplementation(ResourceLaunchHandler.class, LocalResourceLaunchHandler.class) 072 .bindImplementation(ResourceRequestHandler.class, LocalResourceRequestHandler.class) 073 .bindImplementation(ResourceReleaseHandler.class, LocalResourceReleaseHandler.class) 074 .bindImplementation(ResourceManagerStartHandler.class, LocalResourceManagerStartHandler.class) 075 .bindImplementation(ResourceManagerStopHandler.class, LocalResourceManagerStopHandler.class) 076 .bindNamedParameter(ClientRemoteIdentifier.class, CLIENT_REMOTE_IDENTIFIER) 077 .bindNamedParameter(ErrorHandlerRID.class, CLIENT_REMOTE_IDENTIFIER) 078 .bindNamedParameter(JobIdentifier.class, JOB_IDENTIFIER) 079 .bindNamedParameter(LaunchID.class, JOB_IDENTIFIER) 080 .bindNamedParameter(MaxNumberOfEvaluators.class, MAX_NUMBER_OF_EVALUATORS) 081 .bindNamedParameter(RootFolder.class, ROOT_FOLDER) 082 .bindNamedParameter(JVMHeapSlack.class, JVM_HEAP_SLACK) 083 .bindSetEntry(RackNames.class, RACK_NAMES) 084 .bindImplementation(RuntimeClasspathProvider.class, LocalClasspathProvider.class) 085 .build(); 086}