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:47:17 UTC

[44/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-common/src/main/java/org/apache/reef/client/parameters/ResourceManagerErrorHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/client/parameters/ResourceManagerErrorHandler.java b/lang/java/reef-common/src/main/java/org/apache/reef/client/parameters/ResourceManagerErrorHandler.java
new file mode 100644
index 0000000..61b958e
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/client/parameters/ResourceManagerErrorHandler.java
@@ -0,0 +1,35 @@
+/**
+ * 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.client.parameters;
+
+import org.apache.reef.client.FailedRuntime;
+import org.apache.reef.runtime.common.client.defaults.DefaultRuntimeErrorHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+/**
+ * Client EventHandler triggered on resource manager error.
+ */
+@NamedParameter(doc = "Client EventHandler triggered on resource manager error.",
+    default_classes = DefaultRuntimeErrorHandler.class)
+public final class ResourceManagerErrorHandler implements Name<EventHandler<FailedRuntime>> {
+  private ResourceManagerErrorHandler() {
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/client/parameters/package-info.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/client/parameters/package-info.java b/lang/java/reef-common/src/main/java/org/apache/reef/client/parameters/package-info.java
new file mode 100644
index 0000000..af1ae50
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/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.
+ */
+/**
+ * Named parameters for the REEF client API.
+ */
+package org.apache.reef.client.parameters;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/common/AbstractFailure.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/common/AbstractFailure.java b/lang/java/reef-common/src/main/java/org/apache/reef/common/AbstractFailure.java
new file mode 100644
index 0000000..80cf4ac
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/common/AbstractFailure.java
@@ -0,0 +1,151 @@
+/**
+ * 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.common;
+
+import org.apache.reef.util.Optional;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/**
+ * Common data and functionality for all error messages in REEF.
+ */
+public abstract class AbstractFailure implements Failure {
+
+  /**
+   * Identifier of the entity that produced the error. Cannot be null.
+   */
+  protected final String id;
+
+  /**
+   * One-line error message. For wrapped exceptions, this equals
+   * to the Exception.getMessage() result. Cannot be null.
+   */
+  protected final String message;
+
+  /**
+   * Optional error description (long).
+   * For exceptions it is by default populates with the stack trace.
+   */
+  protected final Optional<String> description;
+
+  /**
+   * Optional Java exception that caused the error.
+   */
+  protected final Optional<Throwable> cause;
+
+  /**
+   * Optional byte array that contains serialized version of the exception.
+   */
+  protected final Optional<byte[]> data;
+
+  /**
+   * @param id          Identifier of the entity that produced the error. Cannot be null.
+   * @param message     One-line error message. Cannot be null.
+   * @param description Long error description. Can be null.
+   * @param cause       Java Exception that caused the error. Can be null.
+   * @param data        byte array that contains serialized version of the error. Can be null.
+   */
+  protected AbstractFailure(final String id,
+                            final String message,
+                            final Optional<String> description,
+                            final Optional<Throwable> cause,
+                            final Optional<byte[]> data) {
+    this.id = id;
+    this.message = message;
+    this.description = description;
+    this.cause = cause;
+    this.data = data;
+  }
+
+
+  /**
+   * Helper function: produce the string that contains the given exception's stack trace.
+   * Returns null if the argument is null.
+   *
+   * @param cause Java Exception or null.
+   * @return A string that contains the exception stack trace, or null.
+   */
+  protected static String getStackTrace(final Throwable cause) {
+    if (cause == null) {
+      return null;
+    } else {
+      final StringWriter writer = new StringWriter();
+      cause.printStackTrace(new PrintWriter(writer));
+      return writer.toString();
+    }
+  }
+
+  /**
+   * @return Identifier of the entity that produced the error. Never null.
+   */
+  @Override
+  public String getId() {
+    return this.id;
+  }
+
+  /**
+   * @return One-line error message. Never null.
+   */
+  @Override
+  public String getMessage() {
+    return this.message;
+  }
+
+  /**
+   * @return Optional long error description. For Java Exceptions, can contain stack trace.
+   */
+  @Override
+  public Optional<String> getDescription() {
+    return this.description;
+  }
+
+  @Override
+  public Optional<Throwable> getReason() {
+    return this.cause;
+  }
+
+  /**
+   * @return Optional serialized version of the error message.
+   */
+  @Override
+  public Optional<byte[]> getData() {
+    return this.data;
+  }
+
+  /**
+   * Return the original Java Exception, or generate a new one if it does not exists.
+   * ALWAYS returns an exception.
+   * FIXME: Replace RuntimeException with a better class.
+   *
+   * @return A java exception. Never null.
+   */
+  @Override
+  public Throwable asError() {
+    return this.cause.isPresent() ? this.cause.get() : new RuntimeException(this.toString());
+  }
+
+  /**
+   * @return Human-readable string representation of an error message.
+   */
+  @Override
+  public String toString() {
+    return this.getClass().getName() + " id=" + this.getId() + " failed: " + this.getMessage();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/common/Failure.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/common/Failure.java b/lang/java/reef-common/src/main/java/org/apache/reef/common/Failure.java
new file mode 100644
index 0000000..211f971
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/common/Failure.java
@@ -0,0 +1,58 @@
+/**
+ * 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.common;
+
+import org.apache.reef.io.naming.Identifiable;
+import org.apache.reef.util.Optional;
+
+/**
+ * Common interface for all error messages in REEF.
+ * Most of its functionality is generic and implemented in the AbstractFailure class.
+ */
+public interface Failure extends Identifiable {
+
+  /**
+   * @return One-line error message. Should never be null.
+   */
+  String getMessage();
+
+  /**
+   * @return Optional long error description.
+   */
+  Optional<String> getDescription();
+
+  /**
+   * @return Java Exception that caused the error, if any.
+   */
+  Optional<Throwable> getReason();
+
+
+  /**
+   * @return Optional serialized version of the error message.
+   */
+  Optional<byte[]> getData();
+
+  /**
+   * Return the original Java Exception, or generate a new one if it does not exists.
+   * ALWAYS returns an exception.
+   *
+   * @return A java exception. Never null.
+   */
+  Throwable asError();
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/ContextAndTaskSubmittable.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/ContextAndTaskSubmittable.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/ContextAndTaskSubmittable.java
new file mode 100644
index 0000000..5bd62e5
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/ContextAndTaskSubmittable.java
@@ -0,0 +1,64 @@
+/**
+ * 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.driver;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.tang.Configuration;
+
+/**
+ * Base interface for classes that support the simultaneous submission of both Context and Task configurations.
+ */
+@DriverSide
+@Provided
+@Public
+public interface ContextAndTaskSubmittable {
+  /**
+   * Submit a Context and a Task.
+   * <p/>
+   * The semantics of this call are the same as first submitting the context and then, on the fired ActiveContext event
+   * to submit the Task. The performance of this will be better, though as it potentially saves some roundtrips on
+   * the network.
+   * <p/>
+   * REEF will not fire an ActiveContext as a result of this. Instead, it will fire a TaskRunning event.
+   *
+   * @param contextConfiguration the Configuration of the EvaluatorContext. See ContextConfiguration for details.
+   * @param taskConfiguration    the Configuration of the Task. See TaskConfiguration for details.
+   */
+  public void submitContextAndTask(final Configuration contextConfiguration, final Configuration taskConfiguration);
+
+  /**
+   * Subkit a Context with Services and a Task.
+   * <p/>
+   * The semantics of this call are the same as first submitting the context and services and then, on the fired
+   * ActiveContext event to submit the Task. The performance of this will be better, though as it potentially saves
+   * some roundtrips on the network.
+   * <p/>
+   * REEF will not fire an ActiveContext as a result of this. Instead, it will fire a TaskRunning event.
+   *
+   * @param contextConfiguration
+   * @param serviceConfiguration
+   * @param taskConfiguration
+   */
+  public void submitContextAndServiceAndTask(final Configuration contextConfiguration,
+                                             final Configuration serviceConfiguration,
+                                             final Configuration taskConfiguration);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/ContextSubmittable.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/ContextSubmittable.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/ContextSubmittable.java
new file mode 100644
index 0000000..f9721fa
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/ContextSubmittable.java
@@ -0,0 +1,49 @@
+/**
+ * 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.driver;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.tang.Configuration;
+
+/**
+ * Base interface for classes that support Context submission.
+ */
+@DriverSide
+@Provided
+@Public
+public interface ContextSubmittable {
+
+  /**
+   * Submit a Context.
+   *
+   * @param contextConfiguration the Configuration of the EvaluatorContext. See ContextConfiguration for details.
+   */
+  public void submitContext(final Configuration contextConfiguration);
+
+  /**
+   * Submit a Context and a Service Configuration.
+   *
+   * @param contextConfiguration the Configuration of the EvaluatorContext. See ContextConfiguration for details.
+   * @param serviceConfiguration the Configuration for the Services. See ServiceConfiguration for details.
+   */
+  public void submitContextAndService(final Configuration contextConfiguration, final Configuration serviceConfiguration);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/FlexiblePreemptionEvent.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/FlexiblePreemptionEvent.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/FlexiblePreemptionEvent.java
new file mode 100644
index 0000000..a9aeaf7
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/FlexiblePreemptionEvent.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.driver;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.Unstable;
+import org.apache.reef.annotations.audience.Private;
+import org.apache.reef.driver.evaluator.EvaluatorRequest;
+
+import java.util.Set;
+
+/**
+ * Represents a flexible preemption request: It contains:
+ * <p/>
+ * <ol>
+ * <li>a set of EvaluatorRequests that the resource manager wants to have satisfied and also</li>
+ * <li>a set of Evaluators it will choose to kill if the request isn't satisfied otherwise.</li>
+ * </ol>
+ * <p/>
+ * NOTE: This currently not implemented. Consider it a preview of the API.
+ */
+@Private
+@Provided
+@Unstable
+public interface FlexiblePreemptionEvent extends PreemptionEvent {
+
+  /**
+   * @return the set of EvaluatorRequests that the underlying resource manager seeks to satisfy.
+   */
+  public Set<EvaluatorRequest> getEvaluatorRequest();
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/PreemptionEvent.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/PreemptionEvent.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/PreemptionEvent.java
new file mode 100644
index 0000000..2d84d01
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/PreemptionEvent.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.driver;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.Unstable;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+
+/**
+ * Represents Preemption requests issued by the underlying resource manager.
+ * <p/>
+ * REEF exposes two kinds of preemption requests: Strict ones merely inform the Driver about machines that are about to
+ * be preempted. Flexible ones provide that list, but also expose the resource request that the underlying resource
+ * manager wants to satisfy, thereby giving the Driver a chance to satisfy it in another way.
+ * <p/>
+ * NOTE: This currently not implemented. Consider it a preview of the API.
+ */
+@DriverSide
+@Public
+@Provided
+@Unstable
+public interface PreemptionEvent {
+
+  /**
+   * @return the Set of RunningEvaluators that the underlying resource manager is about to take away from the Driver.
+   */
+  // TODO: We need to have a set of things to present to the user as preempted. Probably a Set<String> with the Evaluator IDs.
+  // public Set<RunningEvaluator> getToBePreemptedEvaluators();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/PreemptionHandler.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/PreemptionHandler.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/PreemptionHandler.java
new file mode 100644
index 0000000..db15d13
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/PreemptionHandler.java
@@ -0,0 +1,36 @@
+/**
+ * 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.driver;
+
+import org.apache.reef.annotations.Optional;
+import org.apache.reef.annotations.Unstable;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.wake.EventHandler;
+
+/**
+ * This EventHandler will receive preemption events from the underlying resourcemanager.
+ * NOTE: This currently not implemented. Consider it a preview of the API.
+ */
+@DriverSide
+@Public
+@Optional
+@Unstable
+public interface PreemptionHandler extends EventHandler<PreemptionEvent> {
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/StrictPreemptionEvent.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/StrictPreemptionEvent.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/StrictPreemptionEvent.java
new file mode 100644
index 0000000..99e8bfb
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/StrictPreemptionEvent.java
@@ -0,0 +1,37 @@
+/**
+ * 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.driver;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.Unstable;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+
+/**
+ * Represents a strict preemption event: It contains the set of Evaluators that the underlying resource manager will
+ * take away from the Driver.
+ * <p/>
+ * NOTE: This currently not implemented. Consider it a preview of the API.
+ */
+@Unstable
+@DriverSide
+@Public
+@Provided
+public interface StrictPreemptionEvent extends PreemptionEvent {
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/TaskSubmittable.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/TaskSubmittable.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/TaskSubmittable.java
new file mode 100644
index 0000000..22f8e8d
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/TaskSubmittable.java
@@ -0,0 +1,40 @@
+/**
+ * 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.driver;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.tang.Configuration;
+
+/**
+ * Base interface for classes that support Task submission.
+ */
+@DriverSide
+@Provided
+@Public
+public interface TaskSubmittable {
+
+  /**
+   * Submits a Task (encoded in the Configuration) for execution.
+   *
+   * @param taskConf the Configuration. See TaskConfiguration for details
+   */
+  public void submitTask(final Configuration taskConf);
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/catalog/NodeDescriptor.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/catalog/NodeDescriptor.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/catalog/NodeDescriptor.java
new file mode 100644
index 0000000..f222df8
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/catalog/NodeDescriptor.java
@@ -0,0 +1,42 @@
+/**
+ * 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.driver.catalog;
+
+import org.apache.reef.annotations.Unstable;
+import org.apache.reef.io.naming.Identifiable;
+
+import java.net.InetSocketAddress;
+
+/**
+ * Descriptor of the physical setup of an Evaluator.
+ */
+@Unstable
+public interface NodeDescriptor extends ResourceCatalog.Descriptor, Identifiable {
+  /**
+   * Access the inet address of the Evaluator.
+   *
+   * @return the inet address of the Evaluator.
+   */
+  public InetSocketAddress getInetSocketAddress();
+
+  /**
+   * @return the rack descriptor that contains this node
+   */
+  public RackDescriptor getRackDescriptor();
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/catalog/RackDescriptor.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/catalog/RackDescriptor.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/catalog/RackDescriptor.java
new file mode 100644
index 0000000..cb34005
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/catalog/RackDescriptor.java
@@ -0,0 +1,35 @@
+/**
+ * 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.driver.catalog;
+
+import org.apache.reef.annotations.Unstable;
+
+import java.util.List;
+
+/**
+ * A rack in the cluster.
+ */
+@Unstable
+public interface RackDescriptor extends ResourceCatalog.Descriptor {
+
+  /**
+   * @return the list of nodes in this rack.
+   */
+  public List<NodeDescriptor> getNodes();
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/catalog/ResourceCatalog.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/catalog/ResourceCatalog.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/catalog/ResourceCatalog.java
new file mode 100644
index 0000000..62f4d6b
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/catalog/ResourceCatalog.java
@@ -0,0 +1,65 @@
+/**
+ * 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.driver.catalog;
+
+import org.apache.reef.annotations.Unstable;
+
+import java.util.Collection;
+
+/**
+ * A catalog of the resources available to a REEF instance.
+ * <p/>
+ * This catalog contains static information about the resources and does not
+ * reflect that dynamic availability of resources. In other words: Its entries
+ * are an upper bound to what is available to a REEF {@link Driver} at any given
+ * moment in time.
+ */
+@Unstable
+public interface ResourceCatalog {
+
+  /**
+   * The global list of resources.
+   *
+   * @return a list of all the static resources available. This is an upper
+   * bound.
+   */
+  public Collection<NodeDescriptor> getNodes();
+
+  /**
+   * The global list of racks
+   *
+   * @return list of all rack descriptors
+   */
+  public Collection<RackDescriptor> getRacks();
+
+  /**
+   * Get the node descriptor with the given identifier.
+   *
+   * @param id of the node.
+   * @return the node descriptor assigned to the identifier.
+   */
+  public NodeDescriptor getNode(String nodeId);
+
+  public interface Descriptor {
+
+    public String getName();
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/client/JobMessageObserver.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/client/JobMessageObserver.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/client/JobMessageObserver.java
new file mode 100644
index 0000000..3cc3b0b
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/client/JobMessageObserver.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.driver.client;
+
+import org.apache.reef.annotations.Optional;
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+
+/**
+ * The driver uses this interface to communicate with the job client.
+ * <p/>
+ * Note that as of REEF 0.4, the presence of a client is no longer guaranteed, depending on the deployment environment.
+ */
+@Public
+@DriverSide
+@Provided
+@Optional
+public interface JobMessageObserver {
+
+  /**
+   * Send a message to the client.
+   *
+   * @param message a message to be sent to the client
+   */
+  public void sendMessageToClient(final byte[] message);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/client/package-info.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/client/package-info.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/client/package-info.java
new file mode 100644
index 0000000..c68dabf
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/client/package-info.java
@@ -0,0 +1,25 @@
+/**
+ * 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.
+ */
+/**
+ * Representations of the Client (i.e. the job submitter) to a Driver.
+ * Note that as of REEF 0.3, the client is optional and may not be available to a driver.
+ */
+@DriverSide package org.apache.reef.driver.client;
+
+import org.apache.reef.annotations.audience.DriverSide;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ActiveContext.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ActiveContext.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ActiveContext.java
new file mode 100644
index 0000000..05ed8e3
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ActiveContext.java
@@ -0,0 +1,71 @@
+/**
+ * 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.driver.context;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.driver.ContextSubmittable;
+import org.apache.reef.driver.TaskSubmittable;
+import org.apache.reef.io.naming.Identifiable;
+import org.apache.reef.tang.Configuration;
+
+/**
+ * Represents an active context on an Evaluator.
+ * <p/>
+ * A context consists of twp configurations:
+ * <ol>
+ * <li>ContextConfiguration: Its visibility is limited to the context itself and tasks spawned from it.</li>
+ * <li>ServiceConfiguration: This is "inherited" by child context spawned.</li>
+ * </ol>
+ * <p/>
+ * Contexts have identifiers. A context is instantiated on a single Evaluator. Contexts are either created on an
+ * AllocatedEvaluator (for what is called the "root Context") or by forming sub-Contexts.
+ * <p/>
+ * Contexts form a stack. Only the topmost context is active. Child Contexts or Tasks can be submitted to the
+ * active Context. Contexts can be closed, in which case their parent becomes active.
+ * In the case of the root context, closing is equivalent to releasing the Evaluator. A child context "sees" all
+ * Configuration in its parent Contexts.
+ */
+@Public
+@DriverSide
+@Provided
+public interface ActiveContext extends Identifiable, AutoCloseable, ContextBase, TaskSubmittable, ContextSubmittable {
+
+  @Override
+  public void close();
+
+  @Override
+  public void submitTask(final Configuration taskConf);
+
+  @Override
+  public void submitContext(final Configuration contextConfiguration);
+
+  @Override
+  public void submitContextAndService(final Configuration contextConfiguration, final Configuration serviceConfiguration);
+
+  /**
+   * Send the active context the message, which will be delivered to all registered
+   * {@link org.apache.reef.evaluator.context.ContextMessageHandler}, for this context.
+   *
+   * @param message
+   */
+  public void sendMessage(final byte[] message);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ClosedContext.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ClosedContext.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ClosedContext.java
new file mode 100644
index 0000000..ca7b5eb
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ClosedContext.java
@@ -0,0 +1,37 @@
+/**
+ * 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.driver.context;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+
+/**
+ * Represents a Context that has been closed succesfully.
+ */
+@Public
+@DriverSide
+@Provided
+public interface ClosedContext extends ContextBase {
+
+  /**
+   * @return the new top of the stack of context.
+   */
+  public ActiveContext getParentContext();
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ContextBase.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ContextBase.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ContextBase.java
new file mode 100644
index 0000000..e7bcb69
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ContextBase.java
@@ -0,0 +1,56 @@
+/**
+ * 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.driver.context;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.driver.evaluator.EvaluatorDescriptor;
+import org.apache.reef.io.naming.Identifiable;
+import org.apache.reef.util.Optional;
+
+/**
+ * A common base interface for all Driver-side representations of Contexts.
+ */
+@Public
+@DriverSide
+@Provided
+public interface ContextBase extends Identifiable {
+
+  /**
+   * @return the ID of the Context.
+   */
+  @Override
+  String getId();
+
+  /**
+   * @return the identifier of the Evaluator this Context is instantiated on.
+   */
+  String getEvaluatorId();
+
+  /**
+   * @return the ID of the parent context, if there is one.
+   */
+  Optional<String> getParentId();
+
+  /**
+   * @return the descriptor of the Evaluator this Context is on.
+   */
+  EvaluatorDescriptor getEvaluatorDescriptor();
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ContextConfiguration.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ContextConfiguration.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ContextConfiguration.java
new file mode 100644
index 0000000..a4e61b1
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ContextConfiguration.java
@@ -0,0 +1,109 @@
+/**
+ * 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.driver.context;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.driver.task.TaskConfigurationOptions;
+import org.apache.reef.evaluator.context.ContextMessageHandler;
+import org.apache.reef.evaluator.context.ContextMessageSource;
+import org.apache.reef.evaluator.context.events.ContextStart;
+import org.apache.reef.evaluator.context.events.ContextStop;
+import org.apache.reef.evaluator.context.parameters.*;
+import org.apache.reef.runtime.common.evaluator.DefaultDriverConnection;
+import org.apache.reef.runtime.common.evaluator.DriverConnection;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.tang.formats.ConfigurationModule;
+import org.apache.reef.tang.formats.ConfigurationModuleBuilder;
+import org.apache.reef.tang.formats.OptionalImpl;
+import org.apache.reef.tang.formats.RequiredParameter;
+import org.apache.reef.task.events.TaskStart;
+import org.apache.reef.task.events.TaskStop;
+import org.apache.reef.wake.EventHandler;
+
+/**
+ * A ConfigurationModule for Context Configuration.
+ */
+@Public
+@DriverSide
+@Provided
+public class ContextConfiguration extends ConfigurationModuleBuilder {
+
+  /**
+   * The identifier of the Context.
+   */
+  public static final RequiredParameter<String> IDENTIFIER = new RequiredParameter<>();
+
+  /**
+   * Event handler for context start. Defaults to logging if not bound.
+   */
+  public static final OptionalImpl<EventHandler<ContextStart>> ON_CONTEXT_STARTED = new OptionalImpl<>();
+
+  /**
+   * Event handler for context stop. Defaults to logging if not bound.
+   */
+  public static final OptionalImpl<EventHandler<ContextStop>> ON_CONTEXT_STOP = new OptionalImpl<>();
+
+  /**
+   * Event handlers to be informed right before a Task enters its call() method.
+   */
+  public static final OptionalImpl<EventHandler<TaskStart>> ON_TASK_STARTED = new OptionalImpl<>();
+
+  /**
+   * Event handlers to be informed right after a Task exits its call() method.
+   */
+  public static final OptionalImpl<EventHandler<TaskStop>> ON_TASK_STOP = new OptionalImpl<>();
+
+  /**
+   * Source of messages to be called whenever the evaluator is about to make a heartbeat.
+   */
+  public static final OptionalImpl<ContextMessageSource> ON_SEND_MESSAGE = new OptionalImpl<>();
+
+  /**
+   * Driver has sent the context a message, and this parameter is used to register a handler
+   * on the context for processing that message.
+   */
+  public static final OptionalImpl<ContextMessageHandler> ON_MESSAGE = new OptionalImpl<>();
+
+  /**
+   * Implementation for reconnecting to driver after driver restart
+   */
+  public static final OptionalImpl<DriverConnection> ON_DRIVER_RECONNECT = new OptionalImpl<>();
+
+  /**
+   * A ConfigurationModule for context.
+   */
+  public static final ConfigurationModule CONF = new ContextConfiguration()
+      .bindNamedParameter(ContextIdentifier.class, IDENTIFIER)
+      .bindNamedParameter(DriverReconnect.class, ON_DRIVER_RECONNECT)
+      .bindSetEntry(ContextStartHandlers.class, ON_CONTEXT_STARTED)
+      .bindSetEntry(ContextStopHandlers.class, ON_CONTEXT_STOP)
+      .bindSetEntry(ContextMessageSources.class, ON_SEND_MESSAGE)
+      .bindSetEntry(ContextMessageHandlers.class, ON_MESSAGE)
+      .bindSetEntry(TaskConfigurationOptions.StartHandlers.class, ON_TASK_STARTED)
+      .bindSetEntry(TaskConfigurationOptions.StopHandlers.class, ON_TASK_STOP)
+      .build();
+
+  @NamedParameter(doc = "House the implementation for re-connecting to driver after driver restart",
+      default_classes = DefaultDriverConnection.class)
+  public static final class DriverReconnect implements Name<DriverConnection> {
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ContextMessage.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ContextMessage.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ContextMessage.java
new file mode 100644
index 0000000..568bc89
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ContextMessage.java
@@ -0,0 +1,52 @@
+/**
+ * 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.driver.context;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.io.Message;
+import org.apache.reef.io.naming.Identifiable;
+
+/**
+ * Driver-side representation of a message sent by a Context to the Driver.
+ */
+@Public
+@DriverSide
+@Provided
+public interface ContextMessage extends Message, Identifiable {
+
+  /**
+   * @return the message sent by the Context.
+   */
+  @Override
+  public byte[] get();
+
+  /**
+   * @return the ID of the sending Context.
+   */
+  @Override
+  public String getId();
+
+  /**
+   * @return the ID of the ContextMessageSource that sent the message on the Context.
+   */
+  public String getMessageSourceID();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/FailedContext.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/FailedContext.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/FailedContext.java
new file mode 100644
index 0000000..a152255
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/FailedContext.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.driver.context;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.common.Failure;
+import org.apache.reef.util.Optional;
+
+/**
+ * Represents Context that failed.
+ * A typical case would be that its ContextStartHandler threw an exception.
+ * <p/>
+ * The underlying Evaluator is still accessible and a new context can be established. Note that REEF can't guarantee
+ * consistency of the Evaluator for all applications. It is up to the application to decide whether it is safe to keep
+ * using the Evaluator.
+ */
+@Public
+@Provided
+@DriverSide
+public interface FailedContext extends Failure, ContextBase {
+
+  /**
+   * @return the new top of the stack of context if there is one.
+   */
+  Optional<ActiveContext> getParentContext();
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ServiceConfiguration.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ServiceConfiguration.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ServiceConfiguration.java
new file mode 100644
index 0000000..93a50d6
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/context/ServiceConfiguration.java
@@ -0,0 +1,79 @@
+/**
+ * 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.driver.context;
+
+import org.apache.reef.driver.task.TaskConfigurationOptions;
+import org.apache.reef.evaluator.context.events.ContextStart;
+import org.apache.reef.evaluator.context.events.ContextStop;
+import org.apache.reef.evaluator.context.parameters.ContextStartHandlers;
+import org.apache.reef.evaluator.context.parameters.ContextStopHandlers;
+import org.apache.reef.evaluator.context.parameters.Services;
+import org.apache.reef.tang.formats.ConfigurationModule;
+import org.apache.reef.tang.formats.ConfigurationModuleBuilder;
+import org.apache.reef.tang.formats.OptionalImpl;
+import org.apache.reef.tang.formats.OptionalParameter;
+import org.apache.reef.task.events.TaskStart;
+import org.apache.reef.task.events.TaskStop;
+import org.apache.reef.wake.EventHandler;
+
+/**
+ * Configuration module for services. The configuration created here can be passed alongside a ContextConfiguration
+ * to form a context. Different from bindings made in the ContextConfiguration, those made here will be passed along
+ * to child context.
+ */
+public class ServiceConfiguration extends ConfigurationModuleBuilder {
+
+  /**
+   * A set of services to instantiate. All classes given here will be instantiated in the context, and their references
+   * will be made available to child context and tasks.
+   */
+  public static final OptionalParameter<Object> SERVICES = new OptionalParameter<>();
+
+  /**
+   * Event handler for context start. Defaults to logging if not bound.
+   */
+  public static final OptionalImpl<EventHandler<ContextStart>> ON_CONTEXT_STARTED = new OptionalImpl<>();
+
+  /**
+   * Event handler for context stop. Defaults to logging if not bound.
+   */
+  public static final OptionalImpl<EventHandler<ContextStop>> ON_CONTEXT_STOP = new OptionalImpl<>();
+
+  /**
+   * Event handlers to be informed right before a Task enters its call() method.
+   */
+  public static final OptionalImpl<EventHandler<TaskStart>> ON_TASK_STARTED = new OptionalImpl<>();
+
+  /**
+   * Event handlers to be informed right after a Task exits its call() method.
+   */
+  public static final OptionalImpl<EventHandler<TaskStop>> ON_TASK_STOP = new OptionalImpl<>();
+
+  /**
+   * ConfigurationModule for services.
+   */
+  public static final ConfigurationModule CONF = new ServiceConfiguration()
+      .bindSetEntry(Services.class, SERVICES)
+      .bindSetEntry(ContextStartHandlers.class, ON_CONTEXT_STARTED)
+      .bindSetEntry(ContextStopHandlers.class, ON_CONTEXT_STOP)
+      .bindSetEntry(TaskConfigurationOptions.StartHandlers.class, ON_TASK_STARTED)
+      .bindSetEntry(TaskConfigurationOptions.StopHandlers.class, ON_TASK_STOP)
+      .build();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/AllocatedEvaluator.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/AllocatedEvaluator.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/AllocatedEvaluator.java
new file mode 100644
index 0000000..198bf00
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/AllocatedEvaluator.java
@@ -0,0 +1,101 @@
+/**
+ * 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.driver.evaluator;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.driver.ContextAndTaskSubmittable;
+import org.apache.reef.driver.ContextSubmittable;
+import org.apache.reef.driver.TaskSubmittable;
+import org.apache.reef.io.naming.Identifiable;
+import org.apache.reef.tang.Configuration;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Represents an Evaluator that is allocated, but is not running yet.
+ */
+@Public
+@DriverSide
+@Provided
+public interface AllocatedEvaluator
+    extends AutoCloseable, Identifiable, ContextSubmittable, ContextAndTaskSubmittable, TaskSubmittable {
+
+  /**
+   * Puts the given file into the working directory of the Evaluator.
+   *
+   * @param file the file to be copied
+   * @throws IOException if the copy fails.
+   */
+  void addFile(final File file);
+
+  /**
+   * Puts the given file into the working directory of the Evaluator and adds it to its classpath.
+   *
+   * @param file the file to be copied
+   * @throws IOException if the copy fails.
+   */
+  void addLibrary(final File file);
+
+  /**
+   * @return the evaluator descriptor of this evaluator.
+   */
+  EvaluatorDescriptor getEvaluatorDescriptor();
+
+  /**
+   * Set the type of Evaluator to be instantiated. Defaults to EvaluatorType.JVM.
+   *
+   * @param type
+   */
+  void setType(final EvaluatorType type);
+
+  /**
+   * Releases the allocated evaluator back to the resource manager.
+   */
+  @Override
+  void close();
+
+  /**
+   * Submits the given Task for execution.
+   * <p/>
+   * This generates a ContextConfiguration for the root context with a generated ID derived from the EvaluatorId.
+   *
+   * @param taskConfiguration the Configuration. See TaskConfiguration for details.
+   */
+  @Override
+  void submitTask(final Configuration taskConfiguration);
+
+  @Override
+  void submitContext(final Configuration contextConfiguration);
+
+  @Override
+  void submitContextAndService(final Configuration contextConfiguration,
+                               final Configuration serviceConfiguration);
+
+  @Override
+  void submitContextAndTask(final Configuration contextConfiguration,
+                            final Configuration taskConfiguration);
+
+  @Override
+  void submitContextAndServiceAndTask(final Configuration contextConfiguration,
+                                      final Configuration serviceConfiguration,
+                                      final Configuration taskConfiguration);
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/CompletedEvaluator.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/CompletedEvaluator.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/CompletedEvaluator.java
new file mode 100644
index 0000000..70e34a5
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/CompletedEvaluator.java
@@ -0,0 +1,33 @@
+/**
+ * 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.driver.evaluator;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.io.naming.Identifiable;
+
+/**
+ * Represents a successfully closed Evaluator.
+ */
+@DriverSide
+@Public
+@Provided
+public interface CompletedEvaluator extends Identifiable {
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorDescriptor.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorDescriptor.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorDescriptor.java
new file mode 100644
index 0000000..55a0ddd
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorDescriptor.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.driver.evaluator;
+
+import org.apache.reef.driver.catalog.NodeDescriptor;
+
+/**
+ * Metadata about an Evaluator.
+ */
+public interface EvaluatorDescriptor {
+
+  /**
+   * @return the NodeDescriptor of the node where this Evaluator is running.
+   */
+  public NodeDescriptor getNodeDescriptor();
+
+  /**
+   * @return the type of Evaluator.
+   */
+  public EvaluatorType getType();
+
+  /**
+   * @return the amount of memory allocated to this Evaluator.
+   */
+  public int getMemory();
+
+  /**
+   * @return the number of virtual core allocated to this Evaluator.
+   */
+  public int getNumberOfCores();
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorRequest.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorRequest.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorRequest.java
new file mode 100644
index 0000000..7094a42
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorRequest.java
@@ -0,0 +1,171 @@
+/**
+ * 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.driver.evaluator;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.driver.catalog.NodeDescriptor;
+import org.apache.reef.driver.catalog.ResourceCatalog;
+
+/**
+ * A request for one ore more Evaluators.
+ */
+@Public
+@DriverSide
+@Provided
+public final class EvaluatorRequest {
+
+  private final int megaBytes;
+  private final int number;
+  private final int cores;
+  private final ResourceCatalog.Descriptor descriptor;
+
+  EvaluatorRequest(final int number,
+                   final int megaBytes,
+                   final int cores,
+                   final ResourceCatalog.Descriptor descriptor) {
+    this.number = number;
+    this.megaBytes = megaBytes;
+    this.cores = cores;
+    this.descriptor = descriptor;
+  }
+
+  /**
+   * @return a new EvaluatorRequest Builder.
+   */
+  public static Builder newBuilder() {
+    return new Builder();
+  }
+
+  /**
+   * @return a new EvaluatorRequest Builder with settings initialized
+   * from an existing request.
+   */
+  public static Builder newBuilder(final EvaluatorRequest request) {
+    return new Builder(request);
+  }
+
+  /**
+   * Access the number of Evaluators requested.
+   *
+   * @return the number of Evaluators requested.
+   */
+  public int getNumber() {
+    return this.number;
+  }
+
+  /**
+   * Access the number of core of Evaluators requested.
+   *
+   * @return the number of cores requested.
+   */
+  public int getNumberOfCores() {
+    return this.cores;
+  }
+
+  /**
+   * Access the {@link NodeDescriptor} used as the template for this
+   * {@link EvaluatorRequest}.
+   *
+   * @return the {@link NodeDescriptor} used as the template for this
+   * {@link EvaluatorRequest}.
+   */
+  public final ResourceCatalog.Descriptor getDescriptor() {
+    return this.descriptor;
+  }
+
+  /**
+   * @return the minimum size of Evaluator requested.
+   */
+  public int getMegaBytes() {
+    return megaBytes;
+  }
+
+  /**
+   * {@link EvaluatorRequest}s are build using this Builder.
+   */
+  public static class Builder implements org.apache.reef.util.Builder<EvaluatorRequest> {
+
+    private int n = 1;
+    private ResourceCatalog.Descriptor descriptor = null;
+    private int megaBytes = -1;
+    private int cores = 1; //if not set, default to 1
+
+    private Builder() {
+    }
+
+    private Builder(final EvaluatorRequest request) {
+      setNumber(request.getNumber());
+      fromDescriptor(request.getDescriptor());
+    }
+
+    /**
+     * @param megaBytes the amount of megabytes to request for the Evaluator.
+     * @return this builder
+     */
+    public Builder setMemory(final int megaBytes) {
+      this.megaBytes = megaBytes;
+      return this;
+    }
+
+    /**
+     * set number of cores
+     *
+     * @param cores the number of cores
+     * @return
+     */
+    public Builder setNumberOfCores(final int cores) {
+      this.cores = cores;
+      return this;
+    }
+
+    /**
+     * Set the number of Evaluators requested.
+     *
+     * @param n
+     * @return this Builder.
+     */
+    public Builder setNumber(final int n) {
+      this.n = n;
+      return this;
+    }
+
+    /**
+     * Builds the {@link EvaluatorRequest}.
+     */
+    @Override
+    public EvaluatorRequest build() {
+      return new EvaluatorRequest(this.n, this.megaBytes, this.cores, this.descriptor);
+    }
+
+    /**
+     * Pre-fill this {@link EvaluatorRequest} from the given
+     * {@link NodeDescriptor}. Any value not changed in subsequent calls to
+     * this Builder will be taken from the given descriptor.
+     *
+     * @param rd the descriptor used to pre-fill this request.
+     * @return this
+     */
+    public Builder fromDescriptor(final ResourceCatalog.Descriptor rd) {
+      this.descriptor = rd;
+      return this;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorRequestor.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorRequestor.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorRequestor.java
new file mode 100644
index 0000000..6999298
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorRequestor.java
@@ -0,0 +1,38 @@
+/**
+ * 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.driver.evaluator;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+
+/**
+ * Interface through which Evaluators can be requested.
+ */
+@Public
+@DriverSide
+@Provided
+public interface EvaluatorRequestor {
+
+  /**
+   * Submit the request for new evaluator.
+   * The response will surface in the AllocatedEvaluator message handler.
+   */
+  public void submit(final EvaluatorRequest req);
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorType.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorType.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorType.java
new file mode 100644
index 0000000..6c27db8
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/EvaluatorType.java
@@ -0,0 +1,38 @@
+/**
+ * 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.driver.evaluator;
+
+/**
+ * Enumeration of all Evaluator types supported by REEF.
+ */
+public enum EvaluatorType {
+  /**
+   * Indicates an Evaluator that runs on the JVM
+   */
+  JVM,
+  /**
+   * Indicates an Evaluator that runs on the CLR
+   */
+  CLR,
+  /**
+   * Indicates an Evaluator whose type hasn't been decided yet. This is common e.g. between Evaluator allocation
+   * and launch.
+   */
+  UNDECIDED
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/FailedEvaluator.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/FailedEvaluator.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/FailedEvaluator.java
new file mode 100644
index 0000000..c173457
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/evaluator/FailedEvaluator.java
@@ -0,0 +1,55 @@
+/**
+ * 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.driver.evaluator;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.driver.context.FailedContext;
+import org.apache.reef.driver.task.FailedTask;
+import org.apache.reef.exception.EvaluatorException;
+import org.apache.reef.io.naming.Identifiable;
+import org.apache.reef.util.Optional;
+
+import java.util.List;
+
+/**
+ * Represents an Evaluator that became unavailable.
+ */
+@DriverSide
+@Public
+@Provided
+public interface FailedEvaluator extends Identifiable {
+
+  /**
+   * @return the reason for the failure.
+   */
+  public EvaluatorException getEvaluatorException();
+
+  /**
+   * @return the list of all context that failed due to the evaluator failure.
+   */
+  public List<FailedContext> getFailedContextList();
+
+  /**
+   * @return the failed task, if there was one running at the time of the evaluator failure.
+   */
+  public Optional<FailedTask> getFailedTask();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/package-info.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/package-info.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/package-info.java
new file mode 100644
index 0000000..c03ab68
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/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.
+ */
+/**
+ * Driver APIs for REEF in terms of Rx.
+ */
+package org.apache.reef.driver;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ClientCloseHandlers.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ClientCloseHandlers.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ClientCloseHandlers.java
new file mode 100644
index 0000000..b2d45f9
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ClientCloseHandlers.java
@@ -0,0 +1,35 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.runtime.common.driver.defaults.DefaultClientCloseHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Handles close requests from the client.
+ */
+@NamedParameter(doc = "Handles close requests from the client.", default_classes = DefaultClientCloseHandler.class)
+public final class ClientCloseHandlers implements Name<Set<EventHandler<Void>>> {
+  private ClientCloseHandlers() {
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ClientCloseWithMessageHandlers.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ClientCloseWithMessageHandlers.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ClientCloseWithMessageHandlers.java
new file mode 100644
index 0000000..708301d
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ClientCloseWithMessageHandlers.java
@@ -0,0 +1,35 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.runtime.common.driver.defaults.DefaultClientCloseWithMessageHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Handles client close requests
+ */
+@NamedParameter(doc = "Handles client close requests", default_classes = DefaultClientCloseWithMessageHandler.class)
+public final class ClientCloseWithMessageHandlers implements Name<Set<EventHandler<byte[]>>> {
+  private ClientCloseWithMessageHandlers() {
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ClientMessageHandlers.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ClientMessageHandlers.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ClientMessageHandlers.java
new file mode 100644
index 0000000..82b61de
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ClientMessageHandlers.java
@@ -0,0 +1,35 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.runtime.common.driver.defaults.DefaultClientMessageHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Handles message from the Client.
+ */
+@NamedParameter(doc = "Handles message from the Client.", default_classes = DefaultClientMessageHandler.class)
+public final class ClientMessageHandlers implements Name<Set<EventHandler<byte[]>>> {
+  private ClientMessageHandlers() {
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/53ea32cc/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ContextActiveHandlers.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ContextActiveHandlers.java b/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ContextActiveHandlers.java
new file mode 100644
index 0000000..724d7a8
--- /dev/null
+++ b/lang/java/reef-common/src/main/java/org/apache/reef/driver/parameters/ContextActiveHandlers.java
@@ -0,0 +1,36 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.context.ActiveContext;
+import org.apache.reef.runtime.common.driver.defaults.DefaultContextActiveHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Handler for ActiveContext
+ */
+@NamedParameter(doc = "Handler for ActiveContext", default_classes = DefaultContextActiveHandler.class)
+public final class ContextActiveHandlers implements Name<Set<EventHandler<ActiveContext>>> {
+  private ContextActiveHandlers() {
+  }
+}