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.client; 020 021import org.apache.reef.client.parameters.DriverConfigurationProviders; 022import org.apache.reef.runtime.common.client.CommonRuntimeConfiguration; 023import org.apache.reef.runtime.common.client.DriverConfigurationProvider; 024import org.apache.reef.runtime.common.client.api.JobSubmissionHandler; 025import org.apache.reef.runtime.common.evaluator.PIDStoreStartHandler; 026import org.apache.reef.runtime.common.files.RuntimeClasspathProvider; 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.ConfigurationProvider; 033import org.apache.reef.tang.formats.*; 034import org.apache.reef.wake.time.Clock; 035 036import java.util.concurrent.ExecutorService; 037 038/** 039 * A ConfigurationModule to configure the local resourcemanager with extensibility point. 040 */ 041public final class ExtensibleLocalRuntimeConfiguration extends ConfigurationModuleBuilder { 042 043 /** 044 * The number of threads or processes available to the resourcemanager. This is the upper limit on the number of 045 * Evaluators that the local resourcemanager will hand out concurrently. 046 * This simulates the size of a physical cluster in terms of the number of slots available on it 047 * with one important caveat: The Driver is not counted against this number. 048 */ 049 public static final OptionalParameter<Integer> MAX_NUMBER_OF_EVALUATORS = new OptionalParameter<>(); 050 /** 051 * The folder in which the sub-folders, one per Node, will be created. Those will contain one folder per 052 * Evaluator instantiated on the virtual node. Those inner folders will be named by the time when the Evaluator was 053 * launched. 054 * <p> 055 * If none is given, a folder "REEF_LOCAL_RUNTIME" will be created in the local directory. 056 */ 057 public static final OptionalParameter<String> RUNTIME_ROOT_FOLDER = new OptionalParameter<>(); 058 059 /** 060 * The fraction of the container memory NOT to use for the Java Heap. 061 */ 062 public static final OptionalParameter<Double> JVM_HEAP_SLACK = new OptionalParameter<>(); 063 064 /** 065 * Configuration provides whose Configuration will be merged into all Driver Configuration. 066 */ 067 public static final OptionalImpl<ConfigurationProvider> DRIVER_CONFIGURATION_PROVIDERS = new OptionalImpl<>(); 068 069 /** 070 * The rack names that will be available in the local runtime. 071 */ 072 public static final OptionalParameter<String> RACK_NAMES = new OptionalParameter<>(); 073 074 /** 075 * Driver configuration provider for the client. 076 */ 077 public static final RequiredImpl<DriverConfigurationProvider> DRIVER_CONFIGURATION_PROVIDER = new RequiredImpl<>(); 078 079 /** 080 * The ConfigurationModule for the local resourcemanager. 081 */ 082 public static final ConfigurationModule CONF = new ExtensibleLocalRuntimeConfiguration() 083 .merge(CommonRuntimeConfiguration.CONF) 084 // Bind the local runtime 085 .bindImplementation(JobSubmissionHandler.class, LocalJobSubmissionHandler.class) 086 .bindImplementation(DriverConfigurationProvider.class, DRIVER_CONFIGURATION_PROVIDER) 087 .bindConstructor(ExecutorService.class, ExecutorServiceConstructor.class) 088 .bindImplementation(RuntimeClasspathProvider.class, LocalClasspathProvider.class) 089 // Bind parameters of the local runtime 090 .bindNamedParameter(MaxNumberOfEvaluators.class, MAX_NUMBER_OF_EVALUATORS) 091 .bindNamedParameter(RootFolder.class, RUNTIME_ROOT_FOLDER) 092 .bindNamedParameter(JVMHeapSlack.class, JVM_HEAP_SLACK) 093 .bindSetEntry(DriverConfigurationProviders.class, DRIVER_CONFIGURATION_PROVIDERS) 094 .bindSetEntry(Clock.StartHandler.class, PIDStoreStartHandler.class) 095 .bindSetEntry(RackNames.class, RACK_NAMES) 096 .build(); 097} 098