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:04:03 UTC
[32/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/driver/parameters/ServiceDriverRestartCompletedHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceDriverRestartCompletedHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceDriverRestartCompletedHandlers.java
new file mode 100644
index 0000000..a2bd452
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceDriverRestartCompletedHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.runtime.common.DriverRestartCompleted;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Service handler for driver restart completed event
+ */
+@NamedParameter(doc = "Handler for driver restart completed event")
+public final class ServiceDriverRestartCompletedHandlers implements Name<Set<EventHandler<DriverRestartCompleted>>> {
+ private ServiceDriverRestartCompletedHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceDriverRestartContextActiveHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceDriverRestartContextActiveHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceDriverRestartContextActiveHandlers.java
new file mode 100644
index 0000000..501d077
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceDriverRestartContextActiveHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.context.ActiveContext;
+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 received during driver restart
+ */
+@NamedParameter(doc = "Handler for ActiveContext received during driver restart")
+public final class ServiceDriverRestartContextActiveHandlers implements Name<Set<EventHandler<ActiveContext>>> {
+ private ServiceDriverRestartContextActiveHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceDriverRestartTaskRunningHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceDriverRestartTaskRunningHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceDriverRestartTaskRunningHandlers.java
new file mode 100644
index 0000000..5b54dd6
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceDriverRestartTaskRunningHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.task.RunningTask;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Running task handler during driver restart.
+ */
+@NamedParameter(doc = "Running task handler during driver restart.")
+public final class ServiceDriverRestartTaskRunningHandlers implements Name<Set<EventHandler<RunningTask>>> {
+ private ServiceDriverRestartTaskRunningHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceEvaluatorAllocatedHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceEvaluatorAllocatedHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceEvaluatorAllocatedHandlers.java
new file mode 100644
index 0000000..0b70ee4
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceEvaluatorAllocatedHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.evaluator.AllocatedEvaluator;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Called when an allocated evaluator is given to the client.
+ */
+@NamedParameter(doc = "Called when an allocated evaluator is given to the client.")
+public final class ServiceEvaluatorAllocatedHandlers implements Name<Set<EventHandler<AllocatedEvaluator>>> {
+ private ServiceEvaluatorAllocatedHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceEvaluatorCompletedHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceEvaluatorCompletedHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceEvaluatorCompletedHandlers.java
new file mode 100644
index 0000000..3295c76
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceEvaluatorCompletedHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.evaluator.CompletedEvaluator;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Called when an exception occurs on a running evaluator.
+ */
+@NamedParameter(doc = "Called when an exception occurs on a running evaluator.")
+public final class ServiceEvaluatorCompletedHandlers implements Name<Set<EventHandler<CompletedEvaluator>>> {
+ private ServiceEvaluatorCompletedHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceEvaluatorFailedHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceEvaluatorFailedHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceEvaluatorFailedHandlers.java
new file mode 100644
index 0000000..bbea341
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceEvaluatorFailedHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.evaluator.FailedEvaluator;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Called when an exception occurs on a running evaluator.
+ */
+@NamedParameter(doc = "Called when an exception occurs on a running evaluator.")
+public final class ServiceEvaluatorFailedHandlers implements Name<Set<EventHandler<FailedEvaluator>>> {
+ private ServiceEvaluatorFailedHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskCompletedHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskCompletedHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskCompletedHandlers.java
new file mode 100644
index 0000000..c12a55d
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskCompletedHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.task.CompletedTask;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Completed task handler.
+ */
+@NamedParameter(doc = "Completed task handler.")
+public final class ServiceTaskCompletedHandlers implements Name<Set<EventHandler<CompletedTask>>> {
+ private ServiceTaskCompletedHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskFailedHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskFailedHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskFailedHandlers.java
new file mode 100644
index 0000000..261ba07
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskFailedHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.task.FailedTask;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Task failure handler.
+ */
+@NamedParameter(doc = "Task failure handler.")
+public final class ServiceTaskFailedHandlers implements Name<Set<EventHandler<FailedTask>>> {
+ private ServiceTaskFailedHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskMessageHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskMessageHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskMessageHandlers.java
new file mode 100644
index 0000000..9ee97e4
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskMessageHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.task.TaskMessage;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Task message handler.
+ */
+@NamedParameter(doc = "Task message handler.")
+public final class ServiceTaskMessageHandlers implements Name<Set<EventHandler<TaskMessage>>> {
+ private ServiceTaskMessageHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskRunningHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskRunningHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskRunningHandlers.java
new file mode 100644
index 0000000..d47668c
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskRunningHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.task.RunningTask;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Running task handler.
+ */
+@NamedParameter(doc = "Running task handler.")
+public final class ServiceTaskRunningHandlers implements Name<Set<EventHandler<RunningTask>>> {
+ private ServiceTaskRunningHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskSuspendedHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskSuspendedHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskSuspendedHandlers.java
new file mode 100644
index 0000000..a01ba65
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/ServiceTaskSuspendedHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.task.SuspendedTask;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Suspended task handler.
+ */
+@NamedParameter(doc = "Suspended task handler.")
+public final class ServiceTaskSuspendedHandlers implements Name<Set<EventHandler<SuspendedTask>>> {
+ private ServiceTaskSuspendedHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskCompletedHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskCompletedHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskCompletedHandlers.java
new file mode 100644
index 0000000..37bfc03
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskCompletedHandlers.java
@@ -0,0 +1,33 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.task.CompletedTask;
+import org.apache.reef.runtime.common.driver.defaults.DefaultTaskCompletionHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Completed task handler.
+ */
+@NamedParameter(doc = "Completed task handler.", default_classes = DefaultTaskCompletionHandler.class)
+public final class TaskCompletedHandlers implements Name<Set<EventHandler<CompletedTask>>> {
+ private TaskCompletedHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskFailedHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskFailedHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskFailedHandlers.java
new file mode 100644
index 0000000..3823906
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskFailedHandlers.java
@@ -0,0 +1,33 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.task.FailedTask;
+import org.apache.reef.runtime.common.driver.defaults.DefaultTaskFailureHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Task failure handler.
+ */
+@NamedParameter(doc = "Task failure handler.", default_classes = DefaultTaskFailureHandler.class)
+public final class TaskFailedHandlers implements Name<Set<EventHandler<FailedTask>>> {
+ private TaskFailedHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskMessageHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskMessageHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskMessageHandlers.java
new file mode 100644
index 0000000..12bd86e
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskMessageHandlers.java
@@ -0,0 +1,33 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.task.TaskMessage;
+import org.apache.reef.runtime.common.driver.defaults.DefaultTaskMessageHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Task message handler.
+ */
+@NamedParameter(doc = "Task message handler.", default_classes = DefaultTaskMessageHandler.class)
+public final class TaskMessageHandlers implements Name<Set<EventHandler<TaskMessage>>> {
+ private TaskMessageHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskRunningHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskRunningHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskRunningHandlers.java
new file mode 100644
index 0000000..49a3717
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskRunningHandlers.java
@@ -0,0 +1,33 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.task.RunningTask;
+import org.apache.reef.runtime.common.driver.defaults.DefaultTaskRunningHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Running task handler.
+ */
+@NamedParameter(doc = "Running task handler.", default_classes = DefaultTaskRunningHandler.class)
+public final class TaskRunningHandlers implements Name<Set<EventHandler<RunningTask>>> {
+ private TaskRunningHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskSuspendedHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskSuspendedHandlers.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskSuspendedHandlers.java
new file mode 100644
index 0000000..b3cf159
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/TaskSuspendedHandlers.java
@@ -0,0 +1,33 @@
+/**
+ * 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.driver.parameters;
+
+import org.apache.reef.driver.task.SuspendedTask;
+import org.apache.reef.runtime.common.driver.defaults.DefaultTaskSuspensionHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Suspended task handler.
+ */
+@NamedParameter(doc = "Suspended task handler.", default_classes = DefaultTaskSuspensionHandler.class)
+public final class TaskSuspendedHandlers implements Name<Set<EventHandler<SuspendedTask>>> {
+ private TaskSuspendedHandlers() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/parameters/package-info.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/parameters/package-info.java b/reef-common/src/main/java/org/apache/reef/driver/parameters/package-info.java
new file mode 100644
index 0000000..6296c46
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/parameters/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.
+ */
+/**
+ * Named parameters used by the Driver
+ */
+package org.apache.reef.driver.parameters;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/task/CompletedTask.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/task/CompletedTask.java b/reef-common/src/main/java/org/apache/reef/driver/task/CompletedTask.java
new file mode 100644
index 0000000..aa29123
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/task/CompletedTask.java
@@ -0,0 +1,43 @@
+/**
+ * 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.driver.task;
+
+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.ActiveContext;
+import org.apache.reef.io.Message;
+import org.apache.reef.io.naming.Identifiable;
+
+/**
+ * Represents a completed Task.
+ */
+@DriverSide
+@Public
+@Provided
+public interface CompletedTask extends Message, Identifiable {
+
+ /**
+ * @return the context the Task ran on.
+ */
+ public ActiveContext getActiveContext();
+
+ /**
+ * @return the id of the completed task.
+ */
+ @Override
+ public String getId();
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/task/FailedTask.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/task/FailedTask.java b/reef-common/src/main/java/org/apache/reef/driver/task/FailedTask.java
new file mode 100644
index 0000000..0c7daff
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/task/FailedTask.java
@@ -0,0 +1,72 @@
+/**
+ * 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.driver.task;
+
+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.AbstractFailure;
+import org.apache.reef.driver.context.ActiveContext;
+import org.apache.reef.util.Optional;
+
+/**
+ * An error message that REEF Driver gets from a failed Task.
+ */
+@DriverSide
+@Provided
+@Public
+public final class FailedTask extends AbstractFailure {
+
+ /**
+ * (Optional) Context of the failed Task.
+ */
+ private final Optional<ActiveContext> context;
+
+ /**
+ * @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.
+ * @param context the Context the Task failed on.
+ */
+ public FailedTask(final String id,
+ final String message,
+ final Optional<String> description,
+ final Optional<Throwable> cause,
+ final Optional<byte[]> data,
+ final Optional<ActiveContext> context) {
+ super(id, message, description, cause, data);
+ this.context = context;
+ }
+
+
+ /**
+ * Access the context the task ran (and crashed) on, if it could be recovered.
+ * <p/>
+ * An ActiveContext is given when the task fails but the context remains alive.
+ * On context failure, the context also fails and is surfaced via the FailedContext event.
+ * <p/>
+ * Note that receiving an ActiveContext here is no guarantee that the context (and evaluator)
+ * are in a consistent state. Application developers need to investigate the reason available
+ * via getCause() to make that call.
+ *
+ * @return the context the Task ran on.
+ */
+ public Optional<ActiveContext> getActiveContext() {
+ return this.context;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/task/RunningTask.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/task/RunningTask.java b/reef-common/src/main/java/org/apache/reef/driver/task/RunningTask.java
new file mode 100644
index 0000000..d38fa99
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/task/RunningTask.java
@@ -0,0 +1,70 @@
+/**
+ * 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.driver.task;
+
+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.ActiveContext;
+import org.apache.reef.io.naming.Identifiable;
+
+/**
+ * Represents a running Task
+ */
+@DriverSide
+@Public
+@Provided
+public interface RunningTask extends Identifiable, AutoCloseable {
+
+
+ /**
+ * @return the context the task is running on.
+ */
+ public ActiveContext getActiveContext();
+
+
+ /**
+ * Sends the message to the running task.
+ *
+ * @param message to be sent to the running task
+ */
+ public void send(final byte[] message);
+
+ /**
+ * Signal the task to suspend.
+ *
+ * @param message a message that is sent to the Task.
+ */
+ public void suspend(final byte[] message);
+
+ /**
+ * Signal the task to suspend.
+ */
+ public void suspend();
+
+ /**
+ * Signal the task to shut down.
+ *
+ * @param message a message that is sent to the Task.
+ */
+ public void close(final byte[] message);
+
+ /**
+ * Signal the task to shut down.
+ */
+ @Override
+ public void close();
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/task/SuspendedTask.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/task/SuspendedTask.java b/reef-common/src/main/java/org/apache/reef/driver/task/SuspendedTask.java
new file mode 100644
index 0000000..5af2882
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/task/SuspendedTask.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.driver.task;
+
+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.ActiveContext;
+import org.apache.reef.io.Message;
+import org.apache.reef.io.naming.Identifiable;
+
+/**
+ * Represents a suspended Task.
+ */
+@DriverSide
+@Public
+@Provided
+public interface SuspendedTask extends Message, Identifiable {
+ /**
+ * @return the context the task ran on. This context is now available to run another task or to spwan new
+ * child context
+ */
+ public ActiveContext getActiveContext();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/task/TaskConfiguration.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/task/TaskConfiguration.java b/reef-common/src/main/java/org/apache/reef/driver/task/TaskConfiguration.java
new file mode 100644
index 0000000..6ef84a1
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/task/TaskConfiguration.java
@@ -0,0 +1,89 @@
+/**
+ * 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.driver.task;
+
+import org.apache.reef.tang.formats.*;
+import org.apache.reef.task.Task;
+import org.apache.reef.task.TaskMessageSource;
+import org.apache.reef.task.events.*;
+import org.apache.reef.wake.EventHandler;
+
+/**
+ * A ConfigurationModule to fill out to generate legal task Configurations that can be submitted.
+ */
+public class TaskConfiguration extends ConfigurationModuleBuilder {
+
+ /**
+ * Identifier for the task.
+ */
+ public static final RequiredParameter<String> IDENTIFIER = new RequiredParameter<>();
+
+ /**
+ * The task to instantiate.
+ */
+ public static final RequiredImpl<Task> TASK = new RequiredImpl<>();
+
+ /**
+ * Handler for task suspension. Defaults to task failure if not bound.
+ */
+ public static final OptionalImpl<EventHandler<SuspendEvent>> ON_SUSPEND = new OptionalImpl<>();
+
+ /**
+ * Handler for messages from the driver. Defaults to task failure if not bound.
+ */
+ public static final OptionalImpl<EventHandler<DriverMessage>> ON_MESSAGE = new OptionalImpl<>();
+
+ /**
+ * Handler for closure requests from the driver. Defaults to task failure if not bound.
+ */
+ public static final OptionalImpl<EventHandler<CloseEvent>> ON_CLOSE = new OptionalImpl<>();
+
+ /**
+ * The Base64 encoded memento to be passed to Task.call().
+ * You can do the encoding for example via DatatypeConverter.printBase64Binary()
+ */
+ public static final OptionalParameter<String> MEMENTO = new OptionalParameter<>();
+
+ /**
+ * Message source invoked upon each evaluator heartbeat.
+ */
+ public static final OptionalImpl<TaskMessageSource> ON_SEND_MESSAGE = new OptionalImpl<>();
+
+ /**
+ * Event handler to receive TaskStart after the Task.call() method was called.
+ */
+ public static final OptionalImpl<EventHandler<TaskStart>> ON_TASK_STARTED = new OptionalImpl<>();
+
+ /**
+ * Event handler to receive TaskStop after the Task.call() method returned.
+ */
+ public static final OptionalImpl<EventHandler<TaskStop>> ON_TASK_STOP = new OptionalImpl<>();
+
+ /**
+ * ConfigurationModule to fill out for a Task configuration.
+ */
+ public static final ConfigurationModule CONF = new TaskConfiguration()
+ .bindNamedParameter(TaskConfigurationOptions.Identifier.class, IDENTIFIER)
+ .bindImplementation(Task.class, TASK)
+ .bindNamedParameter(TaskConfigurationOptions.Memento.class, MEMENTO)
+ .bindNamedParameter(TaskConfigurationOptions.CloseHandler.class, ON_CLOSE)
+ .bindNamedParameter(TaskConfigurationOptions.SuspendHandler.class, ON_SUSPEND)
+ .bindNamedParameter(TaskConfigurationOptions.MessageHandler.class, ON_MESSAGE)
+ .bindSetEntry(TaskConfigurationOptions.TaskMessageSources.class, ON_SEND_MESSAGE)
+ .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/50444bba/reef-common/src/main/java/org/apache/reef/driver/task/TaskConfigurationOptions.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/task/TaskConfigurationOptions.java b/reef-common/src/main/java/org/apache/reef/driver/task/TaskConfigurationOptions.java
new file mode 100644
index 0000000..4d6d4dc
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/task/TaskConfigurationOptions.java
@@ -0,0 +1,74 @@
+/**
+ * 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.driver.task;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.runtime.common.evaluator.task.defaults.DefaultCloseHandler;
+import org.apache.reef.runtime.common.evaluator.task.defaults.DefaultDriverMessageHandler;
+import org.apache.reef.runtime.common.evaluator.task.defaults.DefaultSuspendHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.task.TaskMessageSource;
+import org.apache.reef.task.events.*;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * Configuration parameters for the TaskConfiguration class.
+ */
+@Public
+@DriverSide
+@Provided
+public final class TaskConfigurationOptions {
+
+ @NamedParameter(default_value = "Unnamed Task", doc = "The Identifier of the Task")
+ public static final class Identifier implements Name<String> {
+ }
+
+ @NamedParameter(doc = "The memento to be used for the Task.")
+ public final class Memento implements Name<String> {
+ }
+
+ @NamedParameter(doc = "TaskMessageSource instances.")
+ public final class TaskMessageSources implements Name<Set<TaskMessageSource>> {
+ }
+
+ @NamedParameter(doc = "The set of event handlers for the TaskStart event.")
+ public final class StartHandlers implements Name<Set<EventHandler<TaskStart>>> {
+ }
+
+ @NamedParameter(doc = "The set of event handlers for the TaskStop event.")
+ public final class StopHandlers implements Name<Set<EventHandler<TaskStop>>> {
+ }
+
+ @NamedParameter(doc = "The event handler that receives the close event",
+ default_class = DefaultCloseHandler.class)
+ public final class CloseHandler implements Name<EventHandler<CloseEvent>> {
+ }
+
+ @NamedParameter(doc = "The event handler that receives the suspend event",
+ default_class = DefaultSuspendHandler.class)
+ public final class SuspendHandler implements Name<EventHandler<SuspendEvent>> {
+ }
+
+ @NamedParameter(doc = "The event handler that receives messages from the driver",
+ default_class = DefaultDriverMessageHandler.class)
+ public final class MessageHandler implements Name<EventHandler<DriverMessage>> {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/driver/task/TaskMessage.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/driver/task/TaskMessage.java b/reef-common/src/main/java/org/apache/reef/driver/task/TaskMessage.java
new file mode 100644
index 0000000..c87adbd
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/driver/task/TaskMessage.java
@@ -0,0 +1,53 @@
+/**
+ * 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.driver.task;
+
+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;
+
+/**
+ * A message from a running task to the driver.
+ */
+@DriverSide
+@Public
+@Provided
+public interface TaskMessage extends Message, Identifiable {
+
+ /**
+ * @return the message.
+ */
+ @Override
+ byte[] get();
+
+ /**
+ * @return the ID of the sending task.
+ */
+ @Override
+ String getId();
+
+ /**
+ * @return the id of the context the sending task is running in.
+ */
+ String getContextId();
+
+ /**
+ * @return the ID of the TaskMessageSource
+ */
+ String getMessageSourceID();
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/evaluator/context/ContextMessage.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/evaluator/context/ContextMessage.java b/reef-common/src/main/java/org/apache/reef/evaluator/context/ContextMessage.java
new file mode 100644
index 0000000..33ae610
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/evaluator/context/ContextMessage.java
@@ -0,0 +1,66 @@
+/**
+ * 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.evaluator.context;
+
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.EvaluatorSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.io.Message;
+
+/**
+ * Evaluator-side representation of a message sent from an Evaluator to a Driver.
+ */
+@EvaluatorSide
+@Public
+@Provided
+public final class ContextMessage implements Message {
+
+ private final String messageSourceID;
+ private final byte[] theBytes;
+
+ private ContextMessage(final String messageSourceID, final byte[] theBytes) {
+ this.messageSourceID = messageSourceID;
+ this.theBytes = theBytes;
+ }
+
+ /**
+ * @param messageSourceID The message's sourceID. This will be accessible in the Driver for routing.
+ * @param theBytes The actual content of the message, serialized into a byte[]
+ * @return a new EvaluatorMessage with the given content.
+ */
+ public static ContextMessage from(final String messageSourceID, final byte[] theBytes) {
+ assert (theBytes != null && messageSourceID != null);
+ return new ContextMessage(messageSourceID, theBytes);
+ }
+
+ /**
+ * @return the message source identifier.
+ */
+ public String getMessageSourceID() {
+ return this.messageSourceID;
+ }
+
+ /**
+ * @return the message
+ */
+ @Override
+ public byte[] get() {
+ return this.theBytes;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/evaluator/context/ContextMessageHandler.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/evaluator/context/ContextMessageHandler.java b/reef-common/src/main/java/org/apache/reef/evaluator/context/ContextMessageHandler.java
new file mode 100644
index 0000000..0c348b8
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/evaluator/context/ContextMessageHandler.java
@@ -0,0 +1,36 @@
+/**
+ * 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.evaluator.context;
+
+import org.apache.reef.annotations.Optional;
+import org.apache.reef.annotations.audience.EvaluatorSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.wake.EventHandler;
+
+/**
+ * Implement this interface to receive messages from the driver in a context.
+ */
+@EvaluatorSide
+@Public
+@Optional
+public interface ContextMessageHandler extends EventHandler<byte[]> {
+
+ /**
+ * @param message sent by the driver to this context
+ */
+ @Override
+ public void onNext(final byte[] message);
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/evaluator/context/ContextMessageSource.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/evaluator/context/ContextMessageSource.java b/reef-common/src/main/java/org/apache/reef/evaluator/context/ContextMessageSource.java
new file mode 100644
index 0000000..a9e7d1b
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/evaluator/context/ContextMessageSource.java
@@ -0,0 +1,36 @@
+/**
+ * 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.evaluator.context;
+
+import org.apache.reef.annotations.audience.EvaluatorSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.util.Optional;
+
+
+/**
+ * Message source for control flow messages from a context to the Driver.
+ */
+@Public
+@EvaluatorSide
+public interface ContextMessageSource {
+
+ /**
+ * @return a message to be sent back to the Driver.
+ */
+ public Optional<ContextMessage> getMessage();
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/evaluator/context/events/ContextStart.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/evaluator/context/events/ContextStart.java b/reef-common/src/main/java/org/apache/reef/evaluator/context/events/ContextStart.java
new file mode 100644
index 0000000..bc0d365
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/evaluator/context/events/ContextStart.java
@@ -0,0 +1,36 @@
+/**
+ * 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.evaluator.context.events;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.EvaluatorSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.io.naming.Identifiable;
+
+/**
+ * This Event is fired when a Context is started.
+ */
+@EvaluatorSide
+@Public
+@Provided
+public interface ContextStart extends Identifiable {
+
+ /**
+ * @return the ID of the EvaluatorContext that was just launched.
+ */
+ public String getId();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/evaluator/context/events/ContextStop.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/evaluator/context/events/ContextStop.java b/reef-common/src/main/java/org/apache/reef/evaluator/context/events/ContextStop.java
new file mode 100644
index 0000000..e4c88e4
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/evaluator/context/events/ContextStop.java
@@ -0,0 +1,36 @@
+/**
+ * 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.evaluator.context.events;
+
+import org.apache.reef.annotations.Provided;
+import org.apache.reef.annotations.audience.EvaluatorSide;
+import org.apache.reef.annotations.audience.Public;
+import org.apache.reef.io.naming.Identifiable;
+
+/**
+ * This event is fired when a Context is about to be closed.
+ */
+@EvaluatorSide
+@Public
+@Provided
+public interface ContextStop extends Identifiable {
+
+ /**
+ * @return the ID of the EvaluatorContext.
+ */
+ public String getId();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextIdentifier.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextIdentifier.java b/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextIdentifier.java
new file mode 100644
index 0000000..f9b8467
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextIdentifier.java
@@ -0,0 +1,26 @@
+/**
+ * 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.evaluator.context.parameters;
+
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+/**
+ * Context identifier.
+ */
+@NamedParameter(doc = "The identifier for the context.")
+public final class ContextIdentifier implements Name<String> {
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextMessageHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextMessageHandlers.java b/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextMessageHandlers.java
new file mode 100644
index 0000000..2fc0338
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextMessageHandlers.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.evaluator.context.parameters;
+
+import org.apache.reef.evaluator.context.ContextMessageHandler;
+import org.apache.reef.runtime.common.evaluator.context.defaults.DefaultContextMessageHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+import java.util.Set;
+
+/**
+ * The set of Context message handlers.
+ */
+@NamedParameter(doc = "The set of Context message handlers.",
+ default_classes = DefaultContextMessageHandler.class)
+public final class ContextMessageHandlers implements Name<Set<ContextMessageHandler>> {
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextMessageSources.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextMessageSources.java b/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextMessageSources.java
new file mode 100644
index 0000000..c1815df
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextMessageSources.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.evaluator.context.parameters;
+
+import org.apache.reef.evaluator.context.ContextMessageSource;
+import org.apache.reef.runtime.common.evaluator.context.defaults.DefaultContextMessageSource;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+
+import java.util.Set;
+
+/**
+ * The set of ContextMessageSource implementations called during heartbeats.
+ */
+@NamedParameter(doc = "The set of ContextMessageSource implementations called during heartbeats.",
+ default_classes = DefaultContextMessageSource.class)
+public final class ContextMessageSources implements Name<Set<ContextMessageSource>> {
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextStartHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextStartHandlers.java b/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextStartHandlers.java
new file mode 100644
index 0000000..97056ca
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextStartHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.evaluator.context.parameters;
+
+import org.apache.reef.evaluator.context.events.ContextStart;
+import org.apache.reef.runtime.common.evaluator.context.defaults.DefaultContextStartHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * The set of event handlers for the ContextStart event.
+ */
+@NamedParameter(doc = "The set of event handlers for the ContextStart event.",
+ default_classes = DefaultContextStartHandler.class)
+public class ContextStartHandlers implements Name<Set<EventHandler<ContextStart>>> {
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextStopHandlers.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextStopHandlers.java b/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextStopHandlers.java
new file mode 100644
index 0000000..f837059
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/ContextStopHandlers.java
@@ -0,0 +1,32 @@
+/**
+ * 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.evaluator.context.parameters;
+
+import org.apache.reef.evaluator.context.events.ContextStop;
+import org.apache.reef.runtime.common.evaluator.context.defaults.DefaultContextStopHandler;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.wake.EventHandler;
+
+import java.util.Set;
+
+/**
+ * The set of event handlers for the ContextStop event.
+ */
+@NamedParameter(doc = "The set of event handlers for the ContextStop event.",
+ default_classes = DefaultContextStopHandler.class)
+public final class ContextStopHandlers implements Name<Set<EventHandler<ContextStop>>> {
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/Services.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/Services.java b/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/Services.java
new file mode 100644
index 0000000..e414530
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/evaluator/context/parameters/Services.java
@@ -0,0 +1,32 @@
+/**
+ * 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.evaluator.context.parameters;
+
+import org.apache.reef.annotations.audience.Private;
+import org.apache.reef.tang.annotations.Name;
+import org.apache.reef.tang.annotations.NamedParameter;
+import org.apache.reef.util.ObjectInstantiationLogger;
+
+import java.util.Set;
+
+/**
+ * A set of classes to be instantiated and shared as singletons within this context and all child context
+ */
+@NamedParameter(doc = "A set of classes to be instantiated and shared as singletons within this context and all child context",
+ default_classes = ObjectInstantiationLogger.class)
+@Private
+public class Services implements Name<Set<Object>> {
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/exception/DriverException.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/exception/DriverException.java b/reef-common/src/main/java/org/apache/reef/exception/DriverException.java
new file mode 100644
index 0000000..98e53df
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/exception/DriverException.java
@@ -0,0 +1,62 @@
+/**
+ * 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.exception;
+
+import java.util.concurrent.ExecutionException;
+
+/**
+ * Thrown by the {@link Driver} and to the clients of {@link REEF}.
+ */
+public class DriverException extends ExecutionException {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Standard Exception constructor.
+ */
+ public DriverException() {
+ super();
+ }
+
+ /**
+ * Standard Exception constructor.
+ *
+ * @param message
+ * @param cause
+ */
+ public DriverException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Standard Exception constructor.
+ *
+ * @param message
+ */
+ public DriverException(final String message) {
+ super(message);
+ }
+
+ /**
+ * Standard Exception constructor.
+ *
+ * @param cause
+ */
+ public DriverException(final Throwable cause) {
+ super(cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/exception/EvaluatorException.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/exception/EvaluatorException.java b/reef-common/src/main/java/org/apache/reef/exception/EvaluatorException.java
new file mode 100644
index 0000000..7b22a81
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/exception/EvaluatorException.java
@@ -0,0 +1,63 @@
+/**
+ * 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.exception;
+
+import org.apache.reef.annotations.audience.DriverSide;
+import org.apache.reef.io.naming.Identifiable;
+
+import java.util.concurrent.ExecutionException;
+
+/**
+ * Exception thrown to the Driver when an Evaluator becomes unusable.
+ */
+@DriverSide
+public class EvaluatorException extends ExecutionException implements Identifiable {
+
+ private static final long serialVersionUID = 1L;
+ private final transient String evaluatorId;
+
+ public EvaluatorException(final String evaluatorId) {
+ super();
+ this.evaluatorId = evaluatorId;
+ }
+
+ public EvaluatorException(final String evaluatorId, final String message, final Throwable cause) {
+ super(message, cause);
+ this.evaluatorId = evaluatorId;
+ }
+
+ public EvaluatorException(final String evaluatorId, final String message) {
+ super(message);
+ this.evaluatorId = evaluatorId;
+ }
+
+
+ public EvaluatorException(final String evaluatorId, final Throwable cause) {
+ super(cause);
+ this.evaluatorId = evaluatorId;
+ }
+
+ /**
+ * Access the affected Evaluator.
+ *
+ * @return the affected Evaluator.
+ */
+ @Override
+ public String getId() {
+ return this.evaluatorId;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/exception/EvaluatorKilledByResourceManagerException.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/exception/EvaluatorKilledByResourceManagerException.java b/reef-common/src/main/java/org/apache/reef/exception/EvaluatorKilledByResourceManagerException.java
new file mode 100644
index 0000000..5c61cb6
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/exception/EvaluatorKilledByResourceManagerException.java
@@ -0,0 +1,26 @@
+/**
+ * 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.exception;
+
+/**
+ * Reported as part of a FailedEvaluator when the resource manager killed the Evaluator
+ */
+public final class EvaluatorKilledByResourceManagerException extends EvaluatorException {
+
+ public EvaluatorKilledByResourceManagerException(final String evaluatorId, final String message) {
+ super(evaluatorId, message);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/exception/EvaluatorTimeoutException.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/exception/EvaluatorTimeoutException.java b/reef-common/src/main/java/org/apache/reef/exception/EvaluatorTimeoutException.java
new file mode 100644
index 0000000..c3b99ad
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/exception/EvaluatorTimeoutException.java
@@ -0,0 +1,41 @@
+/**
+ * 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.exception;
+
+/**
+ * Thrown if an Evaluator hasn't been reporting for a while.
+ */
+public class EvaluatorTimeoutException extends EvaluatorException {
+
+ private static final long serialVersionUID = 1L;
+
+ public EvaluatorTimeoutException(final String evaluatorID) {
+ super(evaluatorID);
+ }
+
+ public EvaluatorTimeoutException(final String evaluatorID, final String message, final Throwable cause) {
+ super(evaluatorID, message, cause);
+ }
+
+ public EvaluatorTimeoutException(final String evaluatorID, final String message) {
+ super(evaluatorID, message);
+ }
+
+ public EvaluatorTimeoutException(final String evaluatorID, final Throwable cause) {
+ super(evaluatorID, cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/exception/evaluator/NetworkException.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/exception/evaluator/NetworkException.java b/reef-common/src/main/java/org/apache/reef/exception/evaluator/NetworkException.java
new file mode 100644
index 0000000..16e35b6
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/exception/evaluator/NetworkException.java
@@ -0,0 +1,35 @@
+/**
+ * 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.exception.evaluator;
+
+/**
+ * Network exception
+ */
+public class NetworkException extends ServiceException {
+ private static final long serialVersionUID = 1L;
+
+ public NetworkException(final String s, final Throwable e) {
+ super(s, e);
+ }
+
+ public NetworkException(final String s) {
+ super(s);
+ }
+
+ public NetworkException(final Throwable e) {
+ super(e);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/exception/evaluator/ServiceException.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/exception/evaluator/ServiceException.java b/reef-common/src/main/java/org/apache/reef/exception/evaluator/ServiceException.java
new file mode 100644
index 0000000..c9e4c12
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/exception/evaluator/ServiceException.java
@@ -0,0 +1,50 @@
+/**
+ * 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.exception.evaluator;
+
+/**
+ * The base class for exceptions thrown by REEF libraries and services.
+ * <p/>
+ * Rules of thumb for exception handling in REEF:
+ * <ul>
+ * <li>When possible, throw a subclass of ServiceException, with the following exceptions (no pun intended)</li>
+ * <li>Iterator and other standard Java interfaces neglect to declare throws
+ * clauses. Use ServiceRuntimeException when implementing such interfaces.</li>
+ * <li>If there is no good way for Task code to recover from the exception, throw
+ * (and document) a subclass of ServiceRuntimeException</li>
+ * <li>Applications with generic, catch-all error handling should catch ServiceRuntimeException and ServiceException.</li>
+ * <li>Applications with specific error handling logic (eg: ignoring/coping with a failed remote task) should catch
+ * the subclass of ServiceRuntimeException / ServiceException thrown by the library they are using.</li>
+ * </ul>
+ *
+ * @see ServiceRuntimeException
+ */
+public class ServiceException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public ServiceException(final String s, final Throwable e) {
+ super(s, e);
+ }
+
+ public ServiceException(final String s) {
+ super(s);
+ }
+
+ public ServiceException(final Throwable e) {
+ super(e);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/exception/evaluator/ServiceRuntimeException.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/exception/evaluator/ServiceRuntimeException.java b/reef-common/src/main/java/org/apache/reef/exception/evaluator/ServiceRuntimeException.java
new file mode 100644
index 0000000..ffb43f8
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/exception/evaluator/ServiceRuntimeException.java
@@ -0,0 +1,72 @@
+/**
+ * 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.exception.evaluator;
+
+
+/**
+ * The base class for resourcemanager exceptions thrown by REEF services, such as
+ * storage and networking routines. SERVICES that throw exceptions that
+ * applications may be able to cope with should subclass ServiceRuntimeException
+ * or ServiceException.
+ *
+ * @see ServiceException which is generally preferred over ServiceRuntimeException.
+ */
+public class ServiceRuntimeException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+ private final boolean isWrappedServiceException;
+
+ public ServiceRuntimeException() {
+ this.isWrappedServiceException = false;
+ }
+
+ /**
+ * It often is the case that analogous ServiceException and ServiceRuntimeExceptions
+ * are needed so that exception types can be uniformly thrown from Reef APIs that
+ * declare throws clauses, and legacy interfaces that do not. This constructor
+ * wraps ServiceExceptions, and is the preferred way to deal with such situations.
+ *
+ * @param cause
+ */
+ public ServiceRuntimeException(final ServiceException cause) {
+ super("Wrapped ServiceException", cause);
+ this.isWrappedServiceException = true;
+ }
+
+ public ServiceRuntimeException(final String message, final Throwable cause) {
+ super(message, cause);
+ this.isWrappedServiceException = false;
+ }
+
+ public ServiceRuntimeException(final String message) {
+ super(message);
+ this.isWrappedServiceException = false;
+
+ }
+
+ public ServiceRuntimeException(final Throwable cause) {
+ super(cause);
+ this.isWrappedServiceException = (cause instanceof ServiceException);
+ }
+
+ /**
+ * Upon catching a ServiceRuntimeException, the receiving code should call unwrap().
+ *
+ * @return this, or getCause(), depending on whether or not this is a wrapped ServiceException.
+ */
+ public Throwable unwrap() {
+ return this.isWrappedServiceException ? getCause() : this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/exception/evaluator/StorageException.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/exception/evaluator/StorageException.java b/reef-common/src/main/java/org/apache/reef/exception/evaluator/StorageException.java
new file mode 100644
index 0000000..7e32ac3
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/exception/evaluator/StorageException.java
@@ -0,0 +1,33 @@
+/**
+ * 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.exception.evaluator;
+
+public class StorageException extends ServiceException {
+ private static final long serialVersionUID = 1L;
+
+ public StorageException(final String s, final Throwable e) {
+ super(s, e);
+ }
+
+ public StorageException(final String s) {
+ super(s);
+ }
+
+ public StorageException(final Throwable e) {
+ super(e);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/exception/evaluator/package-info.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/exception/evaluator/package-info.java b/reef-common/src/main/java/org/apache/reef/exception/evaluator/package-info.java
new file mode 100644
index 0000000..3697372
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/exception/evaluator/package-info.java
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+/**
+ * Exceptions thrown in the Evaluators.
+ *
+ */
+package org.apache.reef.exception.evaluator;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/50444bba/reef-common/src/main/java/org/apache/reef/exception/package-info.java
----------------------------------------------------------------------
diff --git a/reef-common/src/main/java/org/apache/reef/exception/package-info.java b/reef-common/src/main/java/org/apache/reef/exception/package-info.java
new file mode 100644
index 0000000..b1a6701
--- /dev/null
+++ b/reef-common/src/main/java/org/apache/reef/exception/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.
+ */
+/**
+ * Exceptions thrown to Job Drivers.
+ */
+package org.apache.reef.exception;
\ No newline at end of file