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/29 21:43:04 UTC
[20/31] incubator-reef git commit: [REEF-97] Add the REEF.NET code
base
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloHttpHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloHttpHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloHttpHandler.cs
new file mode 100644
index 0000000..6a06831
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloHttpHandler.cs
@@ -0,0 +1,51 @@
+/**
+ * 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.
+ */
+
+using System.Globalization;
+using System.Net;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge.Handlers
+{
+ public class HelloHttpHandler : IHttpHandler
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(HttpServerHandler));
+
+ [Inject]
+ public HelloHttpHandler()
+ {
+ }
+
+ public string GetSpecification()
+ {
+ return "NRT"; //Client Example
+ }
+
+ public void OnHttpRequest(ReefHttpRequest requet, ReefHttpResponse response)
+ {
+ LOGGER.Log(Level.Info, string.Format(CultureInfo.CurrentCulture, "HelloHttpHandler OnHttpRequest: URL: {0}, QueryString: {1}, inputStream: {2}.", requet.Url, requet.Querystring, ByteUtilities.ByteArrarysToString(requet.InputStream)));
+ response.Status = HttpStatusCode.OK;
+ response.OutputStream =
+ ByteUtilities.StringToByteArrays("Byte array returned from HelloHttpHandler in CLR!!!");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRestartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRestartHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRestartHandler.cs
new file mode 100644
index 0000000..79e5af3
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRestartHandler.cs
@@ -0,0 +1,48 @@
+/**
+ * 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.
+ */
+
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Wake.Time;
+using System;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+ public class HelloRestartHandler : IObserver<StartTime>
+ {
+ [Inject]
+ public HelloRestartHandler()
+ {
+ }
+
+ public void OnNext(StartTime value)
+ {
+ Console.WriteLine("Hello from CLR: we are informed that Driver has restarted at " + new DateTime(value.TimeStamp));
+ }
+
+ public void OnError(Exception error)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnCompleted()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRunningTaskHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRunningTaskHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRunningTaskHandler.cs
new file mode 100644
index 0000000..927cb47
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloRunningTaskHandler.cs
@@ -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.
+ */
+
+using System;
+using System.Globalization;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge.Handlers
+{
+ /// <summary>
+ /// Sample implementaion of RunningTaskHandler
+ /// </summary>
+ public class HelloRunningTaskHandler : IObserver<IRunningTask>
+ {
+ [Inject]
+ public HelloRunningTaskHandler()
+ {
+ }
+
+ public void OnNext(IRunningTask runningTask)
+ {
+ IActiveContext context = runningTask.ActiveContext;
+
+ string messageStr = string.Format(
+ CultureInfo.InvariantCulture,
+ "HelloRunningTaskHandler: Task [{0}] is running. Evaluator id: [{1}].",
+ runningTask.Id,
+ context.EvaluatorId);
+ Console.WriteLine(messageStr);
+
+ byte[] message = ByteUtilities.StringToByteArrays(messageStr);
+
+ runningTask.Send(message);
+ }
+
+ public void OnError(Exception error)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnCompleted()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloSimpleEventHandlers.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloSimpleEventHandlers.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloSimpleEventHandlers.cs
new file mode 100644
index 0000000..9e3e804
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloSimpleEventHandlers.cs
@@ -0,0 +1,421 @@
+/**
+ * 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.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.Driver;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge.handlers
+{
+ enum DriverStatus
+ {
+ Init = 0,
+ Idle = 1,
+ RunningTasks = 2,
+ CompleteTasks = 3
+ }
+
+ internal enum TaskStatus
+ {
+ Submitting = 0,
+ Running = 1,
+ Completed = 2
+ }
+
+ /// <summary>
+ /// A demo class that contains basic handlers. It runs given tasks and is able to get request from http server and start to ren the tasks again.
+ /// It handle various http requests. It also monitoring task status and driver status.
+ /// </summary>
+ public class HelloSimpleEventHandlers :
+ IObserver<IEvaluatorRequestor>,
+ IObserver<IAllocatedEvaluator>,
+ IObserver<IActiveContext>,
+ IObserver<ICompletedTask>,
+ IObserver<IRunningTask>,
+ IObserver<IFailedTask>,
+ IObserver<IFailedEvaluator>,
+ IObserver<ICompletedEvaluator>,
+ IStartHandler,
+ IHttpHandler
+ {
+ private const int NumberOfTasks = 5;
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(HelloSimpleEventHandlers));
+ private IAllocatedEvaluator _allocatedEvaluator;
+ private IActiveContext _activeContext;
+ private IList<IActiveContext> _activeContexts = new List<IActiveContext>();
+ private DriverStatus driveStatus;
+ private TaskContext _taskContext;
+
+ [Inject]
+ public HelloSimpleEventHandlers()
+ {
+ LOGGER.Log(Level.Info, "HelloSimpleEventHandlers constructor");
+ CreateClassHierarchy();
+ Identifier = "HelloSimpleEventHandlers";
+ _taskContext = new TaskContext();
+ _taskContext.TotalTasks = NumberOfTasks;
+ driveStatus = DriverStatus.Init;
+ }
+
+ public string Identifier { get; set; }
+
+ public static string ParsePathInfo(string pathInfo)
+ {
+ string[] p = pathInfo.Split('/');
+ foreach (string s in p)
+ {
+ LOGGER.Log(Level.Info, s);
+ }
+ if (p.Length > 3)
+ {
+ return p[3];
+ }
+ return null;
+ }
+
+ public static void BuildHttpResponse(
+ ReefHttpResponse response,
+ HttpStatusCode httpStatusCode,
+ string strResponse)
+ {
+ response.Status = httpStatusCode;
+ response.OutputStream = ByteUtilities.StringToByteArrays(strResponse);
+ }
+
+ public static void BuildHttpResponse(
+ ReefHttpResponse response,
+ HttpStatusCode httpStatusCode,
+ byte[] bytesResponse)
+ {
+ response.Status = httpStatusCode;
+ response.OutputStream = bytesResponse;
+ }
+
+ public void OnNext(IEvaluatorRequestor evalutorRequestor)
+ {
+ using (LOGGER.LogFunction("HelloSimpleEventHandlers::evalutorRequestor received"))
+ {
+ int evaluatorsNumber = 2;
+ int memory = 1024 * 3;
+ int cpuCoreCount = 1;
+ string rack = "WonderlandRack";
+ string evaluatorBatchId = "evaluatorThatRequires3GBofMemory";
+ EvaluatorRequest request = new EvaluatorRequest(evaluatorsNumber, memory, cpuCoreCount, rack, evaluatorBatchId);
+
+ evalutorRequestor.Submit(request);
+ }
+ }
+
+ public void OnNext(IAllocatedEvaluator allocatedEvaluator)
+ {
+ string taskId = "Task_" + allocatedEvaluator.Id;
+ using (LOGGER.LogFunction("HelloSimpleEventHandlers::allocatedEvaluator received {0}.", taskId))
+ {
+ _allocatedEvaluator = allocatedEvaluator;
+
+ IConfiguration contextConfiguration = ContextConfiguration.ConfigurationModule.Set(ContextConfiguration.Identifier, "HelloSimpleEventHandlersContext_" + Guid.NewGuid().ToString("N")).Build();
+
+ allocatedEvaluator.SubmitContext(contextConfiguration);
+ }
+ }
+
+ public void OnNext(IActiveContext activeContext)
+ {
+ using (LOGGER.LogFunction("HelloSimpleEventHandlers::activeContext received"))
+ {
+ LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received activeContext, EvaluatorId id: {0}", activeContext.EvaluatorId));
+ _activeContext = activeContext;
+ _activeContexts.Add(activeContext);
+ driveStatus = DriverStatus.RunningTasks;
+ SubmitNextTask(activeContext);
+ }
+ }
+
+ public void OnNext(ICompletedTask value)
+ {
+ using (LOGGER.LogFunction("HelloSimpleEventHandlers::CompletedTask received"))
+ {
+ LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Received CompletedTask: {0}, task id: {1}", value.Id, _taskContext.CurrentTaskId()));
+ _activeContext = value.ActiveContext;
+ _taskContext.UpdateTaskStatus(value.Id, TaskStatus.Completed);
+ _taskContext.TaskCompleted++;
+ SubmitNextTask(value.ActiveContext);
+ }
+ }
+
+ public void OnError(Exception error)
+ {
+ LOGGER.Log(Level.Error, string.Format(CultureInfo.InvariantCulture, "Exception in coral handlers Msg: {1} Stack: {2}", error.Message, error.StackTrace));
+ }
+
+ public void OnCompleted()
+ {
+ }
+
+ public void OnNext(IRunningTask value)
+ {
+ _taskContext.UpdateTaskStatus(_taskContext.CurrentTaskId(), TaskStatus.Running);
+ }
+
+ public void OnNext(IFailedTask value)
+ {
+ }
+
+ public void OnNext(IFailedEvaluator value)
+ {
+ }
+
+ public void OnNext(ICompletedEvaluator completedEvaluator)
+ {
+ string messageStr = string.Format(
+ CultureInfo.InvariantCulture,
+ "HelloSimpleEventHandlers: Evaluator [{0}] is done.",
+ completedEvaluator.Id);
+ Console.WriteLine(messageStr);
+ }
+
+ public string GetSpecification()
+ {
+ return "crystal";
+ }
+
+ public void OnHttpRequest(ReefHttpRequest request, ReefHttpResponse response)
+ {
+ string target = ParsePathInfo(request.PathInfo);
+ LOGGER.Log(Level.Info, "Target: " + target + ". PathInfo: " + request.PathInfo);
+ //if (target != null && target.ToLower(CultureInfo.CurrentCulture).Equals("driverstatus"))
+ if (target != null && target.Equals("driverstatus"))
+ {
+ LOGGER.Log(Level.Info, "Target: " + target + ". Driver status: " + driveStatus.ToString());
+ string msg = string.Format(CultureInfo.CurrentCulture, "Current Driver status: {0} ", driveStatus.ToString());
+ BuildHttpResponse(response, HttpStatusCode.OK, msg);
+ return;
+ }
+
+ if (target != null && target.Equals("taskstatus"))
+ {
+ LOGGER.Log(Level.Info, "Target: " + target + ". TaskStatus string: " + _taskContext.TaskStatusString());
+ BuildHttpResponse(response, HttpStatusCode.OK, _taskContext.TaskStatusString());
+ return;
+ }
+
+ if (target != null && target.ToLower(CultureInfo.CurrentCulture).Equals("run") && driveStatus == DriverStatus.Init)
+ {
+ BuildHttpResponse(response, HttpStatusCode.OK, "Driver is not ready, wait a few second then send request again!!!");
+ return;
+ }
+
+ if (target != null && target.ToLower(CultureInfo.CurrentCulture).Equals("run") && driveStatus == DriverStatus.RunningTasks)
+ {
+ string msg = string.Format(CultureInfo.CurrentCulture,
+ "A job is running. Please check driver status and then submit your job again.");
+ BuildHttpResponse(response, HttpStatusCode.OK, msg);
+ return;
+ }
+
+ if (target != null && target.ToLower(CultureInfo.CurrentCulture).Equals("run") && driveStatus == DriverStatus.Idle)
+ {
+ string numberOfTasks = getQueryValue(request.Querystring, "numberoftasks");
+ if (numberOfTasks == null)
+ {
+ BuildHttpResponse(response, HttpStatusCode.OK, "Please specify number of tasks to run");
+ return;
+ }
+
+ driveStatus = DriverStatus.RunningTasks;
+ using (LOGGER.LogFunction("HelloSimpleEventHandlers::Processing a new Job from web request"))
+ {
+ _taskContext = new TaskContext();
+ _taskContext.TotalTasks = int.Parse(numberOfTasks, CultureInfo.CurrentCulture);
+ BuildHttpResponse(response, HttpStatusCode.OK, "Job from web request is submitted and is running!!!");
+ }
+
+ foreach (var c in _activeContexts)
+ {
+ SubmitNextTask(c);
+ }
+ return;
+ }
+ BuildHttpResponse(response, HttpStatusCode.OK, "Unsupported query");
+ }
+
+ private static IDictionary<string, string> ParseQueryString(string queryString)
+ {
+ IDictionary<string, string> queryPairs = new Dictionary<string, string>();
+ if (queryString != null && queryString.Length > 0)
+ {
+ string[] queries = queryString.Split('&');
+ foreach (string query in queries)
+ {
+ string[] pairs = query.Split('=');
+ if (pairs.Length == 2 && !pairs[0].Equals(string.Empty) && !pairs[1].Equals(string.Empty))
+ {
+ queryPairs[pairs[0]] = pairs[1];
+ LOGGER.Log(Level.Info, string.Format(CultureInfo.CurrentCulture, "query key: {0}, Query value: {1}.", pairs[0], pairs[1]));
+ }
+ }
+ }
+ return queryPairs;
+ }
+
+ private static string getQueryValue(string queryString, string name)
+ {
+ IDictionary<string, string> pairs = ParseQueryString(queryString);
+ string v;
+ pairs.TryGetValue(name, out v);
+ return v;
+ }
+
+ private void CreateClassHierarchy()
+ {
+ HashSet<string> clrDlls = new HashSet<string>();
+ clrDlls.Add(typeof(IDriver).Assembly.GetName().Name);
+ clrDlls.Add(typeof(ITask).Assembly.GetName().Name);
+ clrDlls.Add(typeof(HelloTask).Assembly.GetName().Name);
+ clrDlls.Add(typeof(INameClient).Assembly.GetName().Name);
+ clrDlls.Add(typeof(NameClient).Assembly.GetName().Name);
+
+ ClrHandlerHelper.GenerateClassHierarchy(clrDlls);
+ }
+
+ private void SubmitNextTask(IActiveContext activeContext)
+ {
+ LOGGER.Log(Level.Info, "SubmitNextTask with evaluatorid: " + activeContext.EvaluatorId);
+ IConfiguration finalConfiguration = GetNextTaskConfiguration();
+ if (null != finalConfiguration)
+ {
+ LOGGER.Log(Level.Info, "Executing task id " + _taskContext.CurrentTaskId());
+ LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Submitting Task {0}", _taskContext.CurrentTaskId()));
+
+ activeContext.SubmitTask(finalConfiguration);
+ }
+ else
+ {
+ if (_taskContext.TaskCompleted == _taskContext.TotalTasks)
+ {
+ LOGGER.Log(Level.Info, "All tasks submitted and completed, active context remian idle");
+ driveStatus = DriverStatus.Idle;
+ }
+ }
+ }
+
+ private IConfiguration GetNextTaskConfiguration()
+ {
+ string nextTaskId = _taskContext.NextTaskId();
+ LOGGER.Log(Level.Info, "GetNextTaskConfiguration, nextTaskId: " + nextTaskId);
+ if (nextTaskId != null)
+ {
+ IConfiguration taskConfiguration = TaskConfiguration.ConfigurationModule
+ .Set(TaskConfiguration.Identifier, nextTaskId)
+ .Set(TaskConfiguration.Task, GenericType<HelloTask>.Class)
+ .Set(TaskConfiguration.OnMessage, GenericType<HelloTask.HelloDriverMessageHandler>.Class)
+ .Set(TaskConfiguration.OnSendMessage, GenericType<HelloTaskMessage>.Class)
+ .Build();
+ return taskConfiguration;
+ }
+ return null;
+ }
+ }
+
+ class TaskContext
+ {
+ private IList<string> taskIds = new List<string>();
+
+ private IDictionary<string, TaskStatus> tasks = new Dictionary<string, TaskStatus>();
+
+ public TaskContext()
+ {
+ NextTaskIndex = 0;
+ TaskCompleted = 0;
+ }
+
+ public int TotalTasks { get; set; }
+
+ public int NextTaskIndex { get; set; }
+
+ public int TaskCompleted { get; set; }
+
+ public string NextTaskId()
+ {
+ Console.WriteLine("NextTaskId: " + NextTaskIndex);
+ if (NextTaskIndex < TotalTasks)
+ {
+ string id = "Jan7DemoTask_" + DateTime.Now.Ticks;
+ taskIds.Add(id);
+ tasks.Add(id, TaskStatus.Submitting);
+ NextTaskIndex++;
+ return id;
+ }
+ return null;
+ }
+
+ public string CurrentTaskId()
+ {
+ Console.WriteLine("CurrentTaskIndex: " + (NextTaskIndex - 1));
+ if (NextTaskIndex <= TotalTasks)
+ {
+ Console.WriteLine("CurrentTaskId: " + taskIds[NextTaskIndex - 1]);
+ return taskIds[NextTaskIndex - 1];
+ }
+ return null; //either not started or completed
+ }
+
+ public void UpdateTaskStatus(string taskId, TaskStatus status)
+ {
+ tasks[taskId] = status;
+ }
+
+ public string TaskStatusString()
+ {
+ Console.WriteLine("TaskStatusString 1, nextTaskIndex: " + NextTaskIndex);
+ StringBuilder sb = new StringBuilder();
+
+ if (tasks.Count > 0)
+ {
+ foreach (var pair in tasks)
+ {
+ sb.AppendLine("Task id: " + pair.Key + " Task status: " + pair.Value.ToString());
+ }
+ }
+ else
+ {
+ sb.Append("No task is running yet");
+ }
+
+ return sb.ToString();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloStartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloStartHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloStartHandler.cs
new file mode 100644
index 0000000..edd1737
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloStartHandler.cs
@@ -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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.Driver;
+using Org.Apache.Reef.Driver.bridge;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.IO.Network.Naming;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Utilities.Logging;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+ public class HelloStartHandler : IStartHandler
+ {
+ private static readonly Logger LOGGER = Logger.GetLogger(typeof(HelloStartHandler));
+
+ [Inject]
+ public HelloStartHandler(HttpServerPort httpServerPort)
+ {
+ CreateClassHierarchy();
+ Identifier = "HelloStartHandler";
+ LOGGER.Log(Level.Info, "HttpPort received in HelloStartHandler: " + httpServerPort.PortNumber);
+ }
+
+ public HelloStartHandler(string id)
+ {
+ Identifier = id;
+ CreateClassHierarchy();
+ }
+
+ public string Identifier { get; set; }
+
+ private void CreateClassHierarchy()
+ {
+ HashSet<string> clrDlls = new HashSet<string>();
+ clrDlls.Add(typeof(IDriver).Assembly.GetName().Name);
+ clrDlls.Add(typeof(ITask).Assembly.GetName().Name);
+ clrDlls.Add(typeof(HelloTask).Assembly.GetName().Name);
+ clrDlls.Add(typeof(INameClient).Assembly.GetName().Name);
+ clrDlls.Add(typeof(NameClient).Assembly.GetName().Name);
+
+ ClrHandlerHelper.GenerateClassHierarchy(clrDlls);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloTaskMessageHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloTaskMessageHandler.cs b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloTaskMessageHandler.cs
new file mode 100644
index 0000000..8cee6ef
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/HelloCLRBridge/handlers/HelloTaskMessageHandler.cs
@@ -0,0 +1,54 @@
+/**
+ * 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.
+ */
+
+using System;
+using System.Globalization;
+using System.Text;
+using Org.Apache.Reef.Driver.Task;
+using Org.Apache.Reef.Tang.Annotations;
+
+namespace Org.Apache.Reef.Examples.HelloCLRBridge
+{
+ public class HelloTaskMessageHandler : IObserver<ITaskMessage>
+ {
+ [Inject]
+ public HelloTaskMessageHandler()
+ {
+ }
+
+ public void OnNext(ITaskMessage taskMessage)
+ {
+ Console.WriteLine(string.Format(
+ CultureInfo.InvariantCulture,
+ "CLR HelloTaskMessageHandler received following message from Task: {0}, Message: {1}.",
+ taskMessage.TaskId,
+ Encoding.UTF8.GetString(taskMessage.Message)));
+ }
+
+ public void OnCompleted()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnError(Exception error)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/Properties/AssemblyInfo.cs b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..726f304
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/Properties/AssemblyInfo.cs
@@ -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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("RetainedEvalCLRBridge")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("RetainedEvalCLRBridge")]
+[assembly: AssemblyCopyright("Copyright © 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("636170aa-ea18-45bf-b345-83dae7fb6a03")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/RetainedEvalCLRBridge.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/RetainedEvalCLRBridge.csproj b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/RetainedEvalCLRBridge.csproj
new file mode 100644
index 0000000..c463f84
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/RetainedEvalCLRBridge.csproj
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{A33C20FB-A76E-494C-80C5-BCE4BAD876D3}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Org.Apache.Reef.Examples.RetainedEvalCLRBridge</RootNamespace>
+ <AssemblyName>Org.Apache.Reef.Examples.RetainedEvalCLRBridge</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>..\..\..\..\bin\Debug\Org.Apache.Reef.Examples.RetainedEvalCLRBridge\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>..\..\..\..\bin\Release\Microsoft.Reef.Examples.RetainedEvalCLRBridge\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="handler\RetainedEvalActiveContextHandler.cs" />
+ <Compile Include="handler\RetainedEvalAllocatedEvaluatorHandler.cs" />
+ <Compile Include="handler\RetainedEvalEvaluatorRequestorHandler.cs" />
+ <Compile Include="handler\RetainedEvalStartHandler.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\Tang\Tang\Tang.csproj">
+ <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+ <Name>Tang</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\Utilities\Utilities.csproj">
+ <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+ <Name>Utilities</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\reef-common\ReefCommon\ReefCommon.csproj">
+ <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+ <Name>ReefCommon</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\reef-common\ReefDriver\ReefDriver.csproj">
+ <Project>{a6baa2a7-f52f-4329-884e-1bcf711d6805}</Project>
+ <Name>ReefDriver</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\reef-tasks\Tasks\Tasks.csproj">
+ <Project>{75503f90-7b82-4762-9997-94b5c68f15db}</Project>
+ <Name>Tasks</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalActiveContextHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalActiveContextHandler.cs b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalActiveContextHandler.cs
new file mode 100644
index 0000000..2647ff6
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalActiveContextHandler.cs
@@ -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.
+ */
+
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tang.Implementations;
+using Org.Apache.Reef.Tang.Interface;
+using Org.Apache.Reef.Tang.Util;
+using System;
+
+namespace Org.Apache.Reef.Examples.RetainedEvalBridge
+{
+ public class RetainedEvalActiveContextHandler : IObserver<IActiveContext>
+ {
+ public void OnNext(IActiveContext activeContext)
+ {
+ ICsConfigurationBuilder cb = TangFactory.GetTang().NewConfigurationBuilder();
+ cb.AddConfiguration(TaskConfiguration.ConfigurationModule
+ .Set(TaskConfiguration.Identifier, "bridgeCLRShellTask_" + DateTime.Now.Ticks)
+ .Set(TaskConfiguration.Task, GenericType<ShellTask>.Class)
+ .Build());
+ cb.BindNamedParameter<ShellTask.Command, string>(GenericType<ShellTask.Command>.Class, "echo");
+
+ IConfiguration taskConfiguration = cb.Build();
+
+ activeContext.SubmitTask(taskConfiguration);
+ }
+
+ public void OnError(Exception error)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnCompleted()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalAllocatedEvaluatorHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalAllocatedEvaluatorHandler.cs b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalAllocatedEvaluatorHandler.cs
new file mode 100644
index 0000000..c9b63c4
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalAllocatedEvaluatorHandler.cs
@@ -0,0 +1,48 @@
+/**
+ * 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.
+ */
+
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Tang.Interface;
+using System;
+
+namespace Org.Apache.Reef.Examples.RetainedEvalBridge
+{
+ public class RetainedEvalAllocatedEvaluatorHandler : IObserver<IAllocatedEvaluator>
+ {
+ public void OnCompleted()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnError(Exception error)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnNext(IAllocatedEvaluator allocatedEvaluator)
+ {
+ IConfiguration contextConfiguration = ContextConfiguration.ConfigurationModule
+ .Set(ContextConfiguration.Identifier, "RetainedEvalCLRBridgeContextId")
+ .Build();
+
+ allocatedEvaluator.SubmitContext(contextConfiguration);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalEvaluatorRequestorHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalEvaluatorRequestorHandler.cs b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalEvaluatorRequestorHandler.cs
new file mode 100644
index 0000000..884f304
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalEvaluatorRequestorHandler.cs
@@ -0,0 +1,48 @@
+/**
+ * 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.
+ */
+
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Evaluator;
+using System;
+
+namespace Org.Apache.Reef.Examples.RetainedEvalCLRBridge
+{
+ public class RetainedEvalEvaluatorRequestorHandler : IObserver<IEvaluatorRequestor>
+ {
+ public void OnNext(IEvaluatorRequestor requestor)
+ {
+ int evaluatorsNumber = 1;
+ int memory = 512;
+ string rack = "WonderlandRack";
+ EvaluatorRequest request = new EvaluatorRequest(evaluatorsNumber, memory, rack);
+
+ requestor.Submit(request);
+ }
+
+ public void OnCompleted()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnError(Exception error)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalStartHandler.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalStartHandler.cs b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalStartHandler.cs
new file mode 100644
index 0000000..3ff3cd6
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-examples/RetainedEvalCLRBridge/handler/RetainedEvalStartHandler.cs
@@ -0,0 +1,90 @@
+/**
+ * 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.
+ */
+
+using Org.Apache.Reef.Driver;
+using Org.Apache.Reef.Driver.Bridge;
+using Org.Apache.Reef.Driver.Context;
+using Org.Apache.Reef.Driver.Evaluator;
+using Org.Apache.Reef.Examples.RetainedEvalBridge;
+using Org.Apache.Reef.Examples.RetainedEvalCLRBridge;
+using Org.Apache.Reef.Tasks;
+using Org.Apache.Reef.Tang.Annotations;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Org.Apache.Reef.Interop.Examples.RetainedEval
+{
+ public class RetainedEvalStartHandler : IStartHandler
+ {
+ private static ClrSystemHandler<IEvaluatorRequestor> _evaluatorRequestorHandler;
+ private static ClrSystemHandler<IAllocatedEvaluator> _allocatedEvaluatorHandler;
+ private static ClrSystemHandler<IActiveContext> _activeContextHandler;
+
+ [Inject]
+ public RetainedEvalStartHandler()
+ {
+ CreateClassHierarchy();
+ Identifier = "RetainedEvalStartHandler";
+ }
+
+ public RetainedEvalStartHandler(string id)
+ {
+ Identifier = id;
+ CreateClassHierarchy();
+ }
+
+ public string Identifier { get; set; }
+
+ public IList<ulong> GetHandlers()
+ {
+ ulong[] handlers = Enumerable.Repeat(Constants.NullHandler, Constants.HandlersNumber).ToArray();
+
+ // initiate Evaluator Requestor handler
+ _evaluatorRequestorHandler = new ClrSystemHandler<IEvaluatorRequestor>();
+ handlers[Constants.Handlers[Constants.EvaluatorRequestorHandler]] = ClrHandlerHelper.CreateHandler(_evaluatorRequestorHandler);
+ Console.WriteLine("_evaluatorRequestorHandler initiated");
+ _evaluatorRequestorHandler.Subscribe(new RetainedEvalEvaluatorRequestorHandler());
+
+ // initiate Allocated Evaluator handler
+ _allocatedEvaluatorHandler = new ClrSystemHandler<IAllocatedEvaluator>();
+ handlers[Constants.Handlers[Constants.AllocatedEvaluatorHandler]] = ClrHandlerHelper.CreateHandler(_allocatedEvaluatorHandler);
+ Console.WriteLine("_allocatedEvaluatorHandler initiated");
+ _allocatedEvaluatorHandler.Subscribe(new RetainedEvalAllocatedEvaluatorHandler());
+
+ // initiate Active Context handler
+ _activeContextHandler = new ClrSystemHandler<IActiveContext>();
+ handlers[Constants.Handlers[Constants.ActiveContextHandler]] = ClrHandlerHelper.CreateHandler(_activeContextHandler);
+ Console.WriteLine("_activeContextHandler initiated");
+ _activeContextHandler.Subscribe(new RetainedEvalActiveContextHandler());
+
+ return handlers;
+ }
+
+ private void CreateClassHierarchy()
+ {
+ HashSet<string> clrDlls = new HashSet<string>();
+ clrDlls.Add(typeof(IDriver).Assembly.GetName().Name);
+ clrDlls.Add(typeof(ITask).Assembly.GetName().Name);
+ clrDlls.Add(typeof(ShellTask).Assembly.GetName().Name);
+
+ ClrHandlerHelper.GenerateClassHierarchy(clrDlls);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupRequestCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupRequestCodec.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupRequestCodec.cs
new file mode 100644
index 0000000..a518e2e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupRequestCodec.cs
@@ -0,0 +1,41 @@
+/**
+ * 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.
+ */
+
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Wake.Remote;
+using org.apache.reef.io.network.naming.avro;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Codec
+{
+ internal class NamingLookupRequestCodec : ICodec<NamingLookupRequest>
+ {
+ public byte[] Encode(NamingLookupRequest obj)
+ {
+ var request = new AvroNamingLookupRequest { ids = obj.Identifiers };
+ return AvroUtils.AvroSerialize(request);
+ }
+
+ public NamingLookupRequest Decode(byte[] data)
+ {
+ AvroNamingLookupRequest request = AvroUtils.AvroDeserialize<AvroNamingLookupRequest>(data);
+ return new NamingLookupRequest(request.ids);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupResponseCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupResponseCodec.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupResponseCodec.cs
new file mode 100644
index 0000000..e4c59df
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingLookupResponseCodec.cs
@@ -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.
+ */
+
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Wake.Remote;
+using System.Collections.Generic;
+using System.Linq;
+using org.apache.reef.io.network.naming.avro;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Codec
+{
+ internal class NamingLookupResponseCodec : ICodec<NamingLookupResponse>
+ {
+ public byte[] Encode(NamingLookupResponse obj)
+ {
+ List<AvroNamingAssignment> tuples = obj.NameAssignments
+ .Select(assignment => new AvroNamingAssignment()
+ {
+ id = assignment.Identifier,
+ host = assignment.Endpoint.Address.ToString(),
+ port = assignment.Endpoint.Port
+ }).ToList();
+
+ AvroNamingLookupResponse response = new AvroNamingLookupResponse { tuples = tuples };
+ return AvroUtils.AvroSerialize(response);
+ }
+
+ public NamingLookupResponse Decode(byte[] data)
+ {
+ AvroNamingLookupResponse response = AvroUtils.AvroDeserialize<AvroNamingLookupResponse>(data);
+ List<NameAssignment> assignments =
+ response.tuples.Select(x => new NameAssignment(x.id, x.host, x.port)).ToList();
+
+ return new NamingLookupResponse(assignments);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterRequestCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterRequestCodec.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterRequestCodec.cs
new file mode 100644
index 0000000..f75a8d5
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterRequestCodec.cs
@@ -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.
+ */
+
+using Org.Apache.Reef.Common.io;
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Wake.Remote;
+using org.apache.reef.io.network.naming.avro;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Codec
+{
+ internal class NamingRegisterRequestCodec : ICodec<NamingRegisterRequest>
+ {
+ public byte[] Encode(NamingRegisterRequest obj)
+ {
+ AvroNamingRegisterRequest request = new AvroNamingRegisterRequest
+ {
+ id = obj.NameAssignment.Identifier,
+ host = obj.NameAssignment.Endpoint.Address.ToString(),
+ port = obj.NameAssignment.Endpoint.Port
+ };
+ return AvroUtils.AvroSerialize(request);
+ }
+
+ public NamingRegisterRequest Decode(byte[] data)
+ {
+ AvroNamingRegisterRequest request = AvroUtils.AvroDeserialize<AvroNamingRegisterRequest>(data);
+ return new NamingRegisterRequest(new NameAssignment(request.id, request.host, request.port));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterResponseCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterResponseCodec.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterResponseCodec.cs
new file mode 100644
index 0000000..877abdd
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingRegisterResponseCodec.cs
@@ -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.
+ */
+
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Wake.Remote;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Codec
+{
+ internal class NamingRegisterResponseCodec : ICodec<NamingRegisterResponse>
+ {
+ private NamingRegisterRequestCodec _codec;
+
+ public NamingRegisterResponseCodec(NamingRegisterRequestCodec codec)
+ {
+ _codec = codec;
+ }
+
+ public byte[] Encode(NamingRegisterResponse obj)
+ {
+ return _codec.Encode(obj.Request);
+ }
+
+ public NamingRegisterResponse Decode(byte[] data)
+ {
+ return new NamingRegisterResponse(_codec.Decode(data));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingUnregisterRequestCodec.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingUnregisterRequestCodec.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingUnregisterRequestCodec.cs
new file mode 100644
index 0000000..9512660
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Codec/NamingUnregisterRequestCodec.cs
@@ -0,0 +1,41 @@
+/**
+ * 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.
+ */
+
+using Org.Apache.Reef.IO.Network.Naming.Events;
+using Org.Apache.Reef.Utilities;
+using Org.Apache.Reef.Wake.Remote;
+using org.apache.reef.io.network.naming.avro;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Codec
+{
+ internal class NamingUnregisterRequestCodec : ICodec<NamingUnregisterRequest>
+ {
+ public byte[] Encode(NamingUnregisterRequest obj)
+ {
+ AvroNamingUnRegisterRequest request = new AvroNamingUnRegisterRequest { id = obj.Identifier };
+ return AvroUtils.AvroSerialize(request);
+ }
+
+ public NamingUnregisterRequest Decode(byte[] data)
+ {
+ AvroNamingUnRegisterRequest request = AvroUtils.AvroDeserialize<AvroNamingUnRegisterRequest>(data);
+ return new NamingUnregisterRequest(request.id);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingAssignment.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingAssignment.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingAssignment.cs
new file mode 100644
index 0000000..5cfd5ab
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingAssignment.cs
@@ -0,0 +1,62 @@
+/**
+ * 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.
+ */
+
+using System.Runtime.Serialization;
+
+//---------- Auto-generated ------------
+namespace org.apache.reef.io.network.naming.avro
+{
+ /// <summary>
+ /// Used to serialize and deserialize Avro record org.apache.reef.io.network.naming.avro.AvroNamingAssignment.
+ /// </summary>
+ [DataContract]
+ public class AvroNamingAssignment
+ {
+ private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.io.network.naming.avro.AvroNamingAssignment"",""fields"":[{""name"":""id"",""type"":""string""},{""name"":""host"",""type"":""string""},{""name"":""port"",""type"":""int""}]}";
+
+ /// <summary>
+ /// Gets the schema.
+ /// </summary>
+ public static string Schema
+ {
+ get
+ {
+ return JsonSchema;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the id field.
+ /// </summary>
+ [DataMember]
+ public string id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the host field.
+ /// </summary>
+ [DataMember]
+ public string host { get; set; }
+
+ /// <summary>
+ /// Gets or sets the port field.
+ /// </summary>
+ [DataMember]
+ public int port { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupRequest.cs
new file mode 100644
index 0000000..0698fd6
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupRequest.cs
@@ -0,0 +1,51 @@
+/**
+ * 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.
+ */
+
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+//---------- Auto-generated ------------
+namespace org.apache.reef.io.network.naming.avro
+{
+ /// <summary>
+ /// Used to serialize and deserialize Avro record org.apache.reef.io.network.naming.avro.AvroNamingLookupRequest.
+ /// </summary>
+ [DataContract]
+ public class AvroNamingLookupRequest
+ {
+ private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.io.network.naming.avro.AvroNamingLookupRequest"",""fields"":[{""name"":""ids"",""type"":{""type"":""array"",""items"":""string""}}]}";
+
+ /// <summary>
+ /// Gets the schema.
+ /// </summary>
+ public static string Schema
+ {
+ get
+ {
+ return JsonSchema;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the ids field.
+ /// </summary>
+ [DataMember]
+ public List<string> ids { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupResponse.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupResponse.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupResponse.cs
new file mode 100644
index 0000000..4599faa
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingLookupResponse.cs
@@ -0,0 +1,51 @@
+/**
+ * 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.
+ */
+
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+//---------- Auto-generated ------------
+namespace org.apache.reef.io.network.naming.avro
+{
+ /// <summary>
+ /// Used to serialize and deserialize Avro record org.apache.reef.io.network.naming.avro.AvroNamingLookupResponse.
+ /// </summary>
+ [DataContract]
+ public class AvroNamingLookupResponse
+ {
+ private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.io.network.naming.avro.AvroNamingLookupResponse"",""fields"":[{""name"":""tuples"",""type"":{""type"":""array"",""items"":{""type"":""record"",""name"":""org.apache.reef.io.network.naming.avro.AvroNamingAssignment"",""fields"":[{""name"":""id"",""type"":""string""},{""name"":""host"",""type"":""string""},{""name"":""port"",""type"":""int""}]}}}]}";
+
+ /// <summary>
+ /// Gets the schema.
+ /// </summary>
+ public static string Schema
+ {
+ get
+ {
+ return JsonSchema;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the tuples field.
+ /// </summary>
+ [DataMember]
+ public List<AvroNamingAssignment> tuples { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingRegisterRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingRegisterRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingRegisterRequest.cs
new file mode 100644
index 0000000..76f14be
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingRegisterRequest.cs
@@ -0,0 +1,62 @@
+/**
+ * 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.
+ */
+
+using System.Runtime.Serialization;
+
+//---------- Auto-generated ------------
+namespace org.apache.reef.io.network.naming.avro
+{
+ /// <summary>
+ /// Used to serialize and deserialize Avro record org.apache.reef.io.network.naming.avro.AvroNamingRegisterRequest.
+ /// </summary>
+ [DataContract]
+ public class AvroNamingRegisterRequest
+ {
+ private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.io.network.naming.avro.AvroNamingRegisterRequest"",""fields"":[{""name"":""id"",""type"":""string""},{""name"":""host"",""type"":""string""},{""name"":""port"",""type"":""int""}]}";
+
+ /// <summary>
+ /// Gets the schema.
+ /// </summary>
+ public static string Schema
+ {
+ get
+ {
+ return JsonSchema;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the id field.
+ /// </summary>
+ [DataMember]
+ public string id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the host field.
+ /// </summary>
+ [DataMember]
+ public string host { get; set; }
+
+ /// <summary>
+ /// Gets or sets the port field.
+ /// </summary>
+ [DataMember]
+ public int port { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingUnRegisterRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingUnRegisterRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingUnRegisterRequest.cs
new file mode 100644
index 0000000..299e940
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Contracts/AvroNamingUnRegisterRequest.cs
@@ -0,0 +1,50 @@
+/**
+ * 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.
+ */
+
+using System.Runtime.Serialization;
+
+//---------- Auto-generated ------------
+namespace org.apache.reef.io.network.naming.avro
+{
+ /// <summary>
+ /// Used to serialize and deserialize Avro record org.apache.reef.io.network.naming.avro.AvroNamingUnRegisterRequest.
+ /// </summary>
+ [DataContract]
+ public class AvroNamingUnRegisterRequest
+ {
+ private const string JsonSchema = @"{""type"":""record"",""name"":""org.apache.reef.io.network.naming.avro.AvroNamingUnRegisterRequest"",""fields"":[{""name"":""id"",""type"":""string""}]}";
+
+ /// <summary>
+ /// Gets the schema.
+ /// </summary>
+ public static string Schema
+ {
+ get
+ {
+ return JsonSchema;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the id field.
+ /// </summary>
+ [DataMember]
+ public string id { get; set; }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingEvent.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingEvent.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingEvent.cs
new file mode 100644
index 0000000..5c992f2
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingEvent.cs
@@ -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.
+ */
+
+using Org.Apache.Reef.Wake.Remote;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+ /// <summary>
+ /// Event representing a lookup, registering, or unregistering of
+ /// an identifier with the Name Service.
+ /// </summary>
+ internal class NamingEvent
+ {
+ /// <summary>
+ /// The link for communication between the NameClient and NameServer
+ /// </summary>
+ public ILink<NamingEvent> Link { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllRequest.cs
new file mode 100644
index 0000000..d680810
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllRequest.cs
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+ /// <summary>
+ /// Event to request all registered identifiers and their mapped
+ /// IPEndpoints
+ /// </summary>
+ internal class NamingGetAllRequest : NamingEvent
+ {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllResponse.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllResponse.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllResponse.cs
new file mode 100644
index 0000000..08e608e
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingGetAllResponse.cs
@@ -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.
+ */
+
+using System.Collections.Generic;
+using Org.Apache.Reef.Common.io;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+ /// <summary>
+ /// Response event for looking up all registered identifiers and their
+ /// mapped IPEndpoints
+ /// </summary>
+ internal class NamingGetAllResponse : NamingEvent
+ {
+ public NamingGetAllResponse(List<NameAssignment> assignments)
+ {
+ Assignments = assignments;
+ }
+
+ public List<NameAssignment> Assignments { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupRequest.cs
new file mode 100644
index 0000000..9f9e184
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupRequest.cs
@@ -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.
+ */
+
+using System.Collections.Generic;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+ /// <summary>
+ /// Event to request look up of IPEndpoints in the Name Service
+ /// </summary>
+ internal class NamingLookupRequest : NamingEvent
+ {
+ public NamingLookupRequest(List<string> ids)
+ {
+ Identifiers = ids;
+ }
+
+ public List<string> Identifiers { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupResponse.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupResponse.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupResponse.cs
new file mode 100644
index 0000000..872c8c7
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingLookupResponse.cs
@@ -0,0 +1,39 @@
+/**
+ * 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.
+ */
+
+using System.Collections.Generic;
+using Microsoft.Hadoop.Avro;
+using Org.Apache.Reef.Common.io;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+ /// <summary>
+ /// Event for lookup response in Name Service.
+ /// </summary>
+ internal class NamingLookupResponse : NamingEvent
+ {
+ public NamingLookupResponse(List<NameAssignment> nameAssignments)
+ {
+ NameAssignments = nameAssignments;
+ }
+
+ [NullableSchema]
+ public List<NameAssignment> NameAssignments { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterRequest.cs
new file mode 100644
index 0000000..3da980b
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterRequest.cs
@@ -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.
+ */
+
+using Org.Apache.Reef.Common.io;
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+ /// <summary>
+ /// Event to request registering an identifier and endpoint with the Name Service
+ /// </summary>
+ internal class NamingRegisterRequest : NamingEvent
+ {
+ public NamingRegisterRequest(NameAssignment nameAssignment)
+ {
+ NameAssignment = nameAssignment;
+ }
+
+ public NameAssignment NameAssignment { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterResponse.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterResponse.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterResponse.cs
new file mode 100644
index 0000000..d879d35
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingRegisterResponse.cs
@@ -0,0 +1,34 @@
+/**
+ * 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.
+ */
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+ /// <summary>
+ /// Response event for registering an IPEndpoint with the Name Service
+ /// </summary>
+ internal class NamingRegisterResponse : NamingEvent
+ {
+ public NamingRegisterResponse(NamingRegisterRequest request)
+ {
+ Request = request;
+ }
+
+ public NamingRegisterRequest Request { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2ae282de/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingUnregisterRequest.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingUnregisterRequest.cs b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingUnregisterRequest.cs
new file mode 100644
index 0000000..966e533
--- /dev/null
+++ b/lang/cs/Source/REEF/reef-io/Network/Naming/Events/NamingUnregisterRequest.cs
@@ -0,0 +1,34 @@
+/**
+ * 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.
+ */
+
+namespace Org.Apache.Reef.IO.Network.Naming.Events
+{
+ /// <summary>
+ /// Event to request unregistering of an IPEndpoint with the Name Service
+ /// </summary>
+ internal class NamingUnregisterRequest : NamingEvent
+ {
+ public NamingUnregisterRequest(string identifier)
+ {
+ Identifier = identifier;
+ }
+
+ public string Identifier { get; set; }
+ }
+}