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 2014/10/23 02:03:54 UTC

[23/51] [abbrv] [partial] Initial merge of Wake, Tang and REEF into one repository and project

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/util/Optional.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/util/Optional.java b/reef-common/src/main/java/org/apache/reef/util/Optional.java
new file mode 100644
index 0000000..365ff3f
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/util/Optional.java
@@ -0,0 +1,125 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * Licensed 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.util;
+
+import net.jcip.annotations.Immutable;
+import net.jcip.annotations.ThreadSafe;
+
+import java.io.Serializable;
+
+/**
+ * Represents an optional value. Loosely based on
+ * <a href="http://download.java.net/jdk8/docs/api/java/util/Optional.html"></a>The Java 8 version</a>, but filtered for
+ * Java 7 compatibility.
+ */
+@Immutable
+@ThreadSafe
+public final class Optional<T> implements Serializable {
+
+  private static final long serialVersionUID = 42L;
+
+  private final T value;
+  private final String valueStr;
+  private final int valueHash;
+
+  private Optional(final T value) {
+    this.value = value;
+    this.valueStr = "Optional:{" + value + '}';
+    this.valueHash = value.hashCode();
+  }
+
+  private Optional() {
+    this.value = null;
+    this.valueStr = "OptionalvNothing";
+    this.valueHash = 0;
+  }
+
+  /**
+   * @return An Optional with the given value.
+   * @throws NullPointerException if the value is null
+   */
+  public static <T> Optional<T> of(final T value) throws NullPointerException {
+    if (null == value) {
+      throw new NullPointerException("Passed a null value. Use ofNullable() instead");
+    }
+    return new Optional<>(value);
+  }
+
+  /**
+   * @return an Optional with no value.
+   */
+  public static <T> Optional<T> empty() {
+    return new Optional<>();
+  }
+
+  /**
+   * @return An optional representing the given value, or an empty Optional.
+   */
+  public static <T> Optional<T> ofNullable(final T value) {
+    if (null == value) {
+      return Optional.empty();
+    } else {
+      return Optional.of(value);
+    }
+  }
+
+  /**
+   * @return the value represented or null, if isPresent() is false.
+   */
+  public T get() {
+    return this.value;
+  }
+
+  /**
+   * @param other
+   * @return the value of this Optional or other, if no value exists.
+   */
+  public T orElse(final T other) {
+    if (isPresent()) {
+      return this.get();
+    } else {
+      return other;
+    }
+  }
+
+  /**
+   * @return true if there is a value, false otherwise.
+   */
+  public boolean isPresent() {
+    return null != this.value;
+  }
+
+  @Override
+  public boolean equals(final Object obj) {
+
+    if (this == obj) return true;
+
+    if (obj == null || getClass() != obj.getClass()) return false;
+
+    final Optional that = (Optional) obj;
+    return this.value == that.value || (this.value != null && this.value.equals(that.value));
+  }
+
+  @Override
+  public int hashCode() {
+    return this.valueHash;
+  }
+
+  @Override
+  public String toString() {
+    return this.valueStr;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/util/SetOnce.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/util/SetOnce.java b/reef-common/src/main/java/org/apache/reef/util/SetOnce.java
new file mode 100644
index 0000000..283988b
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/util/SetOnce.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * Licensed 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.util;
+
+/**
+ * A reference to a value that can be set exactly once.
+ */
+public final class SetOnce<T> {
+
+  private Optional<T> value;
+
+  public SetOnce(final T value) {
+    this.set(value);
+  }
+
+  public SetOnce() {
+    this.value = Optional.empty();
+  }
+
+  public synchronized T get() {
+    return value.get();
+  }
+
+  public synchronized void set(final T value) {
+    if (this.value.isPresent()) {
+      throw new IllegalStateException("Trying to set new value " + value +
+          " while an old value was already present: " + this.value);
+    }
+    this.value = Optional.of(value);
+  }
+
+  public synchronized boolean isSet() {
+    return this.value.isPresent();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/util/SingletonAsserter.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/util/SingletonAsserter.java b/reef-common/src/main/java/org/apache/reef/util/SingletonAsserter.java
new file mode 100644
index 0000000..4046560
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/util/SingletonAsserter.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * Licensed 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.util;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A helper class that can be used to ensure that objects are only instantiated once.
+ */
+public final class SingletonAsserter {
+
+  private static final Set<Class> classes = Collections.synchronizedSet(new HashSet<Class>());
+
+  /**
+   * This class operates purely in static mode.
+   */
+  private SingletonAsserter() {
+  }
+
+  public static boolean assertSingleton(final Class clazz) {
+    return classes.add(clazz);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/util/logging/Config.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/util/logging/Config.java b/reef-common/src/main/java/org/apache/reef/util/logging/Config.java
new file mode 100644
index 0000000..6ceddfb
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/util/logging/Config.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * Licensed 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.util.logging;
+
+import java.io.IOException;
+import java.util.logging.LogManager;
+
+public final class Config {
+
+  public Config() throws IOException {
+    LogManager.getLogManager().readConfiguration(
+        Thread.currentThread().getContextClassLoader()
+            .getResourceAsStream("com/microsoft/reef/logging.properties"));
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/util/logging/LoggingSetup.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/util/logging/LoggingSetup.java b/reef-common/src/main/java/org/apache/reef/util/logging/LoggingSetup.java
new file mode 100644
index 0000000..a264a48
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/util/logging/LoggingSetup.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * Licensed 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.util.logging;
+
+/**
+ * Configure Commons Logging
+ */
+public final class LoggingSetup {
+
+  private LoggingSetup() {
+  }
+
+  /**
+   * Redirect the commons logging to the JDK logger.
+   */
+  public static void setupCommonsLogging() {
+    if (System.getProperty("org.apache.commons.logging.Log") == null) {
+      System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/util/logging/ThreadLogFormatter.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/util/logging/ThreadLogFormatter.java b/reef-common/src/main/java/org/apache/reef/util/logging/ThreadLogFormatter.java
new file mode 100644
index 0000000..193be6d
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/util/logging/ThreadLogFormatter.java
@@ -0,0 +1,138 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * Licensed 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.util.logging;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.logging.Formatter;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+
+/**
+ * A denser logging format for REEF that is similar to the standard SimpleFormatter.
+ * <p/>
+ * The following config properties are available:
+ * <p/>
+ * * `org.apache.reef.util.logging.ThreadLogFormatter.format`
+ * is a format string for String.format() that takes same arguments and in
+ * the same order as the standard SimpleFormatter, plus the thread name:
+ * 1. date
+ * 2. class and method name
+ * 3. logger name
+ * 4. logging level
+ * 5. message
+ * 6. stack trace
+ * 7. thread name
+ * <p/>
+ * * `org.apache.reef.util.logging.ThreadLogFormatter.dropPrefix`
+ * contains a comma-separated list of package name prefixes that should be
+ * removed from the class name for logging. e.g. value `com.microsoft.,org.apache.`
+ * will have the formatter write class `org.apache.reef.util.logging.Config` as
+ * `reef.util.logging.Config`. (Note the dot at the end of the prefix).
+ */
+public final class ThreadLogFormatter extends Formatter {
+
+  private static final String DEFAULT_FORMAT = "%1$tF %1$tT,%1$tL %4$s %2$s %7$s | %5$s%6$s%n";
+
+  private final List<String> dropPrefix = new ArrayList<>();
+  private final Date date = new Date();
+  private final String logFormat;
+
+  public ThreadLogFormatter() {
+
+    super();
+    final LogManager logManager = LogManager.getLogManager();
+    final String className = this.getClass().getName();
+
+    final String format = logManager.getProperty(className + ".format");
+    this.logFormat = format != null ? format : DEFAULT_FORMAT;
+
+    final String rawDropStr = logManager.getProperty(className + ".dropPrefix");
+    if (rawDropStr != null) {
+      for (String prefix : rawDropStr.trim().split(",")) {
+        prefix = prefix.trim();
+        if (!prefix.isEmpty()) {
+          this.dropPrefix.add(prefix);
+        }
+      }
+    }
+  }
+
+  /**
+   * Format the log string. Internally, it uses `String.format()` that takes same
+   * arguments and in the same order as the standard SimpleFormatter, plus the thread name:
+   * 1. date
+   * 2. class and method name
+   * 3. logger name
+   * 4. logging level
+   * 5. message
+   * 6. stack trace
+   * 7. thread name
+   *
+   * @return string to be written to the log.
+   */
+  @Override
+  public String format(final LogRecord logRecord) {
+    this.date.setTime(System.currentTimeMillis());
+    return String.format(
+        this.logFormat,
+        this.date,
+        this.trimPrefix(logRecord.getSourceClassName()) + "." + logRecord.getSourceMethodName(),
+        logRecord.getLoggerName(),
+        logRecord.getLevel().getLocalizedName(),
+        formatMessage(logRecord),
+        this.getStackTrace(logRecord.getThrown()),
+        Thread.currentThread().getName());
+  }
+
+  /**
+   * Check if the class name starts with one of the prefixes specified in `dropPrefix`,
+   * and remove it. e.g. for class name `org.apache.reef.util.logging.Config` and
+   * prefix `com.microsoft.` (note the trailing dot), the result will be
+   * `reef.util.logging.Config`
+   */
+  private String trimPrefix(final String className) {
+    for (final String prefix : this.dropPrefix) {
+      if (className.startsWith(prefix)) {
+        return className.substring(prefix.length());
+      }
+    }
+    return className;
+  }
+
+  /**
+   * @return a string that contains stack trace of a given exception.
+   * if `error` is null, return an empty string.
+   */
+  private String getStackTrace(final Throwable error) {
+    if (error != null) {
+      try (final StringWriter sw = new StringWriter();
+           final PrintWriter pw = new PrintWriter(sw)) {
+        pw.println();
+        error.printStackTrace(pw);
+        return sw.toString();
+      } catch (final IOException ex) {
+        // should never happen
+        throw new RuntimeException("Unexpected error while logging stack trace", ex);
+      }
+    }
+    return "";
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/util/package-info.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/util/package-info.java b/reef-common/src/main/java/org/apache/reef/util/package-info.java
new file mode 100644
index 0000000..5195a45
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/util/package-info.java
@@ -0,0 +1,19 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * Licensed 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.
+ */
+/**
+ * Various utility classes.
+ */
+package org.apache.reef.util;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/proto/client_runtime.proto
----------------------------------------------------------------------
diff --git a/reef-common/src/main/proto/client_runtime.proto b/reef-common/src/main/proto/client_runtime.proto
index 4ad6f0f..94b2f7f 100644
--- a/reef-common/src/main/proto/client_runtime.proto
+++ b/reef-common/src/main/proto/client_runtime.proto
@@ -1,4 +1,4 @@
-option java_package = "com.microsoft.reef.proto";
+option java_package = "org.apache.reef.proto";
 option java_outer_classname = "ClientRuntimeProtocol";
 option java_generic_services = true;
 option java_generate_equals_and_hash = true;

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/proto/driver_runtime.proto
----------------------------------------------------------------------
diff --git a/reef-common/src/main/proto/driver_runtime.proto b/reef-common/src/main/proto/driver_runtime.proto
index 80b8b06..03bfff0 100644
--- a/reef-common/src/main/proto/driver_runtime.proto
+++ b/reef-common/src/main/proto/driver_runtime.proto
@@ -1,4 +1,4 @@
-option java_package = "com.microsoft.reef.proto";
+option java_package = "org.apache.reef.proto";
 option java_outer_classname = "DriverRuntimeProtocol";
 option java_generic_services = true;
 option java_generate_equals_and_hash = true;

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/proto/evaluator_runtime.proto
----------------------------------------------------------------------
diff --git a/reef-common/src/main/proto/evaluator_runtime.proto b/reef-common/src/main/proto/evaluator_runtime.proto
index 79e8c0c..d758a0f 100644
--- a/reef-common/src/main/proto/evaluator_runtime.proto
+++ b/reef-common/src/main/proto/evaluator_runtime.proto
@@ -1,5 +1,5 @@
 
-option java_package = "com.microsoft.reef.proto";
+option java_package = "org.apache.reef.proto";
 option java_outer_classname = "EvaluatorRuntimeProtocol";
 option java_generic_services = true;
 option java_generate_equals_and_hash = true;

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/proto/reef_protocol.proto
----------------------------------------------------------------------
diff --git a/reef-common/src/main/proto/reef_protocol.proto b/reef-common/src/main/proto/reef_protocol.proto
index a84dfbe..687dcca 100644
--- a/reef-common/src/main/proto/reef_protocol.proto
+++ b/reef-common/src/main/proto/reef_protocol.proto
@@ -5,7 +5,7 @@ import "evaluator_runtime.proto";
 import "reef_service_protos.proto";
 
 
-option java_package = "com.microsoft.reef.proto";
+option java_package = "org.apache.reef.proto";
 
 option java_generic_services = true;
 

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/proto/reef_service_protos.proto
----------------------------------------------------------------------
diff --git a/reef-common/src/main/proto/reef_service_protos.proto b/reef-common/src/main/proto/reef_service_protos.proto
index 1830956..6c9a41d 100644
--- a/reef-common/src/main/proto/reef_service_protos.proto
+++ b/reef-common/src/main/proto/reef_service_protos.proto
@@ -1,4 +1,4 @@
-option java_package = "com.microsoft.reef.proto";
+option java_package = "org.apache.reef.proto";
 
 option java_outer_classname = "ReefServiceProtos";
 

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/resources/com/microsoft/reef/logging.properties
----------------------------------------------------------------------
diff --git a/reef-common/src/main/resources/com/microsoft/reef/logging.properties b/reef-common/src/main/resources/com/microsoft/reef/logging.properties
deleted file mode 100644
index 627a783..0000000
--- a/reef-common/src/main/resources/com/microsoft/reef/logging.properties
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# Copyright (C) 2014 Microsoft Corporation
-#
-# Licensed 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.
-#
-
-# Properties file which configures the operation of the JDK
-# logging facility.
-
-# The system will look for this config file, first using
-# a System property specified at startup:
-#
-# >java -Djava.utils.logging.config.file=myLoggingConfigFilePath
-#
-# If this property is not specified, then the config file is
-# retrieved from its default location at:
-#
-# JDK_HOME/jre/lib/logging.properties
-
-# Global logging properties.
-# ------------------------------------------
-# The set of handlers to be loaded upon startup.
-# Comma-separated list of class names.
-# (? LogManager docs say no comma here, but JDK example has comma.)
-# handlers=java.utils.logging.FileHandler, java.utils.logging.ConsoleHandler
-handlers=java.util.logging.ConsoleHandler
-
-# java.util.logging.SimpleFormatter.format=%1$tF %1$tT,%1$tL %4$s %2$s - %5$s%6$s%n
-
-com.microsoft.reef.util.logging.ThreadLogFormatter.format=%1$tF %1$tT,%1$tL %4$s %2$s %7$s | %5$s%6$s%n
-com.microsoft.reef.util.logging.ThreadLogFormatter.dropPrefix=com.microsoft.,org.apache.
-
-# Default global logging level.
-# Loggers and Handlers may override this level
-.level=ALL
-
-# Loggers
-# ------------------------------------------
-# Loggers are usually attached to packages.
-# Here, the level for each package is specified.
-# The global level is used by default, so levels
-# specified here simply act as an override.
-
-# com.microsoft.reef.examples.level=FINEST
-# com.microsoft.tang.level=INFO
-
-# Handlers
-# -----------------------------------------
-
-# --- ConsoleHandler ---
-# Override of global logging level
-java.util.logging.ConsoleHandler.level=FINEST
-java.util.logging.ConsoleHandler.formatter=com.microsoft.reef.util.logging.ThreadLogFormatter
-
-# --- FileHandler ---
-# Override of global logging level
-java.util.logging.FileHandler.level=FINEST
-
-# Naming style for the output file:
-# (The output file is placed in the directory
-# defined by the "user.home" System property.)
-java.util.logging.FileHandler.pattern=%h/reef.%u.log
-
-# Limiting size of output file in bytes:
-java.util.logging.FileHandler.limit=512000
-
-# Number of output files to cycle through, by appending an
-# integer to the base file name:
-java.util.logging.FileHandler.count=100
-
-# Style of output (Simple or XML):
-java.util.logging.FileHandler.formatter=com.microsoft.reef.util.logging.ThreadLogFormatter

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/resources/org/apache/reef/logging.properties
----------------------------------------------------------------------
diff --git a/reef-common/src/main/resources/org/apache/reef/logging.properties b/reef-common/src/main/resources/org/apache/reef/logging.properties
new file mode 100644
index 0000000..80d23a7
--- /dev/null
+++ b/reef-common/src/main/resources/org/apache/reef/logging.properties
@@ -0,0 +1,82 @@
+#
+# Copyright (C) 2014 Microsoft Corporation
+#
+# Licensed 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.
+#
+
+# Properties file which configures the operation of the JDK
+# logging facility.
+
+# The system will look for this config file, first using
+# a System property specified at startup:
+#
+# >java -Djava.utils.logging.config.file=myLoggingConfigFilePath
+#
+# If this property is not specified, then the config file is
+# retrieved from its default location at:
+#
+# JDK_HOME/jre/lib/logging.properties
+
+# Global logging properties.
+# ------------------------------------------
+# The set of handlers to be loaded upon startup.
+# Comma-separated list of class names.
+# (? LogManager docs say no comma here, but JDK example has comma.)
+# handlers=java.utils.logging.FileHandler, java.utils.logging.ConsoleHandler
+handlers=java.util.logging.ConsoleHandler
+
+# java.util.logging.SimpleFormatter.format=%1$tF %1$tT,%1$tL %4$s %2$s - %5$s%6$s%n
+
+org.apache.reef.util.logging.ThreadLogFormatter.format=%1$tF %1$tT,%1$tL %4$s %2$s %7$s | %5$s%6$s%n
+org.apache.reef.util.logging.ThreadLogFormatter.dropPrefix=com.microsoft.,org.apache.
+
+# Default global logging level.
+# Loggers and Handlers may override this level
+.level=ALL
+
+# Loggers
+# ------------------------------------------
+# Loggers are usually attached to packages.
+# Here, the level for each package is specified.
+# The global level is used by default, so levels
+# specified here simply act as an override.
+
+# org.apache.reef.examples.level=FINEST
+# org.apache.reef.tang.level=INFO
+
+# Handlers
+# -----------------------------------------
+
+# --- ConsoleHandler ---
+# Override of global logging level
+java.util.logging.ConsoleHandler.level=FINEST
+java.util.logging.ConsoleHandler.formatter=org.apache.reef.util.logging.ThreadLogFormatter
+
+# --- FileHandler ---
+# Override of global logging level
+java.util.logging.FileHandler.level=FINEST
+
+# Naming style for the output file:
+# (The output file is placed in the directory
+# defined by the "user.home" System property.)
+java.util.logging.FileHandler.pattern=%h/reef.%u.log
+
+# Limiting size of output file in bytes:
+java.util.logging.FileHandler.limit=512000
+
+# Number of output files to cycle through, by appending an
+# integer to the base file name:
+java.util.logging.FileHandler.count=100
+
+# Style of output (Simple or XML):
+java.util.logging.FileHandler.formatter=org.apache.reef.util.logging.ThreadLogFormatter

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/test/java/com/microsoft/reef/runtime/common/driver/EvaluatorRequestorImplTest.java
----------------------------------------------------------------------
diff --git a/reef-common/src/test/java/com/microsoft/reef/runtime/common/driver/EvaluatorRequestorImplTest.java b/reef-common/src/test/java/com/microsoft/reef/runtime/common/driver/EvaluatorRequestorImplTest.java
deleted file mode 100644
index 87cb367..0000000
--- a/reef-common/src/test/java/com/microsoft/reef/runtime/common/driver/EvaluatorRequestorImplTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * Licensed 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 com.microsoft.reef.runtime.common.driver;
-
-import com.microsoft.reef.driver.catalog.ResourceCatalog;
-import com.microsoft.reef.driver.evaluator.EvaluatorRequest;
-import com.microsoft.reef.driver.evaluator.EvaluatorRequestor;
-import com.microsoft.reef.proto.DriverRuntimeProtocol;
-import com.microsoft.reef.runtime.common.driver.api.ResourceRequestHandler;
-import org.junit.Assert;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-
-/**
- * Tests for EvaluatorRequestorImpl.
- */
-public class EvaluatorRequestorImplTest {
-  private final ResourceCatalog resourceCatalog = mock(ResourceCatalog.class);
-
-  private class DummyRequestHandler implements ResourceRequestHandler {
-    private DriverRuntimeProtocol.ResourceRequestProto request;
-
-    @Override
-    public void onNext(DriverRuntimeProtocol.ResourceRequestProto resourceRequestProto) {
-      this.request = resourceRequestProto;
-    }
-
-    public DriverRuntimeProtocol.ResourceRequestProto get() {
-      return this.request;
-    }
-  }
-
-  /**
-   * If only memory, no count is given, 1 evaluator should be requested.
-   */
-  @Test
-  public void testMemoryOnly() {
-    final int memory = 777;
-    final DummyRequestHandler requestHandler = new DummyRequestHandler();
-    final EvaluatorRequestor evaluatorRequestor = new EvaluatorRequestorImpl(resourceCatalog, requestHandler);
-    evaluatorRequestor.submit(EvaluatorRequest.newBuilder().setMemory(memory).build());
-    Assert.assertEquals("Memory request did not make it", requestHandler.get().getMemorySize(), memory);
-    Assert.assertEquals("Number of requests did not make it", requestHandler.get().getResourceCount(), 1);
-  }
-
-  /**
-   * Checks whether memory and count make it correctly.
-   */
-  @Test
-  public void testMemoryAndCount() {
-    final int memory = 777;
-    final int count = 9;
-    final DummyRequestHandler requestHandler = new DummyRequestHandler();
-    final EvaluatorRequestor evaluatorRequestor = new EvaluatorRequestorImpl(resourceCatalog, requestHandler);
-    evaluatorRequestor.submit(EvaluatorRequest.newBuilder().setMemory(memory).setNumber(count).build());
-    Assert.assertEquals("Memory request did not make it", requestHandler.get().getMemorySize(), memory);
-    Assert.assertEquals("Number of requests did not make it", requestHandler.get().getResourceCount(), count);
-  }
-
-  /**
-   * Expect an IllegalArgumentException when a non-positive memory amount is passed.
-   */
-  @Test(expected = IllegalArgumentException.class)
-  public void testIllegalMemory() {
-    final int memory = 0;
-    final int count = 1;
-    final DummyRequestHandler requestHandler = new DummyRequestHandler();
-    final EvaluatorRequestor evaluatorRequestor = new EvaluatorRequestorImpl(resourceCatalog, requestHandler);
-    evaluatorRequestor.submit(EvaluatorRequest.newBuilder().setMemory(memory).setNumberOfCores(1).setNumber(count).build());
-  }
-
-  /**
-   * Expect an IllegalArgumentException when a non-positive evaluator count is passed.
-   */
-  @Test(expected = IllegalArgumentException.class)
-  public void testIllegalCount() {
-    final int memory = 128;
-    final int count = 0;
-    final DummyRequestHandler requestHandler = new DummyRequestHandler();
-    final EvaluatorRequestor evaluatorRequestor = new EvaluatorRequestorImpl(resourceCatalog, requestHandler);
-    evaluatorRequestor.submit(EvaluatorRequest.newBuilder().setMemory(memory).setNumberOfCores(1).setNumber(count).build());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/test/java/com/microsoft/reef/runtime/common/driver/catalog/CatalogTest.java
----------------------------------------------------------------------
diff --git a/reef-common/src/test/java/com/microsoft/reef/runtime/common/driver/catalog/CatalogTest.java b/reef-common/src/test/java/com/microsoft/reef/runtime/common/driver/catalog/CatalogTest.java
deleted file mode 100644
index 0590f50..0000000
--- a/reef-common/src/test/java/com/microsoft/reef/runtime/common/driver/catalog/CatalogTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * Licensed 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 com.microsoft.reef.runtime.common.driver.catalog;
-
-import com.microsoft.reef.proto.DriverRuntimeProtocol;
-import org.junit.Assert;
-import org.junit.Test;
-
-public final class CatalogTest {
-
-
-  /**
-   * Basic catalog test that addes some nodes and checks
-   * that they exist.
-   */
-  @Test
-  public final void TestResourceCatalog() {
-    final int nodes = 10;
-    final ResourceCatalogImpl catalog = new ResourceCatalogImpl();
-
-    for (int i = 0; i < nodes; i++) {
-      catalog.handle(DriverRuntimeProtocol.NodeDescriptorProto.newBuilder()
-          .setRackName("test-rack")
-          .setHostName("test-" + i)
-          .setPort(0)
-          .setIdentifier("test-" + i)
-          .setMemorySize(512)
-          .build());
-    }
-
-    for (int i = 0; i < nodes; i++) {
-      Assert.assertNotNull(catalog.getNode("test-" + i));
-    }
-
-    Assert.assertTrue(catalog.getRacks().size() == 1);
-
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/test/java/com/microsoft/reef/util/OptionalTest.java
----------------------------------------------------------------------
diff --git a/reef-common/src/test/java/com/microsoft/reef/util/OptionalTest.java b/reef-common/src/test/java/com/microsoft/reef/util/OptionalTest.java
deleted file mode 100644
index ebe05aa..0000000
--- a/reef-common/src/test/java/com/microsoft/reef/util/OptionalTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * Licensed 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 com.microsoft.reef.util;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.ArrayList;
-
-/**
- * Tests for Optional.
- */
-public class OptionalTest {
-
-  @Test
-  public void testEmpty() {
-    Assert.assertFalse("An empty Optional should return false to isPresent()",
-        Optional.empty().isPresent());
-  }
-
-  @Test
-  public void testOf() {
-    Assert.assertTrue("Optional.of() needs to return an Optional where isPresent() returns true",
-        Optional.of(2).isPresent());
-  }
-
-  @Test(expected = NullPointerException.class)
-  public void testOfNull() {
-    final Optional<Integer> o = Optional.of(null);
-  }
-
-  @Test
-  public void testOfRandom() {
-    final double value = Math.random();
-    final Optional<Double> o = Optional.of(value);
-    Assert.assertEquals(value, (double) o.get(), 1e-12);
-  }
-
-  @Test
-  public void testOfNullable() {
-    Assert.assertFalse(Optional.ofNullable(null).isPresent());
-    Assert.assertTrue(Optional.ofNullable(1).isPresent());
-    Assert.assertEquals(Optional.ofNullable(1).get(), Integer.valueOf(1));
-  }
-
-  @Test
-  public void testOrElse() {
-    Assert.assertEquals(Optional.empty().orElse(2), 2);
-    Assert.assertEquals(Optional.of(1).orElse(2), Integer.valueOf(1));
-  }
-
-  @Test
-  public void testEquals() {
-    Assert.assertEquals(Optional.empty(), Optional.empty());
-    Assert.assertEquals(Optional.empty(), Optional.ofNullable(null));
-    Assert.assertEquals(Optional.of(1), Optional.of(1));
-    Assert.assertEquals(Optional.of("one"), Optional.of("one"));
-    Assert.assertFalse(Optional.of("one").equals(Optional.of("two")));
-  }
-
-  @Test
-  public void testEqualsCornerCases() {
-
-    // We lose type coercion:
-    Assert.assertFalse(Optional.of(1L).equals(Optional.of(1)));
-    Assert.assertTrue(1L == 1);
-    Assert.assertTrue(new Integer(1) == 1L);
-
-    // .equals() isn't typesafe, so we lose compile-time type checking:
-    Assert.assertFalse(Optional.of(1L).equals(1));
-
-    Assert.assertFalse(Optional.empty().equals(null));
-    Assert.assertFalse(Optional.of(3).equals(3));
-    Assert.assertFalse(Optional.of("one").equals(1));
-
-    // Assert.assertFalse("one" == 1); // incompatible operands; does not compile.
-
-    Assert.assertFalse(Optional.of(new ArrayList<>()).equals(Optional.of(new Object[]{})));
-
-    // Incompatible operands; does not compile, though == between objects is almost always a typo:
-    // Assert.assertFalse(new java.util.ArrayList() == new java.awt.List());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/test/java/com/microsoft/reef/util/SingletonAsserterTest.java
----------------------------------------------------------------------
diff --git a/reef-common/src/test/java/com/microsoft/reef/util/SingletonAsserterTest.java b/reef-common/src/test/java/com/microsoft/reef/util/SingletonAsserterTest.java
deleted file mode 100644
index 51c59d2..0000000
--- a/reef-common/src/test/java/com/microsoft/reef/util/SingletonAsserterTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * Licensed 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 com.microsoft.reef.util;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.List;
-
-public final class SingletonAsserterTest {
-
-  @Test
-  public void testSingletonAsserter() {
-    Assert.assertTrue(SingletonAsserter.assertSingleton(SingletonAsserterTest.class));
-    Assert.assertTrue(SingletonAsserter.assertSingleton(List.class));
-    Assert.assertFalse(SingletonAsserter.assertSingleton(List.class));
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/test/java/org/apache/reef/runtime/common/driver/EvaluatorRequestorImplTest.java
----------------------------------------------------------------------
diff --git a/reef-common/src/test/java/org/apache/reef/runtime/common/driver/EvaluatorRequestorImplTest.java b/reef-common/src/test/java/org/apache/reef/runtime/common/driver/EvaluatorRequestorImplTest.java
new file mode 100644
index 0000000..b3b4237
--- /dev/null
+++ b/reef-common/src/test/java/org/apache/reef/runtime/common/driver/EvaluatorRequestorImplTest.java
@@ -0,0 +1,97 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * Licensed 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.common.driver;
+
+import org.apache.reef.driver.catalog.ResourceCatalog;
+import org.apache.reef.driver.evaluator.EvaluatorRequest;
+import org.apache.reef.driver.evaluator.EvaluatorRequestor;
+import org.apache.reef.proto.DriverRuntimeProtocol;
+import org.apache.reef.runtime.common.driver.api.ResourceRequestHandler;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.mockito.Mockito.mock;
+
+/**
+ * Tests for EvaluatorRequestorImpl.
+ */
+public class EvaluatorRequestorImplTest {
+  private final ResourceCatalog resourceCatalog = mock(ResourceCatalog.class);
+
+  /**
+   * If only memory, no count is given, 1 evaluator should be requested.
+   */
+  @Test
+  public void testMemoryOnly() {
+    final int memory = 777;
+    final DummyRequestHandler requestHandler = new DummyRequestHandler();
+    final EvaluatorRequestor evaluatorRequestor = new EvaluatorRequestorImpl(resourceCatalog, requestHandler);
+    evaluatorRequestor.submit(EvaluatorRequest.newBuilder().setMemory(memory).build());
+    Assert.assertEquals("Memory request did not make it", requestHandler.get().getMemorySize(), memory);
+    Assert.assertEquals("Number of requests did not make it", requestHandler.get().getResourceCount(), 1);
+  }
+
+  /**
+   * Checks whether memory and count make it correctly.
+   */
+  @Test
+  public void testMemoryAndCount() {
+    final int memory = 777;
+    final int count = 9;
+    final DummyRequestHandler requestHandler = new DummyRequestHandler();
+    final EvaluatorRequestor evaluatorRequestor = new EvaluatorRequestorImpl(resourceCatalog, requestHandler);
+    evaluatorRequestor.submit(EvaluatorRequest.newBuilder().setMemory(memory).setNumber(count).build());
+    Assert.assertEquals("Memory request did not make it", requestHandler.get().getMemorySize(), memory);
+    Assert.assertEquals("Number of requests did not make it", requestHandler.get().getResourceCount(), count);
+  }
+
+  /**
+   * Expect an IllegalArgumentException when a non-positive memory amount is passed.
+   */
+  @Test(expected = IllegalArgumentException.class)
+  public void testIllegalMemory() {
+    final int memory = 0;
+    final int count = 1;
+    final DummyRequestHandler requestHandler = new DummyRequestHandler();
+    final EvaluatorRequestor evaluatorRequestor = new EvaluatorRequestorImpl(resourceCatalog, requestHandler);
+    evaluatorRequestor.submit(EvaluatorRequest.newBuilder().setMemory(memory).setNumberOfCores(1).setNumber(count).build());
+  }
+
+  /**
+   * Expect an IllegalArgumentException when a non-positive evaluator count is passed.
+   */
+  @Test(expected = IllegalArgumentException.class)
+  public void testIllegalCount() {
+    final int memory = 128;
+    final int count = 0;
+    final DummyRequestHandler requestHandler = new DummyRequestHandler();
+    final EvaluatorRequestor evaluatorRequestor = new EvaluatorRequestorImpl(resourceCatalog, requestHandler);
+    evaluatorRequestor.submit(EvaluatorRequest.newBuilder().setMemory(memory).setNumberOfCores(1).setNumber(count).build());
+  }
+
+  private class DummyRequestHandler implements ResourceRequestHandler {
+    private DriverRuntimeProtocol.ResourceRequestProto request;
+
+    @Override
+    public void onNext(DriverRuntimeProtocol.ResourceRequestProto resourceRequestProto) {
+      this.request = resourceRequestProto;
+    }
+
+    public DriverRuntimeProtocol.ResourceRequestProto get() {
+      return this.request;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/test/java/org/apache/reef/runtime/common/driver/catalog/CatalogTest.java
----------------------------------------------------------------------
diff --git a/reef-common/src/test/java/org/apache/reef/runtime/common/driver/catalog/CatalogTest.java b/reef-common/src/test/java/org/apache/reef/runtime/common/driver/catalog/CatalogTest.java
new file mode 100644
index 0000000..b5137fe
--- /dev/null
+++ b/reef-common/src/test/java/org/apache/reef/runtime/common/driver/catalog/CatalogTest.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * Licensed 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.common.driver.catalog;
+
+import org.apache.reef.proto.DriverRuntimeProtocol;
+import org.junit.Assert;
+import org.junit.Test;
+
+public final class CatalogTest {
+
+
+  /**
+   * Basic catalog test that addes some nodes and checks
+   * that they exist.
+   */
+  @Test
+  public final void TestResourceCatalog() {
+    final int nodes = 10;
+    final ResourceCatalogImpl catalog = new ResourceCatalogImpl();
+
+    for (int i = 0; i < nodes; i++) {
+      catalog.handle(DriverRuntimeProtocol.NodeDescriptorProto.newBuilder()
+          .setRackName("test-rack")
+          .setHostName("test-" + i)
+          .setPort(0)
+          .setIdentifier("test-" + i)
+          .setMemorySize(512)
+          .build());
+    }
+
+    for (int i = 0; i < nodes; i++) {
+      Assert.assertNotNull(catalog.getNode("test-" + i));
+    }
+
+    Assert.assertTrue(catalog.getRacks().size() == 1);
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/test/java/org/apache/reef/util/OptionalTest.java
----------------------------------------------------------------------
diff --git a/reef-common/src/test/java/org/apache/reef/util/OptionalTest.java b/reef-common/src/test/java/org/apache/reef/util/OptionalTest.java
new file mode 100644
index 0000000..640d6a7
--- /dev/null
+++ b/reef-common/src/test/java/org/apache/reef/util/OptionalTest.java
@@ -0,0 +1,96 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * Licensed 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.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+
+/**
+ * Tests for Optional.
+ */
+public class OptionalTest {
+
+  @Test
+  public void testEmpty() {
+    Assert.assertFalse("An empty Optional should return false to isPresent()",
+        Optional.empty().isPresent());
+  }
+
+  @Test
+  public void testOf() {
+    Assert.assertTrue("Optional.of() needs to return an Optional where isPresent() returns true",
+        Optional.of(2).isPresent());
+  }
+
+  @Test(expected = NullPointerException.class)
+  public void testOfNull() {
+    final Optional<Integer> o = Optional.of(null);
+  }
+
+  @Test
+  public void testOfRandom() {
+    final double value = Math.random();
+    final Optional<Double> o = Optional.of(value);
+    Assert.assertEquals(value, (double) o.get(), 1e-12);
+  }
+
+  @Test
+  public void testOfNullable() {
+    Assert.assertFalse(Optional.ofNullable(null).isPresent());
+    Assert.assertTrue(Optional.ofNullable(1).isPresent());
+    Assert.assertEquals(Optional.ofNullable(1).get(), Integer.valueOf(1));
+  }
+
+  @Test
+  public void testOrElse() {
+    Assert.assertEquals(Optional.empty().orElse(2), 2);
+    Assert.assertEquals(Optional.of(1).orElse(2), Integer.valueOf(1));
+  }
+
+  @Test
+  public void testEquals() {
+    Assert.assertEquals(Optional.empty(), Optional.empty());
+    Assert.assertEquals(Optional.empty(), Optional.ofNullable(null));
+    Assert.assertEquals(Optional.of(1), Optional.of(1));
+    Assert.assertEquals(Optional.of("one"), Optional.of("one"));
+    Assert.assertFalse(Optional.of("one").equals(Optional.of("two")));
+  }
+
+  @Test
+  public void testEqualsCornerCases() {
+
+    // We lose type coercion:
+    Assert.assertFalse(Optional.of(1L).equals(Optional.of(1)));
+    Assert.assertTrue(1L == 1);
+    Assert.assertTrue(new Integer(1) == 1L);
+
+    // .equals() isn't typesafe, so we lose compile-time type checking:
+    Assert.assertFalse(Optional.of(1L).equals(1));
+
+    Assert.assertFalse(Optional.empty().equals(null));
+    Assert.assertFalse(Optional.of(3).equals(3));
+    Assert.assertFalse(Optional.of("one").equals(1));
+
+    // Assert.assertFalse("one" == 1); // incompatible operands; does not compile.
+
+    Assert.assertFalse(Optional.of(new ArrayList<>()).equals(Optional.of(new Object[]{})));
+
+    // Incompatible operands; does not compile, though == between objects is almost always a typo:
+    // Assert.assertFalse(new java.util.ArrayList() == new java.awt.List());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/test/java/org/apache/reef/util/SingletonAsserterTest.java
----------------------------------------------------------------------
diff --git a/reef-common/src/test/java/org/apache/reef/util/SingletonAsserterTest.java b/reef-common/src/test/java/org/apache/reef/util/SingletonAsserterTest.java
new file mode 100644
index 0000000..291c9f8
--- /dev/null
+++ b/reef-common/src/test/java/org/apache/reef/util/SingletonAsserterTest.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright (C) 2014 Microsoft Corporation
+ *
+ * Licensed 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.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.List;
+
+public final class SingletonAsserterTest {
+
+  @Test
+  public void testSingletonAsserter() {
+    Assert.assertTrue(SingletonAsserter.assertSingleton(SingletonAsserterTest.class));
+    Assert.assertTrue(SingletonAsserter.assertSingleton(List.class));
+    Assert.assertFalse(SingletonAsserter.assertSingleton(List.class));
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-examples-clr/pom.xml
----------------------------------------------------------------------
diff --git a/reef-examples-clr/pom.xml b/reef-examples-clr/pom.xml
index c4c4249..4663136 100644
--- a/reef-examples-clr/pom.xml
+++ b/reef-examples-clr/pom.xml
@@ -1,12 +1,13 @@
 <?xml version="1.0"?>
-<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">
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+         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>
     <artifactId>reef-examples-clr</artifactId>
     <name>REEF Examples CLR</name>
     <description>Examples that use the JVM/CLR interop of REEF.</description>
 
     <parent>
-        <groupId>com.microsoft.reef</groupId>
+        <groupId>org.apache.reef</groupId>
         <artifactId>reef-project</artifactId>
         <version>0.10-SNAPSHOT</version>
     </parent>
@@ -39,12 +40,12 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
-            <groupId>com.microsoft.reef</groupId>
+            <groupId>${project.groupId}</groupId>
             <artifactId>reef-webserver</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
-            <groupId>com.microsoft.reef</groupId>
+            <groupId>${project.groupId}</groupId>
             <artifactId>reef-examples</artifactId>
             <version>${project.version}</version>
         </dependency>
@@ -55,7 +56,7 @@
             <optional>true</optional>
         </dependency>
         <dependency>
-        <groupId>junit</groupId>
+            <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
@@ -112,12 +113,12 @@
                             <executable>java</executable>
                             <arguments>
                                 <argument>-classpath</argument>
-                                <classpath />
-                                <argument>-Djava.util.logging.config.class=com.microsoft.reef.util.logging.Config
+                                <classpath/>
+                                <argument>-Djava.util.logging.config.class=org.apache.reef.util.logging.Config
                                 </argument>
                                 <argument>-Dcom.microsoft.reef.runtime.local.folder=${project.build.directory}
                                 </argument>
-                                <argument>com.microsoft.reef.examples.retained_evalCLR.Launch</argument>
+                                <argument>org.apache.reef.examples.retained_evalCLR.Launch</argument>
                                 <argument>dotnetDistributedShell</argument>
                                 <!-- <argument>-cmd</argument>
                                 <argument>date</argument>
@@ -144,13 +145,13 @@
                             <executable>java</executable>
                             <arguments>
                                 <argument>-classpath</argument>
-                                <classpath />
-                                <argument>-Djava.util.logging.config.class=com.microsoft.reef.util.logging.Config
+                                <classpath/>
+                                <argument>-Djava.util.logging.config.class=org.apache.reef.util.logging.Config
                                 </argument>
                                 <!-- <argument>-Dlog4j.debug=true</argument> -->
                                 <argument>-Dcom.microsoft.reef.runtime.local.folder=${project.build.directory}
                                 </argument>
-                                <argument>com.microsoft.reef.examples.helloCLR.HelloCLR</argument>
+                                <argument>org.apache.reef.examples.helloCLR.HelloCLR</argument>
                                 <argument>dotnetHello</argument>
                             </arguments>
                         </configuration>

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-examples-clr/src/main/java/com/microsoft/reef/examples/helloCLR/HelloCLR.java
----------------------------------------------------------------------
diff --git a/reef-examples-clr/src/main/java/com/microsoft/reef/examples/helloCLR/HelloCLR.java b/reef-examples-clr/src/main/java/com/microsoft/reef/examples/helloCLR/HelloCLR.java
deleted file mode 100644
index 3712113..0000000
--- a/reef-examples-clr/src/main/java/com/microsoft/reef/examples/helloCLR/HelloCLR.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * Licensed 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 com.microsoft.reef.examples.helloCLR;
-
-import com.microsoft.reef.client.DriverConfiguration;
-import com.microsoft.reef.client.DriverLauncher;
-import com.microsoft.reef.client.LauncherStatus;
-import com.microsoft.reef.runtime.local.client.LocalRuntimeConfiguration;
-import com.microsoft.reef.util.EnvironmentUtils;
-import com.microsoft.tang.Configuration;
-import com.microsoft.tang.exceptions.BindException;
-import com.microsoft.tang.exceptions.InjectionException;
-import com.microsoft.tang.formats.ConfigurationModule;
-import com.microsoft.tang.formats.OptionalParameter;
-
-import java.io.File;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * The Client for Hello REEF example.
- */
-public final class HelloCLR {
-
-  /**
-   * The name of the class hierarchy file.
-   */
-  // TODO: Make this a config option
-  public static final String CLASS_HIERARCHY_FILENAME = "HelloTask.bin";
-
-  private static final Logger LOG = Logger.getLogger(HelloCLR.class.getName());
-
-  /**
-   * Number of milliseconds to wait for the job to complete.
-   */
-  private static final int JOB_TIMEOUT = 1000000; // 1000 sec.
-
-  private static ConfigurationModule addAll(final ConfigurationModule conf, final OptionalParameter<String> param, final File folder) {
-    ConfigurationModule result = conf;
-    for (final File f : folder.listFiles()) {
-      if (f.canRead() && f.exists() && f.isFile()) {
-        result = result.set(param, f.getAbsolutePath());
-      }
-    }
-    return result;
-  }
-
-  public static LauncherStatus runHelloCLR(final Configuration runtimeConf, final int timeOut, final File clrFolder)
-      throws BindException, InjectionException {
-
-    ConfigurationModule driverConf =
-        addAll(DriverConfiguration.CONF, DriverConfiguration.GLOBAL_FILES, clrFolder)
-            .set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(HelloDriver.class))
-            .set(DriverConfiguration.DRIVER_IDENTIFIER, "HelloCLR")
-            .set(DriverConfiguration.ON_DRIVER_STARTED, HelloDriver.StartHandler.class)
-            .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, HelloDriver.EvaluatorAllocatedHandler.class);
-
-    return DriverLauncher.getLauncher(runtimeConf).run(driverConf.build(), timeOut);
-  }
-
-  /**
-   * Start Hello REEF job. Runs method runHelloReef().
-   *
-   * @param args command line parameters.
-   * @throws com.microsoft.tang.exceptions.BindException      configuration error.
-   * @throws com.microsoft.tang.exceptions.InjectionException configuration error.
-   */
-  public static void main(final String[] args) throws BindException, InjectionException {
-    final Configuration runtimeConfiguration = LocalRuntimeConfiguration.CONF
-        .set(LocalRuntimeConfiguration.NUMBER_OF_THREADS, 2)
-        .build();
-
-    final File dotNetFolder = new File(args[0]).getAbsoluteFile();
-    final LauncherStatus status = runHelloCLR(runtimeConfiguration, JOB_TIMEOUT, dotNetFolder);
-    LOG.log(Level.INFO, "REEF job completed: {0}", status);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-examples-clr/src/main/java/com/microsoft/reef/examples/helloCLR/HelloDriver.java
----------------------------------------------------------------------
diff --git a/reef-examples-clr/src/main/java/com/microsoft/reef/examples/helloCLR/HelloDriver.java b/reef-examples-clr/src/main/java/com/microsoft/reef/examples/helloCLR/HelloDriver.java
deleted file mode 100644
index 5ce5fc0..0000000
--- a/reef-examples-clr/src/main/java/com/microsoft/reef/examples/helloCLR/HelloDriver.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * Licensed 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 com.microsoft.reef.examples.helloCLR;
-
-import com.microsoft.reef.driver.context.ContextConfiguration;
-import com.microsoft.reef.driver.evaluator.AllocatedEvaluator;
-import com.microsoft.reef.driver.evaluator.EvaluatorRequest;
-import com.microsoft.reef.driver.evaluator.EvaluatorRequestor;
-import com.microsoft.reef.driver.evaluator.EvaluatorType;
-import com.microsoft.reef.driver.task.TaskConfiguration;
-import com.microsoft.reef.examples.hello.HelloTask;
-import com.microsoft.tang.ClassHierarchy;
-import com.microsoft.tang.Configuration;
-import com.microsoft.tang.ConfigurationBuilder;
-import com.microsoft.tang.Tang;
-import com.microsoft.tang.annotations.Unit;
-import com.microsoft.tang.exceptions.BindException;
-import com.microsoft.tang.implementation.protobuf.ProtocolBufferClassHierarchy;
-import com.microsoft.tang.proto.ClassHierarchyProto;
-import com.microsoft.wake.EventHandler;
-import com.microsoft.wake.time.event.StartTime;
-
-import javax.inject.Inject;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * The Driver code for the Hello REEF Application
- */
-@Unit
-public final class HelloDriver {
-
-  private static final Logger LOG = Logger.getLogger(HelloDriver.class.getName());
-
-  private final EvaluatorRequestor requestor;
-
-  private int nJVMTasks = 1;  // guarded by this
-  private int nCLRTasks = 1;  // guarded by this
-
-
-  /**
-   * Job driver constructor - instantiated via TANG.
-   *
-   * @param requestor evaluator requestor object used to create new evaluator containers.
-   */
-  @Inject
-  public HelloDriver(final EvaluatorRequestor requestor) {
-    this.requestor = requestor;
-  }
-
-  /**
-   * Handles the StartTime event: Request as single Evaluator.
-   */
-  final class StartHandler implements EventHandler<StartTime> {
-    @Override
-    public void onNext(final StartTime startTime) {
-      LOG.log(Level.INFO, "StartTime: ", startTime);
-      HelloDriver.this.requestor.submit(EvaluatorRequest.newBuilder()
-          .setNumber(nCLRTasks + nJVMTasks)
-          .setMemory(128)
-          .setNumberOfCores(1)
-          .build());
-    }
-  }
-
-  /**
-   * Handles AllocatedEvaluator: Submit an empty context and the HelloTask
-   */
-  final class EvaluatorAllocatedHandler implements EventHandler<AllocatedEvaluator> {
-    @Override
-    public void onNext(final AllocatedEvaluator allocatedEvaluator) {
-      synchronized (HelloDriver.this) {
-        if (HelloDriver.this.nJVMTasks > 0) {
-          HelloDriver.this.onNextJVM(allocatedEvaluator);
-          HelloDriver.this.nJVMTasks -= 1;
-        } else if (HelloDriver.this.nCLRTasks > 0) {
-          HelloDriver.this.onNextCLR(allocatedEvaluator);
-          HelloDriver.this.nCLRTasks -= 1;
-        }
-      }
-    }
-  }
-
-  /**
-   * Uses the AllocatedEvaluator to launch a CLR task.
-   *
-   * @param allocatedEvaluator
-   */
-  final void onNextCLR(final AllocatedEvaluator allocatedEvaluator) {
-    try {
-      allocatedEvaluator.setType(EvaluatorType.CLR);
-      final Configuration contextConfiguration = ContextConfiguration.CONF
-          .set(ContextConfiguration.IDENTIFIER, "HelloREEFContext")
-          .build();
-
-      final Configuration taskConfiguration = getCLRTaskConfiguration("Hello_From_CLR");
-
-      allocatedEvaluator.submitContextAndTask(contextConfiguration, taskConfiguration);
-    } catch (final BindException ex) {
-      final String message = "Unable to setup Task or Context configuration.";
-      LOG.log(Level.SEVERE, message, ex);
-      throw new RuntimeException(message, ex);
-    }
-  }
-
-  /**
-   * Uses the AllocatedEvaluator to launch a JVM task.
-   *
-   * @param allocatedEvaluator
-   */
-  final void onNextJVM(final AllocatedEvaluator allocatedEvaluator) {
-    try {
-      allocatedEvaluator.setType(EvaluatorType.JVM);
-      final Configuration contextConfiguration = ContextConfiguration.CONF
-          .set(ContextConfiguration.IDENTIFIER, "HelloREEFContext")
-          .build();
-
-      final Configuration taskConfiguration = TaskConfiguration.CONF
-          .set(TaskConfiguration.IDENTIFIER, "HelloREEFTask")
-          .set(TaskConfiguration.TASK, HelloTask.class)
-          .build();
-
-      allocatedEvaluator.submitContextAndTask(contextConfiguration, taskConfiguration);
-    } catch (final BindException ex) {
-      final String message = "Unable to setup Task or Context configuration.";
-      LOG.log(Level.SEVERE, message, ex);
-      throw new RuntimeException(message, ex);
-    }
-  }
-
-  /**
-   * Makes a task configuration for the CLR Task.
-   *
-   * @param taskId
-   * @return task configuration for the CLR Task.
-   * @throws BindException
-   */
-  private static final Configuration getCLRTaskConfiguration(final String taskId) throws BindException {
-    final ConfigurationBuilder taskConfigurationBuilder = Tang.Factory.getTang()
-        .newConfigurationBuilder(loadClassHierarchy());
-    taskConfigurationBuilder.bind("Microsoft.Reef.Tasks.TaskConfigurationOptions+Identifier, Microsoft.Reef.Tasks.ITask, Version=1.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca", taskId);
-    taskConfigurationBuilder.bind("Microsoft.Reef.Tasks.ITask, Microsoft.Reef.Tasks.ITask, Version=1.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca", "Microsoft.Reef.Tasks.HelloTask, Microsoft.Reef.Tasks.HelloTask, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
-
-      return taskConfigurationBuilder.build();
-  }
-
-  /**
-   * Loads the class hierarchy.
-   *
-   * @return
-   */
-  private static ClassHierarchy loadClassHierarchy() {
-    try (final InputStream chin = new FileInputStream(HelloCLR.CLASS_HIERARCHY_FILENAME)) {
-      final ClassHierarchyProto.Node root = ClassHierarchyProto.Node.parseFrom(chin); // A
-      final ClassHierarchy ch = new ProtocolBufferClassHierarchy(root);
-      return ch;
-    } catch (final IOException e) {
-      final String message = "Unable to load class hierarchy.";
-      LOG.log(Level.SEVERE, message, e);
-      throw new RuntimeException(message, e);
-    }
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-examples-clr/src/main/java/com/microsoft/reef/examples/helloCLR/package-info.java
----------------------------------------------------------------------
diff --git a/reef-examples-clr/src/main/java/com/microsoft/reef/examples/helloCLR/package-info.java b/reef-examples-clr/src/main/java/com/microsoft/reef/examples/helloCLR/package-info.java
deleted file mode 100644
index f118721..0000000
--- a/reef-examples-clr/src/main/java/com/microsoft/reef/examples/helloCLR/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * Licensed 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.
- */
-/**
- * The Hello REEF example for the CLR.
- */
-package com.microsoft.reef.examples.helloCLR;

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-examples-clr/src/main/java/com/microsoft/reef/examples/retained_evalCLR/JobClient.java
----------------------------------------------------------------------
diff --git a/reef-examples-clr/src/main/java/com/microsoft/reef/examples/retained_evalCLR/JobClient.java b/reef-examples-clr/src/main/java/com/microsoft/reef/examples/retained_evalCLR/JobClient.java
deleted file mode 100644
index 8b605cd..0000000
--- a/reef-examples-clr/src/main/java/com/microsoft/reef/examples/retained_evalCLR/JobClient.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/**
- * Copyright (C) 2014 Microsoft Corporation
- *
- * Licensed 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 com.microsoft.reef.examples.retained_evalCLR;
-
-import com.microsoft.reef.client.*;
-import com.microsoft.reef.util.EnvironmentUtils;
-import com.microsoft.tang.Configuration;
-import com.microsoft.tang.annotations.NamedParameter;
-import com.microsoft.tang.annotations.Parameter;
-import com.microsoft.tang.annotations.Unit;
-import com.microsoft.tang.exceptions.BindException;
-import com.microsoft.tang.formats.ConfigurationModule;
-import com.microsoft.wake.EventHandler;
-import com.microsoft.wake.remote.impl.ObjectSerializableCodec;
-
-import javax.inject.Inject;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Retained Evaluator Shell Client.
- */
-@Unit
-public class JobClient {
-
-  /**
-   * Standard java logger.
-   */
-  private static final Logger LOG = Logger.getLogger(JobClient.class.getName());
-
-  /**
-   * Codec to translate messages to and from the job driver
-   */
-  private static final ObjectSerializableCodec<String> CODEC = new ObjectSerializableCodec<>();
-
-  /**
-   * Reference to the REEF framework.
-   * This variable is injected automatically in the constructor.
-   */
-  private final REEF reef;
-
-  /**
-   * Shell command to submitTask to the job driver.
-   */
-  private final String command;
-
-  /**
-   * Job Driver configuration.
-   */
-  private Configuration driverConfiguration;
-
-  private ConfigurationModule driverConfigModule;
-
-  /**
-   * If true, take commands from stdin; otherwise, use -cmd parameter in batch mode.
-   */
-  private final boolean isInteractive;
-
-  /**
-   * Total number of experiments to run.
-   */
-  private final int maxRuns;
-
-  /**
-   * Command prompt reader for the interactive mode (stdin).
-   */
-  private final BufferedReader prompt;
-
-  /**
-   * A reference to the running job that allows client to send messages back to the job driver
-   */
-  private RunningJob runningJob;
-
-  /**
-   * Start timestamp of the current task.
-   */
-  private long startTime = 0;
-
-  /**
-   * Total time spent performing tasks in Evaluators.
-   */
-  private long totalTime = 0;
-
-  /**
-   * Number of experiments ran so far.
-   */
-  private int numRuns = 0;
-
-  /**
-   * Set to false when job driver is done.
-   */
-  private boolean isBusy = true;
-
-  /**
-   * Retained Evaluator client.
-   * Parameters are injected automatically by TANG.
-   *
-   * @param command Shell command to run on each Evaluator.
-   * @param reef    Reference to the REEF framework.
-   */
-  @Inject
-  JobClient(final REEF reef,
-            @Parameter(Launch.Command.class) final String command,
-            @Parameter(Launch.NumRuns.class) final Integer numRuns) throws BindException {
-
-    this.reef = reef;
-    this.command = command;
-    this.maxRuns = numRuns;
-
-    // If command is not set, switch to interactive mode. (Yes, we compare pointers here)
-    this.isInteractive = this.command ==
-        Launch.Command.class.getAnnotation(NamedParameter.class).default_value();
-
-    this.prompt = this.isInteractive ? new BufferedReader(new InputStreamReader(System.in)) : null;
-
-    this.driverConfigModule = DriverConfiguration.CONF
-        .set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClassLocation(JobDriver.class))
-        .set(DriverConfiguration.DRIVER_IDENTIFIER, "eval-" + System.currentTimeMillis())
-        .set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, JobDriver.AllocatedEvaluatorHandler.class)
-        .set(DriverConfiguration.ON_EVALUATOR_FAILED, JobDriver.FailedEvaluatorHandler.class)
-        .set(DriverConfiguration.ON_CONTEXT_ACTIVE, JobDriver.ActiveContextHandler.class)
-        .set(DriverConfiguration.ON_CONTEXT_CLOSED, JobDriver.ClosedContextHandler.class)
-        .set(DriverConfiguration.ON_CONTEXT_FAILED, JobDriver.FailedContextHandler.class)
-        .set(DriverConfiguration.ON_TASK_COMPLETED, JobDriver.CompletedTaskHandler.class)
-        .set(DriverConfiguration.ON_CLIENT_MESSAGE, JobDriver.ClientMessageHandler.class)
-        .set(DriverConfiguration.ON_DRIVER_STARTED, JobDriver.StartHandler.class)
-        .set(DriverConfiguration.ON_DRIVER_STOP, JobDriver.StopHandler.class);
-  }
-
-  private void addCLRFiles(final File folder) throws BindException {
-    ConfigurationModule result = this.driverConfigModule;
-    for (final File f : folder.listFiles()) {
-      if (f.canRead() && f.exists() && f.isFile()) {
-        result = result.set(DriverConfiguration.GLOBAL_FILES, f.getAbsolutePath());
-      }
-    }
-
-    this.driverConfigModule = result;
-    this.driverConfiguration = this.driverConfigModule.build();
-  }
-
-  /**
-   * Launch the job driver.
-   *
-   * @throws BindException configuration error.
-   */
-  public void submit(File clrFolder) {
-    try {
-      addCLRFiles(clrFolder);
-    } catch (final BindException e) {
-      LOG.log(Level.FINE, "Failed to bind", e);
-    }
-    this.reef.submit(this.driverConfiguration);
-  }
-
-  /**
-   * Send command to the job driver. Record timestamp when the command was sent.
-   * If this.command is set, use it; otherwise, ask user for the command.
-   */
-  private synchronized void submitTask() {
-    if (this.isInteractive) {
-      String cmd;
-      try {
-        do {
-          System.out.print("\nRE> ");
-          cmd = this.prompt.readLine();
-        } while (cmd != null && cmd.trim().isEmpty());
-      } catch (final IOException ex) {
-        LOG.log(Level.FINE, "Error reading from stdin: {0}", ex);
-        cmd = null;
-      }
-      if (cmd == null || cmd.equals("exit")) {
-        this.runningJob.close();
-        stopAndNotify();
-      } else {
-        this.submitTask(cmd);
-      }
-    } else {
-      // non-interactive batch mode:
-      this.submitTask(this.command);
-    }
-  }
-
-  /**
-   * Send command to the job driver. Record timestamp when the command was sent.
-   *
-   * @param cmd shell command to execute in all Evaluators.
-   */
-  private synchronized void submitTask(final String cmd) {
-    LOG.log(Level.INFO, "Submit task {0} \"{1}\" to {2}",
-        new Object[]{this.numRuns + 1, cmd, this.runningJob});
-    this.startTime = System.currentTimeMillis();
-    this.runningJob.send(CODEC.encode(cmd));
-  }
-
-  /**
-   * Receive notification from the job driver that the job is running.
-   */
-  final class RunningJobHandler implements EventHandler<RunningJob> {
-    @Override
-    public void onNext(final RunningJob job) {
-      LOG.log(Level.INFO, "Running job: {0}", job.getId());
-      synchronized (JobClient.this) {
-        JobClient.this.runningJob = job;
-        JobClient.this.submitTask();
-      }
-    }
-  }
-
-  /**
-   * Receive message from the job driver.
-   * There is only one message, which comes at the end of the driver execution
-   * and contains shell command output on each node.
-   */
-  final class JobMessageHandler implements EventHandler<JobMessage> {
-    @Override
-    public void onNext(final JobMessage message) {
-      synchronized (JobClient.this) {
-
-        final String result = CODEC.decode(message.get());
-        final long jobTime = System.currentTimeMillis() - startTime;
-        totalTime += jobTime;
-        ++numRuns;
-
-        LOG.log(Level.INFO, "Task {0} completed in {1} msec.:\n{2}",
-            new Object[]{numRuns, jobTime, result});
-
-        System.out.println(result);
-
-        if (runningJob != null) {
-          if (isInteractive || numRuns < maxRuns) {
-            submitTask();
-          } else {
-            LOG.log(Level.INFO,
-                "All {0} tasks complete; Average task time: {1}. Closing the job driver.",
-                new Object[]{maxRuns, totalTime / (double) maxRuns});
-            runningJob.close();
-            stopAndNotify();
-          }
-        }
-      }
-    }
-  }
-
-  /**
-   * Receive notification from the job driver that the job had failed.
-   */
-  final class FailedJobHandler implements EventHandler<FailedJob> {
-    @Override
-    public void onNext(final FailedJob job) {
-      LOG.log(Level.SEVERE, "Failed job: " + job.getId(), job.getReason().orElse(null));
-      stopAndNotify();
-    }
-  }
-
-  /**
-   * Receive notification from the job driver that the job had completed successfully.
-   */
-  final class CompletedJobHandler implements EventHandler<CompletedJob> {
-    @Override
-    public void onNext(final CompletedJob job) {
-      LOG.log(Level.INFO, "Completed job: {0}", job.getId());
-      stopAndNotify();
-    }
-  }
-
-  /**
-   * Receive notification that there was an exception thrown from the job driver.
-   */
-  final class RuntimeErrorHandler implements EventHandler<FailedRuntime> {
-    @Override
-    public void onNext(final FailedRuntime error) {
-      LOG.log(Level.SEVERE, "Error in job driver: " + error, error.getReason().orElse(null));
-      stopAndNotify();
-    }
-  }
-
-  /**
-   * Notify the process in waitForCompletion() method that the main process has finished.
-   */
-  private synchronized void stopAndNotify() {
-    this.runningJob = null;
-    this.isBusy = false;
-    this.notify();
-  }
-
-  /**
-   * Wait for the job driver to complete. This method is called from Launcher.main()
-   */
-  public void waitForCompletion() {
-    while (this.isBusy) {
-      LOG.info("Waiting for the Job Driver to complete.");
-      try {
-        synchronized (this) {
-          this.wait();
-        }
-      } catch (final InterruptedException ex) {
-        LOG.log(Level.WARNING, "Waiting for result interrupted.", ex);
-      }
-    }
-    this.reef.close();
-  }
-}