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.REEF; 022import org.apache.reef.client.RunningJob; 023import org.apache.reef.runtime.common.client.REEFImplementation; 024import org.apache.reef.runtime.common.client.RunningJobImpl; 025import org.apache.reef.runtime.common.client.api.JobSubmissionHandler; 026import org.apache.reef.runtime.common.files.RuntimeClasspathProvider; 027import org.apache.reef.runtime.common.launch.REEFMessageCodec; 028import org.apache.reef.runtime.common.parameters.JVMHeapSlack; 029import org.apache.reef.runtime.local.LocalClasspathProvider; 030import org.apache.reef.runtime.local.client.parameters.NumberOfProcesses; 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.wake.remote.RemoteConfiguration; 036 037import java.util.concurrent.ExecutorService; 038 039/** 040 * A ConfigurationModule to configure the local resourcemanager. 041 */ 042public class LocalRuntimeConfiguration extends ConfigurationModuleBuilder { 043 044 /** 045 * The number of threads or processes available to the resourcemanager. This is the upper limit on the number of 046 * Evaluators that the local resourcemanager will hand out concurrently. This simulates the size of a physical cluster in 047 * terms of the number of slots available on it with one important caveat: The Driver is not counted against this 048 * number. 049 */ 050 public static final OptionalParameter<Integer> NUMBER_OF_THREADS = new OptionalParameter<>(); 051 /** 052 * The folder in which the sub-folders, one per Node, will be created. Those will contain one folder per 053 * Evaluator instantiated on the virtual node. Those inner folders will be named by the time when the Evaluator was 054 * launched. 055 * <p/> 056 * If none is given, a folder "REEF_LOCAL_RUNTIME" will be created in the local directory. 057 */ 058 public static final OptionalParameter<String> RUNTIME_ROOT_FOLDER = new OptionalParameter<>(); 059 060 /** 061 * The fraction of the container memory NOT to use for the Java Heap. 062 */ 063 public static final OptionalParameter<Double> JVM_HEAP_SLACK = new OptionalParameter<>(); 064 065 /** 066 * The ConfigurationModule for the local resourcemanager. 067 */ 068 public static final ConfigurationModule CONF = new LocalRuntimeConfiguration() 069 .bindImplementation(REEF.class, REEFImplementation.class) 070 .bindImplementation(RunningJob.class, RunningJobImpl.class) 071 .bindImplementation(JobSubmissionHandler.class, LocalJobSubmissionHandler.class) 072 .bindConstructor(ExecutorService.class, ExecutorServiceConstructor.class) 073 // Bind the message codec for REEF. 074 .bindNamedParameter(RemoteConfiguration.MessageCodec.class, REEFMessageCodec.class) 075 .bindNamedParameter(NumberOfProcesses.class, NUMBER_OF_THREADS) 076 .bindNamedParameter(RootFolder.class, RUNTIME_ROOT_FOLDER) 077 .bindNamedParameter(JVMHeapSlack.class, JVM_HEAP_SLACK) 078 .bindImplementation(RuntimeClasspathProvider.class, LocalClasspathProvider.class) 079 .build(); 080 081 082}