You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by we...@apache.org on 2015/01/23 00:46:55 UTC

[22/51] [partial] incubator-reef git commit: [REEF-93] Move java sources to lang/java

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/AzureStorageAccountKey.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/AzureStorageAccountKey.java b/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/AzureStorageAccountKey.java
new file mode 100644
index 0000000..d17ca80
--- /dev/null
+++ b/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/AzureStorageAccountKey.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.hdinsight.parameters;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+/**
+ * The Storage account key to be used by Azure.
+ */
+@NamedParameter(doc = "The Storage account key to be used by Azure")
+public final class AzureStorageAccountKey implements Name<String> {
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/AzureStorageAccountName.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/AzureStorageAccountName.java b/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/AzureStorageAccountName.java
new file mode 100644
index 0000000..5d0acae
--- /dev/null
+++ b/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/AzureStorageAccountName.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.hdinsight.parameters;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+/**
+ * The Storage account to be used by Azure.
+ */
+@NamedParameter(doc = "The Storage account to be used by Azure")
+public final class AzureStorageAccountName implements Name<String> {
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/AzureStorageBaseFolder.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/AzureStorageBaseFolder.java b/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/AzureStorageBaseFolder.java
new file mode 100644
index 0000000..46f6d85
--- /dev/null
+++ b/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/AzureStorageBaseFolder.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.hdinsight.parameters;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+/**
+ * The folder to use as the base folder for storing the JARs.
+ */
+@NamedParameter(doc = " The folder to use as the base folder for storing the JARs.", default_value = "apps/reef/jobs/")
+public final class AzureStorageBaseFolder implements Name<String> {
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/HDInsightInstanceURL.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/HDInsightInstanceURL.java b/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/HDInsightInstanceURL.java
new file mode 100644
index 0000000..2019970
--- /dev/null
+++ b/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/HDInsightInstanceURL.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.hdinsight.parameters;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+/**
+ * The password to be used for connecting to hdinsight.
+ */
+@NamedParameter(doc = "The instance URL")
+public final class HDInsightInstanceURL implements Name<String> {
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/HDInsightPassword.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/HDInsightPassword.java b/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/HDInsightPassword.java
new file mode 100644
index 0000000..458c66e
--- /dev/null
+++ b/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/HDInsightPassword.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.hdinsight.parameters;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+/**
+ * The password to be used for connecting to hdinsight.
+ */
+@NamedParameter(doc = "The password to be used for connecting to hdinsight.")
+public final class HDInsightPassword implements Name<String> {
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/HDInsightUsername.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/HDInsightUsername.java b/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/HDInsightUsername.java
new file mode 100644
index 0000000..21bc14e
--- /dev/null
+++ b/lang/java/reef-runtime-hdinsight/src/main/java/org/apache/reef/runtime/hdinsight/parameters/HDInsightUsername.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.hdinsight.parameters;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+/**
+ * The username to be used for connecting to hdinsight.
+ */
+@NamedParameter(doc = "The username to be used for connecting to hdinsight.")
+public final class HDInsightUsername implements Name<String> {
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/pom.xml
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/pom.xml b/lang/java/reef-runtime-local/pom.xml
new file mode 100644
index 0000000..7dff839
--- /dev/null
+++ b/lang/java/reef-runtime-local/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.reef</groupId>
+        <artifactId>reef-project</artifactId>
+        <version>0.11.0-incubating-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>reef-runtime-local</artifactId>
+    <name>REEF Runtime Local</name>
+    <description>A local implementation of REEF that uses local JVMs for execution.</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>reef-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <resources>
+            <resource>
+                <targetPath>META-INF/</targetPath>
+                <filtering>false</filtering>
+                <directory>${basedir}/conf</directory>
+                <includes>
+                    <include>*.xml</include>
+                    <include>*.properties</include>
+                </includes>
+                <excludes>
+                </excludes>
+            </resource>
+        </resources>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/LocalClasspathProvider.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/LocalClasspathProvider.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/LocalClasspathProvider.java
new file mode 100644
index 0000000..22d1fd8
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/LocalClasspathProvider.java
@@ -0,0 +1,134 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local;
+
+import org.apache.reef.runtime.common.files.RuntimeClasspathProvider;
+import org.apache.reef.util.Optional;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+
+/**
+ * RuntimeClasspathProvider for the local runtime.
+ * <p/>
+ * The prefix for the local runtime is empty, the suffix is the classpath of the current JVM. That classpath is filtered
+ * to not contain subfolders of JAVA_HOME. Also, duplicates are removed.
+ */
+public final class LocalClasspathProvider implements RuntimeClasspathProvider {
+  private final List<String> classPathSuffix;
+
+  @Inject
+  LocalClasspathProvider() {
+    this.classPathSuffix = Collections.unmodifiableList(new ArrayList<>(getFilteredClasspath()));
+  }
+
+  /**
+   * @return the classpath filtered by entries in subfolders of JAVA_HOME are removed, so are duplicate entries.
+   */
+  private static LinkedHashSet<String> getFilteredClasspath() {
+    final LinkedHashSet<String> result = new LinkedHashSet<>();
+    final Optional<Path> javaHome = getJavaHome();
+
+    if (javaHome.isPresent()) {
+      final Path javaHomePath = javaHome.get();
+      for (final Path classPathEntry : getClasspath()) {
+        if (!classPathEntry.startsWith(javaHomePath)) {
+          result.add(toAbsolutePathString(classPathEntry));
+        }
+      }
+    } else {
+      for (final Path classPathEntry : getClasspath()) {
+        result.add(toAbsolutePathString(classPathEntry));
+      }
+    }
+    return result;
+  }
+
+  /**
+   * @return the path to "JAVA_HOME", if that is set. Optional.empty(), else.
+   */
+  private static Optional<Path> getJavaHome() {
+    final Optional<String> javaHome = getEnv("JAVA_HOME");
+
+    if (javaHome.isPresent()) {
+      final File javaHomeFile = new File(javaHome.get());
+      if (javaHomeFile.exists()) {
+        return Optional.of(javaHomeFile.toPath());
+      }
+    }
+    return Optional.empty();
+  }
+
+  /**
+   * @param envName
+   * @return the value of the environment variable, if there is one.
+   */
+  private static Optional<String> getEnv(final String envName) {
+    return Optional.ofNullable(System.getenv(envName));
+  }
+
+  /**
+   * @return the classpath of the current JVM. Duplicates are removed.
+   */
+  private static LinkedHashSet<Path> getClasspath() {
+    final LinkedHashSet<Path> result = new LinkedHashSet<>();
+    for (final String classPathEntry : System.getProperty("java.class.path").split(File.pathSeparator)) {
+      final File file = new File(classPathEntry);
+      if (file.exists()) {
+        result.add(file.toPath());
+      }
+    }
+    return result;
+  }
+
+  /**
+   * Concerts the given path into a String representing the absolute path.
+   *
+   * @param path
+   * @return
+   */
+  private static String toAbsolutePathString(final Path path) {
+    return path.toAbsolutePath().toString();
+  }
+
+  @Override
+  public List<String> getDriverClasspathPrefix() {
+    return Collections.emptyList();
+  }
+
+  @Override
+  public List<String> getDriverClasspathSuffix() {
+    return this.classPathSuffix;
+  }
+
+  @Override
+  public List<String> getEvaluatorClasspathPrefix() {
+    return Collections.emptyList();
+  }
+
+  @Override
+  public List<String> getEvaluatorClasspathSuffix() {
+    return this.classPathSuffix;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/DriverFiles.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/DriverFiles.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/DriverFiles.java
new file mode 100644
index 0000000..06262e4
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/DriverFiles.java
@@ -0,0 +1,174 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.client;
+
+import org.apache.reef.proto.ClientRuntimeProtocol;
+import org.apache.reef.proto.ReefServiceProtos;
+import org.apache.reef.runtime.common.files.REEFFileNames;
+import org.apache.reef.tang.formats.ConfigurationModule;
+import org.apache.reef.tang.formats.OptionalParameter;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Represents the files added to a driver.
+ * <p/>
+ * This class is constructed via the from() method that instantiates it based on a JobSubmissionProto
+ */
+final class DriverFiles {
+
+  private static final Logger LOG = Logger.getLogger(DriverFiles.class.getName());
+
+  private final FileSet localFiles = new FileSet();
+  private final FileSet localLibs = new FileSet();
+  private final FileSet globalFiles = new FileSet();
+  private final FileSet globalLibs = new FileSet();
+  private final REEFFileNames fileNames;
+
+  public DriverFiles(final REEFFileNames fileNames) {
+    this.fileNames = fileNames;
+  }
+
+  /**
+   * Instantiates an instance based on the given JobSubmissionProto.
+   *
+   * @param jobSubmissionProto the JobSubmissionProto to parse.
+   * @return a DriverFiles instance pre-populated with the information from the given JobSubmissionProto.
+   * @throws IOException
+   */
+  public static DriverFiles fromJobSubmission(
+      final ClientRuntimeProtocol.JobSubmissionProto jobSubmissionProto,
+      final REEFFileNames fileNames) throws IOException {
+
+    final DriverFiles driverFiles = new DriverFiles(fileNames);
+
+    for (final ReefServiceProtos.FileResourceProto frp : jobSubmissionProto.getGlobalFileList()) {
+      final File f = new File(frp.getPath());
+      if (frp.getType() == ReefServiceProtos.FileType.LIB) {
+        driverFiles.addGlobalLib(f);
+      } else {
+        driverFiles.addGlobalFile(f);
+      }
+    }
+
+    for (final ReefServiceProtos.FileResourceProto frp : jobSubmissionProto.getLocalFileList()) {
+      final File f = new File(frp.getPath());
+      if (frp.getType() == ReefServiceProtos.FileType.LIB) {
+        driverFiles.addLocalLib(f);
+      } else {
+        driverFiles.addLocalFile(f);
+      }
+    }
+
+    return driverFiles;
+  }
+
+  private void addLocalLib(final File f) throws IOException {
+    checkFile(f);
+    this.localLibs.add(f);
+  }
+
+  private void addLocalFile(final File f) throws IOException {
+    checkFile(f);
+    this.localFiles.add(f);
+  }
+
+  private void addGlobalFile(final File f) throws IOException {
+    checkFile(f);
+    this.globalFiles.add(f);
+  }
+
+  private void addGlobalLib(final File f) throws IOException {
+    checkFile(f);
+    this.globalLibs.add(f);
+  }
+
+  private void checkFile(final File f) {
+    if (this.globalLibs.containsFileWithName(f.getName())) {
+      LOG.log(Level.FINEST, "Adding a file that is already part of the global libraries: {0}", f);
+    }
+    if (this.globalFiles.containsFileWithName(f.getName())) {
+      LOG.log(Level.FINEST, "Adding a file that is already part of the global files: {0}", f);
+    }
+    if (this.localLibs.containsFileWithName(f.getName())) {
+      LOG.log(Level.FINEST, "Adding a file that is already part of the local libraries: {0}", f);
+    }
+    if (this.localFiles.containsFileWithName(f.getName())) {
+      LOG.log(Level.FINEST, "Adding a file that is already part of the local files: {0}", f);
+    }
+  }
+
+  /**
+   * Copies this set of files to the destination folder given.
+   * <p/>
+   * Will attempt to create symbolic links for the files to the destination
+   * folder.  If the filesystem does not support symbolic links or the user
+   * does not have appropriate permissions, the entire file will be copied instead.
+   *
+   * @param destinationFolder the folder the files shall be copied to.
+   * @throws IOException if one or more of the copies fail.
+   */
+  public void copyTo(final File destinationFolder) throws IOException {
+    destinationFolder.mkdirs();
+    final File reefFolder = new File(destinationFolder, fileNames.getREEFFolderName());
+
+    final File localFolder = new File(reefFolder, fileNames.getLocalFolderName());
+    final File globalFolder = new File(reefFolder, fileNames.getGlobalFolderName());
+    localFolder.mkdirs();
+    globalFolder.mkdirs();
+
+    try {
+      this.localFiles.createSymbolicLinkTo(localFolder);
+      this.localLibs.createSymbolicLinkTo(localFolder);
+      this.globalLibs.createSymbolicLinkTo(globalFolder);
+      this.globalFiles.createSymbolicLinkTo(globalFolder);
+    } catch (IOException e) {
+      this.localFiles.copyTo(localFolder);
+      this.localLibs.copyTo(localFolder);
+      this.globalLibs.copyTo(globalFolder);
+      this.globalFiles.copyTo(globalFolder);
+    }
+  }
+
+  /**
+   * Fills out a ConfigurationModule.
+   *
+   * @param input           The ConfigurationModule to start with.
+   * @param globalFileField the field on which to set() the global files.
+   * @param globalLibField  the field on which to set() the global libraries.
+   * @param localFileField  the field on which to set() the local files.
+   * @param localLibField   the field on which to set() the local libraries.
+   * @return a copy of input with files and libraries added to the given fields.
+   */
+  public ConfigurationModule addNamesTo(final ConfigurationModule input,
+                                        final OptionalParameter<String> globalFileField,
+                                        final OptionalParameter<String> globalLibField,
+                                        final OptionalParameter<String> localFileField,
+                                        final OptionalParameter<String> localLibField) {
+    ConfigurationModule result = input;
+    result = this.globalFiles.addNamesTo(result, globalFileField);
+    result = this.globalLibs.addNamesTo(result, globalLibField);
+    result = this.localFiles.addNamesTo(result, localFileField);
+    result = this.localLibs.addNamesTo(result, localLibField);
+    return result;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/ExecutorServiceConstructor.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/ExecutorServiceConstructor.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/ExecutorServiceConstructor.java
new file mode 100644
index 0000000..8a211e8
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/ExecutorServiceConstructor.java
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.client;
+
+import org.apache.reef.tang.ExternalConstructor;
+
+import javax.inject.Inject;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Used to make instances of ExecutorService via tang.
+ */
+public final class ExecutorServiceConstructor implements ExternalConstructor<ExecutorService> {
+  private static final Logger LOG = Logger.getLogger(ExecutorServiceConstructor.class.getName());
+
+  @Inject
+  ExecutorServiceConstructor() {
+  }
+
+  @Override
+  public ExecutorService newInstance() {
+    LOG.log(Level.FINEST, "Instantiating new 'ExecutorService'.");
+    return Executors.newCachedThreadPool();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/FileSet.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/FileSet.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/FileSet.java
new file mode 100644
index 0000000..df3d5cd
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/FileSet.java
@@ -0,0 +1,113 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.client;
+
+import org.apache.reef.tang.formats.ConfigurationModule;
+import org.apache.reef.tang.formats.OptionalParameter;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Manages a set of files.
+ */
+final class FileSet {
+  private static final Logger LOG = Logger.getLogger(FileSet.class.getName());
+  private final Set<File> theFiles = new HashSet<>();
+  private final Set<String> fileNames = new HashSet<>();
+
+  /**
+   * Add a file to the FileSet.
+   * <p/>
+   * If the file is a directory, it is turned into a JAR and the resulting JAR is added.
+   * <p/>
+   * Files already added will be ignored.
+   *
+   * @param file the file to be added.
+   */
+  final void add(final File file) {
+    if (file.isFile()) {
+      if (this.fileNames.contains(file.getName())) {
+        LOG.log(Level.FINEST, "A file with this name has already been added: {0}", file.getName());
+      } else {
+        this.fileNames.add(file.getName());
+        this.theFiles.add(file);
+      }
+    } else {
+      LOG.log(Level.FINEST, "Ignoring, because it is not a proper file: {0}", file);
+    }
+  }
+
+  final boolean containsFileWithName(final String name) {
+    return this.fileNames.contains(name);
+  }
+
+  /**
+   * @return an iterable over the filenames, sans the folder. e.g. "/tmp/foo.txt" is returned as "foo.txt"
+   */
+  final Set<String> fileNames() {
+    return this.fileNames;
+  }
+
+  /**
+   * Copies all files in the current FileSet to the given destinationFolder.
+   *
+   * @param destinationFolder the folder where the files shall be copied to.
+   * @throws IOException
+   */
+  final void copyTo(final File destinationFolder) throws IOException {
+    for (final File f : this.theFiles) {
+      final File destinationFile = new File(destinationFolder, f.getName());
+      Files.copy(f.toPath(), destinationFile.toPath());
+    }
+  }
+
+  /**
+   * Creates symbolic links for the current FileSet into the given destinationFolder.
+   *
+   * @param destinationFolder the folder where the symbolic links will be created.
+   * @throws IOException
+   */
+  final void createSymbolicLinkTo(final File destinationFolder) throws IOException {
+    for (final File f : this.theFiles) {
+      final File destinationFile = new File(destinationFolder, f.getName());
+      Files.createSymbolicLink(destinationFile.toPath(), f.toPath());
+    }
+  }
+
+  /**
+   * Adds the file names of this FileSet to the given field of the given ConfigurationModule.
+   *
+   * @param input the ConfigurationModule to fill out
+   * @param field the field to add the files in this set to.
+   * @return the filled out ConfigurationModule
+   */
+  final ConfigurationModule addNamesTo(final ConfigurationModule input, final OptionalParameter<String> field) {
+    ConfigurationModule result = input;
+    for (final String fileName : this.fileNames()) {
+      result = result.set(field, fileName);
+    }
+    return result;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/LocalJobSubmissionHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/LocalJobSubmissionHandler.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/LocalJobSubmissionHandler.java
new file mode 100644
index 0000000..66b3ce6
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/LocalJobSubmissionHandler.java
@@ -0,0 +1,166 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.client;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.reef.annotations.audience.ClientSide;
+import org.apache.reef.annotations.audience.Private;
+import org.apache.reef.proto.ClientRuntimeProtocol;
+import org.apache.reef.runtime.common.client.api.JobSubmissionHandler;
+import org.apache.reef.runtime.common.files.ClasspathProvider;
+import org.apache.reef.runtime.common.files.REEFFileNames;
+import org.apache.reef.runtime.common.launch.JavaLaunchCommandBuilder;
+import org.apache.reef.runtime.common.parameters.JVMHeapSlack;
+import org.apache.reef.runtime.local.client.parameters.NumberOfProcesses;
+import org.apache.reef.runtime.local.client.parameters.RootFolder;
+import org.apache.reef.runtime.local.driver.LocalDriverConfiguration;
+import org.apache.reef.runtime.local.driver.LocalDriverRuntimeConfiguration;
+import org.apache.reef.runtime.local.process.LoggingRunnableProcessObserver;
+import org.apache.reef.runtime.local.process.RunnableProcess;
+import org.apache.reef.tang.Configuration;
+import org.apache.reef.tang.Tang;
+import org.apache.reef.tang.annotations.Parameter;
+import org.apache.reef.tang.formats.ConfigurationSerializer;
+import org.apache.reef.util.logging.LoggingScope;
+import org.apache.reef.util.logging.LoggingScopeFactory;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Handles Job Submissions for the Local Runtime.
+ */
+@Private
+@ClientSide
+final class LocalJobSubmissionHandler implements JobSubmissionHandler {
+
+  /**
+   * The name of the folder for the driver within the Job folder.
+   */
+  public static final String DRIVER_FOLDER_NAME = "driver";
+  /**
+   * The (hard-coded) amount of memory to be used for the driver.
+   */
+  public static final int DRIVER_MEMORY = 512;
+  private static final Logger LOG = Logger.getLogger(LocalJobSubmissionHandler.class.getName());
+  private final ExecutorService executor;
+  private final int nThreads;
+  private final String rootFolderName;
+  private final ConfigurationSerializer configurationSerializer;
+  private final REEFFileNames filenames;
+  private final ClasspathProvider classpath;
+  private final double jvmHeapSlack;
+  private final LoggingScopeFactory loggingScopeFactory;
+
+  @Inject
+  public LocalJobSubmissionHandler(
+      final ExecutorService executor,
+      final @Parameter(RootFolder.class) String rootFolderName,
+      final @Parameter(NumberOfProcesses.class) int nThreads,
+      final ConfigurationSerializer configurationSerializer,
+      final REEFFileNames filenames,
+      final ClasspathProvider classpath,
+      final @Parameter(JVMHeapSlack.class) double jvmHeapSlack,
+      final LoggingScopeFactory loggingScopeFactory) {
+
+    this.executor = executor;
+    this.nThreads = nThreads;
+    this.configurationSerializer = configurationSerializer;
+    this.filenames = filenames;
+    this.classpath = classpath;
+    this.jvmHeapSlack = jvmHeapSlack;
+    this.rootFolderName = new File(rootFolderName).getAbsolutePath();
+    this.loggingScopeFactory = loggingScopeFactory;
+
+    LOG.log(Level.FINE, "Instantiated 'LocalJobSubmissionHandler'");
+  }
+
+  @Override
+  public final void close() {
+    this.executor.shutdown();
+  }
+
+  @Override
+  public final void onNext(final ClientRuntimeProtocol.JobSubmissionProto t) {
+    try (final LoggingScope lf = loggingScopeFactory.localJobSubmission()) {
+      try {
+        LOG.log(Level.FINEST, "Starting local job {0}", t.getIdentifier());
+
+        final File jobFolder = new File(new File(rootFolderName),
+            "/" + t.getIdentifier() + "-" + System.currentTimeMillis() + "/");
+
+        final File driverFolder = new File(jobFolder, DRIVER_FOLDER_NAME);
+        driverFolder.mkdirs();
+
+        final DriverFiles driverFiles = DriverFiles.fromJobSubmission(t, this.filenames);
+        driverFiles.copyTo(driverFolder);
+
+        final Configuration driverConfigurationPart1 = driverFiles
+            .addNamesTo(LocalDriverConfiguration.CONF,
+                LocalDriverConfiguration.GLOBAL_FILES,
+                LocalDriverConfiguration.GLOBAL_LIBRARIES,
+                LocalDriverConfiguration.LOCAL_FILES,
+                LocalDriverConfiguration.LOCAL_LIBRARIES)
+            .set(LocalDriverConfiguration.NUMBER_OF_PROCESSES, this.nThreads)
+            .set(LocalDriverConfiguration.ROOT_FOLDER, jobFolder.getAbsolutePath())
+            .set(LocalDriverConfiguration.JVM_HEAP_SLACK, this.jvmHeapSlack)
+            .build();
+
+        final Configuration driverConfigurationPart2 = new LocalDriverRuntimeConfiguration()
+            .addClientConfiguration(this.configurationSerializer.fromString(t.getConfiguration()))
+            .setClientRemoteIdentifier(t.getRemoteId())
+            .setJobIdentifier(t.getIdentifier()).build();
+
+        final Configuration driverConfiguration = Tang.Factory.getTang()
+            .newConfigurationBuilder(driverConfigurationPart1, driverConfigurationPart2).build();
+        final File runtimeConfigurationFile = new File(driverFolder, this.filenames.getDriverConfigurationPath());
+        this.configurationSerializer.toFile(driverConfiguration, runtimeConfigurationFile);
+
+        final List<String> command = new JavaLaunchCommandBuilder()
+            .setErrorHandlerRID(t.getRemoteId())
+            .setLaunchID(t.getIdentifier())
+            .setConfigurationFileName(this.filenames.getDriverConfigurationPath())
+            .setClassPath(this.classpath.getDriverClasspath())
+            .setMemory(DRIVER_MEMORY)
+            .build();
+
+        if (LOG.isLoggable(Level.FINEST)) {
+          LOG.log(Level.FINEST, "REEF app command: {0}", StringUtils.join(command, ' '));
+        }
+
+        final RunnableProcess process = new RunnableProcess(command,
+            "driver",
+            driverFolder,
+            new LoggingRunnableProcessObserver(),
+            this.filenames.getDriverStdoutFileName(),
+            this.filenames.getDriverStderrFileName());
+        this.executor.submit(process);
+        this.executor.shutdown();
+
+      } catch (final Exception e) {
+        LOG.log(Level.SEVERE, "Unable to setup driver.", e);
+        throw new RuntimeException("Unable to setup driver.", e);
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/LocalRuntimeConfiguration.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/LocalRuntimeConfiguration.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/LocalRuntimeConfiguration.java
new file mode 100644
index 0000000..fe7f104
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/LocalRuntimeConfiguration.java
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.client;
+
+import org.apache.reef.client.REEF;
+import org.apache.reef.client.RunningJob;
+import org.apache.reef.runtime.common.client.REEFImplementation;
+import org.apache.reef.runtime.common.client.RunningJobImpl;
+import org.apache.reef.runtime.common.client.api.JobSubmissionHandler;
+import org.apache.reef.runtime.common.files.RuntimeClasspathProvider;
+import org.apache.reef.runtime.common.launch.REEFMessageCodec;
+import org.apache.reef.runtime.common.parameters.JVMHeapSlack;
+import org.apache.reef.runtime.local.LocalClasspathProvider;
+import org.apache.reef.runtime.local.client.parameters.NumberOfProcesses;
+import org.apache.reef.runtime.local.client.parameters.RootFolder;
+import org.apache.reef.tang.formats.ConfigurationModule;
+import org.apache.reef.tang.formats.ConfigurationModuleBuilder;
+import org.apache.reef.tang.formats.OptionalParameter;
+import org.apache.reef.wake.remote.RemoteConfiguration;
+
+import java.util.concurrent.ExecutorService;
+
+/**
+ * A ConfigurationModule to configure the local resourcemanager.
+ */
+public class LocalRuntimeConfiguration extends ConfigurationModuleBuilder {
+
+  /**
+   * The number of threads or processes available to the resourcemanager. This is the upper limit on the number of
+   * Evaluators that the local resourcemanager will hand out concurrently. This simulates the size of a physical cluster in
+   * terms of the number of slots available on it with one important caveat: The Driver is not counted against this
+   * number.
+   */
+  public static final OptionalParameter<Integer> NUMBER_OF_THREADS = new OptionalParameter<>();
+  /**
+   * The folder in which the sub-folders, one per Node, will be created. Those will contain one folder per
+   * Evaluator instantiated on the virtual node. Those inner folders will be named by the time when the Evaluator was
+   * launched.
+   * <p/>
+   * If none is given, a folder "REEF_LOCAL_RUNTIME" will be created in the local directory.
+   */
+  public static final OptionalParameter<String> RUNTIME_ROOT_FOLDER = new OptionalParameter<>();
+
+  /**
+   * The fraction of the container memory NOT to use for the Java Heap.
+   */
+  public static final OptionalParameter<Double> JVM_HEAP_SLACK = new OptionalParameter<>();
+
+  /**
+   * The ConfigurationModule for the local resourcemanager.
+   */
+  public static final ConfigurationModule CONF = new LocalRuntimeConfiguration()
+      .bindImplementation(REEF.class, REEFImplementation.class)
+      .bindImplementation(RunningJob.class, RunningJobImpl.class)
+      .bindImplementation(JobSubmissionHandler.class, LocalJobSubmissionHandler.class)
+      .bindConstructor(ExecutorService.class, ExecutorServiceConstructor.class)
+          // Bind the message codec for REEF.
+      .bindNamedParameter(RemoteConfiguration.MessageCodec.class, REEFMessageCodec.class)
+      .bindNamedParameter(NumberOfProcesses.class, NUMBER_OF_THREADS)
+      .bindNamedParameter(RootFolder.class, RUNTIME_ROOT_FOLDER)
+      .bindNamedParameter(JVMHeapSlack.class, JVM_HEAP_SLACK)
+      .bindImplementation(RuntimeClasspathProvider.class, LocalClasspathProvider.class)
+      .build();
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/package-info.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/package-info.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/package-info.java
new file mode 100644
index 0000000..6665204
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/package-info.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * client-side event handlers for the local resourcemanager
+ */
+package org.apache.reef.runtime.local.client;

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/DefaultMemorySize.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/DefaultMemorySize.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/DefaultMemorySize.java
new file mode 100644
index 0000000..410723b
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/DefaultMemorySize.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.client.parameters;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+/**
+ * The size of the default container returned in MB.
+ */
+@NamedParameter(doc = "The size of the default container returned in MB", default_value = "512")
+public class DefaultMemorySize implements Name<Integer> {
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/DefaultNumberOfCores.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/DefaultNumberOfCores.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/DefaultNumberOfCores.java
new file mode 100644
index 0000000..a57a067
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/DefaultNumberOfCores.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.client.parameters;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+/**
+ * The number of the default core.
+ */
+@NamedParameter(doc = "The number of the default core", default_value = "1")
+public class DefaultNumberOfCores implements Name<Integer> {
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/NumberOfProcesses.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/NumberOfProcesses.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/NumberOfProcesses.java
new file mode 100644
index 0000000..be0e5d4
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/NumberOfProcesses.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.client.parameters;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+/**
+ * The maximum number of processes to use at once
+ */
+@NamedParameter(default_value = "4", doc = "The maximum number of processes to use at once", short_name = "nThreads")
+public final class NumberOfProcesses implements Name<Integer> {
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/RootFolder.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/RootFolder.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/RootFolder.java
new file mode 100644
index 0000000..710e737
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/RootFolder.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.client.parameters;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+/**
+ * The folder where logs etc. shall be stored.
+ */
+@NamedParameter(default_value = RootFolder.DEFAULT_VALUE, doc = "The folder where logs etc. shall be stored.")
+public class RootFolder implements Name<String> {
+  public static final String DEFAULT_VALUE = "REEF_LOCAL_RUNTIME";
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/package-info.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/package-info.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/package-info.java
new file mode 100644
index 0000000..ec18095
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/client/parameters/package-info.java
@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Parameters of the local runtime.
+ */
+package org.apache.reef.runtime.local.client.parameters;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/Container.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/Container.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/Container.java
new file mode 100644
index 0000000..602575b
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/Container.java
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.driver;
+
+import org.apache.reef.annotations.audience.Private;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Represents a Container: A slice of a machine.
+ * <p/>
+ * In the case of the local resourcemanager, this slice is always the one of the machine where the job was submitted.
+ */
+@Private
+interface Container extends AutoCloseable {
+
+  /**
+   * Run the given commandLine in the container.
+   *
+   * @param commandLine the command line to execute. It will typically be joined by spaces to form the command line.
+   */
+  public void run(final List<String> commandLine);
+
+  /**
+   * Copies the files to the working directory of the container.
+   *
+   * @param files the files to be added to the container.
+   */
+  public void addLocalFiles(final Iterable<File> files);
+
+  public void addGlobalFiles(final File globalFolder);
+
+  /**
+   * @return true if the Container is currently executing, false otherwise.
+   */
+  public boolean isRunning();
+
+  /**
+   * @return the ID of the node this Container is executing on.
+   */
+  public String getNodeID();
+
+  /**
+   * @return the ID of this Container.
+   */
+  public String getContainerID();
+
+  /**
+   * @return the main memory available to the Container.
+   */
+  public int getMemory();
+
+  /**
+   * @return the core available to the Container.
+   */
+  public int getNumberOfCores();
+
+  /**
+   * @return the working directory of the Container.
+   */
+  public File getFolder();
+
+  /**
+   * Kills the Container.
+   */
+  @Override
+  public void close();
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/ContainerManager.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/ContainerManager.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/ContainerManager.java
new file mode 100644
index 0000000..11fb21c
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/ContainerManager.java
@@ -0,0 +1,202 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.driver;
+
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Private;
+import org.apache.reef.client.FailedRuntime;
+import org.apache.reef.proto.DriverRuntimeProtocol;
+import org.apache.reef.proto.ReefServiceProtos;
+import org.apache.reef.runtime.common.driver.api.RuntimeParameters;
+import org.apache.reef.runtime.common.files.REEFFileNames;
+import org.apache.reef.runtime.common.utils.RemoteManager;
+import org.apache.reef.runtime.local.client.parameters.NumberOfProcesses;
+import org.apache.reef.runtime.local.client.parameters.RootFolder;
+import org.apache.reef.runtime.local.process.ReefRunnableProcessObserver;
+import org.apache.reef.tang.annotations.Parameter;
+import org.apache.reef.wake.EventHandler;
+import org.apache.reef.wake.remote.NetUtils;
+import org.apache.reef.wake.remote.RemoteMessage;
+import org.apache.reef.wake.time.Time;
+import org.apache.reef.wake.time.runtime.RuntimeClock;
+import org.apache.reef.wake.time.runtime.event.RuntimeStart;
+import org.apache.reef.wake.time.runtime.event.RuntimeStop;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Manages a set of Containers that each reference a Thread.
+ */
+@Private
+@DriverSide
+final class ContainerManager implements AutoCloseable {
+
+  private final static Logger LOG = Logger.getLogger(ContainerManager.class.getName());
+
+  /**
+   * Map from containerID -> Container
+   */
+  private final Map<String, Container> containers = new HashMap<>();
+
+  /**
+   * List of free, unallocated nodes by their Node ID
+   */
+  private final List<String> freeNodeList = new LinkedList<>();
+
+  private final String errorHandlerRID;
+  private final int capacity;
+  private final EventHandler<DriverRuntimeProtocol.NodeDescriptorProto> nodeDescriptorHandler;
+  private final File rootFolder;
+  private final REEFFileNames fileNames;
+  private final ReefRunnableProcessObserver processObserver;
+
+  @Inject
+  ContainerManager(
+      final RemoteManager remoteManager,
+      final RuntimeClock clock,
+      final REEFFileNames fileNames,
+      final @Parameter(NumberOfProcesses.class) int capacity,
+      final @Parameter(RootFolder.class) String rootFolderName,
+      final @Parameter(RuntimeParameters.NodeDescriptorHandler.class)
+      EventHandler<DriverRuntimeProtocol.NodeDescriptorProto> nodeDescriptorHandler,
+      final ReefRunnableProcessObserver processObserver) {
+
+    this.capacity = capacity;
+    this.fileNames = fileNames;
+    this.processObserver = processObserver;
+    this.errorHandlerRID = remoteManager.getMyIdentifier();
+    this.nodeDescriptorHandler = nodeDescriptorHandler;
+    this.rootFolder = new File(rootFolderName);
+
+    LOG.log(Level.FINEST, "Initializing Container Manager with {0} containers", capacity);
+
+    remoteManager.registerHandler(ReefServiceProtos.RuntimeErrorProto.class, new EventHandler<RemoteMessage<ReefServiceProtos.RuntimeErrorProto>>() {
+      @Override
+      public void onNext(final RemoteMessage<ReefServiceProtos.RuntimeErrorProto> value) {
+        final FailedRuntime error = new FailedRuntime(value.getMessage());
+        LOG.log(Level.SEVERE, "FailedRuntime: " + error, error.getReason().orElse(null));
+        release(error.getId());
+      }
+    });
+    clock.registerEventHandler(RuntimeStart.class, new EventHandler<Time>() {
+      @Override
+      public void onNext(final Time value) {
+        synchronized (ContainerManager.this) {
+          ContainerManager.this.sendNodeDescriptors();
+        }
+      }
+    });
+
+    clock.registerEventHandler(RuntimeStop.class, new EventHandler<Time>() {
+      @Override
+      public void onNext(final Time value) {
+        synchronized (ContainerManager.this) {
+          LOG.log(Level.FINEST, "RuntimeStop: close the container manager");
+          ContainerManager.this.close();
+        }
+      }
+    });
+
+    LOG.log(Level.FINE, "Initialized Container Manager with {0} containers", capacity);
+  }
+
+  private void sendNodeDescriptors() {
+    final IDMaker idmaker = new IDMaker("Node-");
+    for (int i = 0; i < capacity; i++) {
+      final String id = idmaker.getNextID();
+      this.freeNodeList.add(id);
+      nodeDescriptorHandler.onNext(DriverRuntimeProtocol.NodeDescriptorProto.newBuilder()
+          .setIdentifier(id)
+          .setRackName("/default-rack")
+          .setHostName(NetUtils.getLocalAddress())
+          .setPort(i)
+          .setMemorySize(512) // TODO: Find the actual system memory on this machine.
+          .build());
+    }
+  }
+
+  final boolean hasContainerAvailable() {
+    return this.freeNodeList.size() > 0;
+  }
+
+  final Container allocateOne(final int megaBytes, final int numberOfCores) {
+    synchronized (this.containers) {
+      final String nodeId = this.freeNodeList.remove(0);
+      final String processID = nodeId + "-" + String.valueOf(System.currentTimeMillis());
+      final File processFolder = new File(this.rootFolder, processID);
+      processFolder.mkdirs();
+      final ProcessContainer container = new ProcessContainer(
+          this.errorHandlerRID, nodeId, processID, processFolder, megaBytes, numberOfCores, this.fileNames, this.processObserver);
+      this.containers.put(container.getContainerID(), container);
+      LOG.log(Level.FINE, "Allocated {0}", container.getContainerID());
+      return container;
+    }
+  }
+
+  final void release(final String containerID) {
+    synchronized (this.containers) {
+      final Container ctr = this.containers.get(containerID);
+      if (null != ctr) {
+        LOG.log(Level.INFO, "Releasing Container with containerId [{0}]", ctr);
+        if (ctr.isRunning()) {
+          ctr.close();
+        }
+        this.freeNodeList.add(ctr.getNodeID());
+        this.containers.remove(ctr.getContainerID());
+      } else {
+        LOG.log(Level.INFO, "Ignoring release request for unknown containerID [{0}]", containerID);
+      }
+    }
+  }
+
+  final Container get(final String containedID) {
+    synchronized (this.containers) {
+      return this.containers.get(containedID);
+    }
+  }
+
+  /**
+   * @return a List of the IDs of currently allocated Containers.
+   */
+  final Iterable<String> getAllocatedContainerIDs() {
+    return this.containers.keySet();
+  }
+
+  @Override
+  public void close() {
+    synchronized (this.containers) {
+      if (this.containers.isEmpty()) {
+        LOG.log(Level.FINEST, "Clean shutdown with no outstanding containers.");
+      } else {
+        LOG.log(Level.WARNING, "Dirty shutdown with outstanding containers.");
+        for (final Container c : this.containers.values()) {
+          LOG.log(Level.WARNING, "Force shutdown of: {0}", c);
+          c.close();
+        }
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/IDMaker.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/IDMaker.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/IDMaker.java
new file mode 100644
index 0000000..3bd1d09
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/IDMaker.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.driver;
+
+
+/**
+ * Generates unique IDs.
+ */
+public final class IDMaker {
+
+  private final String prefix;
+  private int counter = 0;
+
+  /**
+   * The ids generated by getNextID are of the form "prefixNUMBER", where
+   * number is counted up.
+   *
+   * @param prefix a prefix to be used for the IDs generated.
+   */
+  public IDMaker(final String prefix) {
+    this.prefix = prefix;
+  }
+
+  /**
+   * @return the next ID
+   */
+  public final String getNextID() {
+    this.counter += 1;
+    return this.prefix + this.counter;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalDriverConfiguration.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalDriverConfiguration.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalDriverConfiguration.java
new file mode 100644
index 0000000..c6a6206
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalDriverConfiguration.java
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.driver;
+
+import org.apache.reef.runtime.common.files.RuntimeClasspathProvider;
+import org.apache.reef.runtime.common.parameters.JVMHeapSlack;
+import org.apache.reef.runtime.local.LocalClasspathProvider;
+import org.apache.reef.runtime.local.client.parameters.NumberOfProcesses;
+import org.apache.reef.runtime.local.client.parameters.RootFolder;
+import org.apache.reef.runtime.local.driver.parameters.GlobalFiles;
+import org.apache.reef.runtime.local.driver.parameters.GlobalLibraries;
+import org.apache.reef.runtime.local.driver.parameters.LocalFiles;
+import org.apache.reef.runtime.local.driver.parameters.LocalLibraries;
+import org.apache.reef.tang.formats.ConfigurationModule;
+import org.apache.reef.tang.formats.ConfigurationModuleBuilder;
+import org.apache.reef.tang.formats.OptionalParameter;
+import org.apache.reef.tang.formats.RequiredParameter;
+
+/**
+ * ConfigurationModule for the Driver executed in the local resourcemanager. This is meant to eventually replace
+ * LocalDriverRuntimeConfiguration.
+ */
+public class LocalDriverConfiguration extends ConfigurationModuleBuilder {
+
+  /**
+   * Files for the driver only.
+   */
+  public static final OptionalParameter<String> LOCAL_FILES = new OptionalParameter<>();
+  /**
+   * Libraries for the driver only.
+   */
+  public static final OptionalParameter<String> LOCAL_LIBRARIES = new OptionalParameter<>();
+  /**
+   * Files for the driver and all evaluators.
+   */
+  public static final OptionalParameter<String> GLOBAL_FILES = new OptionalParameter<>();
+  /**
+   * Libraries for the driver and all evaluators.
+   */
+  public static final OptionalParameter<String> GLOBAL_LIBRARIES = new OptionalParameter<>();
+  /**
+   * The maximum number or processes to spawn.
+   */
+  public static final RequiredParameter<Integer> NUMBER_OF_PROCESSES = new RequiredParameter<>();
+  /**
+   * The root folder of the job. Assumed to be an absolute path.
+   */
+  public static final RequiredParameter<String> ROOT_FOLDER = new RequiredParameter<>();
+  /**
+   * The fraction of the container memory NOT to use for the Java Heap.
+   */
+  public static final OptionalParameter<Double> JVM_HEAP_SLACK = new OptionalParameter<>();
+
+
+  public static final ConfigurationModule CONF = new LocalDriverConfiguration()
+      .bindSetEntry(LocalFiles.class, LOCAL_FILES)
+      .bindSetEntry(LocalLibraries.class, LOCAL_LIBRARIES)
+      .bindSetEntry(GlobalFiles.class, GLOBAL_FILES)
+      .bindSetEntry(GlobalLibraries.class, GLOBAL_LIBRARIES)
+      .bindNamedParameter(NumberOfProcesses.class, NUMBER_OF_PROCESSES)
+      .bindNamedParameter(RootFolder.class, ROOT_FOLDER)
+      .bindNamedParameter(JVMHeapSlack.class, JVM_HEAP_SLACK)
+      .bindImplementation(RuntimeClasspathProvider.class, LocalClasspathProvider.class)
+      .build();
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalDriverRuntimeConfiguration.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalDriverRuntimeConfiguration.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalDriverRuntimeConfiguration.java
new file mode 100644
index 0000000..52bd622
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalDriverRuntimeConfiguration.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.driver;
+
+import org.apache.reef.runtime.common.driver.api.AbstractDriverRuntimeConfiguration;
+
+import javax.inject.Inject;
+
+public class LocalDriverRuntimeConfiguration extends AbstractDriverRuntimeConfiguration {
+  @Inject
+  public LocalDriverRuntimeConfiguration() {
+    super(LocalResourceLaunchHandler.class, LocalResourceReleaseHandler.class, LocalResourceRequestHandler.class);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalResourceLaunchHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalResourceLaunchHandler.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalResourceLaunchHandler.java
new file mode 100644
index 0000000..be3ead8
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalResourceLaunchHandler.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.driver;
+
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Private;
+import org.apache.reef.proto.DriverRuntimeProtocol;
+import org.apache.reef.runtime.common.driver.api.ResourceLaunchHandler;
+
+import javax.inject.Inject;
+
+/**
+ * Takes resource launch events and patches them through to the ResourceManager.
+ */
+@Private
+@DriverSide
+final class LocalResourceLaunchHandler implements ResourceLaunchHandler {
+
+  private final ResourceManager resourceManager;
+
+  @Inject
+  public LocalResourceLaunchHandler(final ResourceManager resourceManager) {
+    this.resourceManager = resourceManager;
+  }
+
+  @Override
+  public void onNext(final DriverRuntimeProtocol.ResourceLaunchProto t) {
+    this.resourceManager.onResourceLaunchRequest(t);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalResourceReleaseHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalResourceReleaseHandler.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalResourceReleaseHandler.java
new file mode 100644
index 0000000..04c2730
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalResourceReleaseHandler.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.driver;
+
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Private;
+import org.apache.reef.proto.DriverRuntimeProtocol;
+import org.apache.reef.runtime.common.driver.api.ResourceReleaseHandler;
+
+import javax.inject.Inject;
+
+/**
+ * Takes Resource Release requests and patches them through to the resource
+ * manager.
+ */
+@Private
+@DriverSide
+public final class LocalResourceReleaseHandler implements ResourceReleaseHandler {
+
+  private ResourceManager resourceManager;
+
+  @Inject
+  LocalResourceReleaseHandler(final ResourceManager resourceManager) {
+    this.resourceManager = resourceManager;
+  }
+
+  @Override
+  public void onNext(final DriverRuntimeProtocol.ResourceReleaseProto t) {
+    this.resourceManager.onResourceReleaseRequest(t);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalResourceRequestHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalResourceRequestHandler.java b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalResourceRequestHandler.java
new file mode 100644
index 0000000..a08b05c
--- /dev/null
+++ b/lang/java/reef-runtime-local/src/main/java/org/apache/reef/runtime/local/driver/LocalResourceRequestHandler.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.reef.runtime.local.driver;
+
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Private;
+import org.apache.reef.proto.DriverRuntimeProtocol;
+import org.apache.reef.runtime.common.driver.api.ResourceRequestHandler;
+
+import javax.inject.Inject;
+
+/**
+ * Takes resource requests and patches them through to the ResourceManager
+ */
+@Private
+@DriverSide
+final class LocalResourceRequestHandler implements ResourceRequestHandler {
+
+  private final ResourceManager resourceManager;
+
+  @Inject
+  LocalResourceRequestHandler(final ResourceManager resourceManager) {
+    this.resourceManager = resourceManager;
+  }
+
+  @Override
+  public void onNext(final DriverRuntimeProtocol.ResourceRequestProto t) {
+    this.resourceManager.onResourceRequest(t);
+  }
+}