[REEF-139] Changing .Net project structure for Network and Evaluator

This is to change .Net project structure for Network and Evaluator
  * Move project folders under cs
  * Rename projects to follow name convention
  * Update namespace for projects
  * Update csproj file for the references
  * Fixed license exclusions with the folder structure change

JIRA:
  [REEF-139] https://issues.apache.org/jira/browse/REEF-139

Pull Request:
  This closes #69


Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/b6c4e983
Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/b6c4e983
Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/b6c4e983

Branch: refs/heads/master
Commit: b6c4e983879a0f38983b123f9b55514892442b61
Parents: c1b5200
Author: Julia Wang <[email protected]>
Authored: Thu Feb 5 14:38:44 2015 -0800
Committer: Markus Weimer <[email protected]>
Committed: Thu Feb 5 17:31:18 2015 -0800

----------------------------------------------------------------------
 .../bridge/ClrHandlerHelper.cs                  |   2 +-
 lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs  | 261 +++++++++++++++++
 .../Org.Apache.REEF.Evaluator.csproj            | 124 +++++++++
 .../Properties/AssemblyInfo.cs                  |  55 ++++
 .../Org.Apache.REEF.Evaluator/packages.config   |  22 ++
 .../Naming/Codec/NamingLookupRequestCodec.cs    |  41 +++
 .../Naming/Codec/NamingLookupResponseCodec.cs   |  55 ++++
 .../Naming/Codec/NamingRegisterRequestCodec.cs  |  47 ++++
 .../Naming/Codec/NamingRegisterResponseCodec.cs |  44 +++
 .../Codec/NamingUnregisterRequestCodec.cs       |  41 +++
 .../Naming/Contracts/AvroNamingAssignment.cs    |  62 +++++
 .../Naming/Contracts/AvroNamingLookupRequest.cs |  51 ++++
 .../Contracts/AvroNamingLookupResponse.cs       |  51 ++++
 .../Contracts/AvroNamingRegisterRequest.cs      |  62 +++++
 .../Contracts/AvroNamingUnRegisterRequest.cs    |  50 ++++
 .../Naming/Events/NamingEvent.cs                |  35 +++
 .../Naming/Events/NamingGetAllRequest.cs        |  29 ++
 .../Naming/Events/NamingGetAllResponse.cs       |  38 +++
 .../Naming/Events/NamingLookupRequest.cs        |  36 +++
 .../Naming/Events/NamingLookupResponse.cs       |  39 +++
 .../Naming/Events/NamingRegisterRequest.cs      |  36 +++
 .../Naming/Events/NamingRegisterResponse.cs     |  34 +++
 .../Naming/Events/NamingUnregisterRequest.cs    |  34 +++
 .../Naming/Events/NamingUnregisterResponse.cs   |  34 +++
 .../Naming/INameServer.cs                       |  69 +++++
 .../Naming/NameClient.cs                        | 279 +++++++++++++++++++
 .../Naming/NameLookupClient.cs                  |  97 +++++++
 .../Naming/NameRegisterClient.cs                |  67 +++++
 .../Naming/NameServer.cs                        | 196 +++++++++++++
 .../Naming/NamingConfiguration.cs               |  50 ++++
 .../Naming/NamingConfigurationOptions.cs        |  41 +++
 .../Observers/NamingGetAllRequestObserver.cs    |  47 ++++
 .../Observers/NamingLookupRequestObserver.cs    |  50 ++++
 .../Observers/NamingRegisterRequestObserver.cs  |  51 ++++
 .../NamingUnregisterRequestObserver.cs          |  47 ++++
 .../NetworkService/Codec/ControlMessageCodec.cs |  43 +++
 .../NetworkService/Codec/NsMessageCodec.cs      |  85 ++++++
 .../NetworkService/Codec/NsMessageProto.cs      |  63 +++++
 .../NetworkService/ControlMessage.cs            |  39 +++
 .../NetworkService/IConnection.cs               |  40 +++
 .../NetworkService/INetworkService.cs           |  58 ++++
 .../NetworkService/NetworkService.cs            | 156 +++++++++++
 .../NetworkServiceConfiguration.cs              |  57 ++++
 .../NetworkService/NetworkServiceOptions.cs     |  33 +++
 .../NetworkService/NsConnection.cs              | 139 +++++++++
 .../NetworkService/NsMessage.cs                 |  71 +++++
 .../Org.Apache.REEF.Network.csproj              | 184 ++++++++++++
 .../Properties/AssemblyInfo.cs                  |  55 ++++
 .../Utilities/BlockingCollectionExtensions.cs   |  78 ++++++
 .../Org.Apache.REEF.Network/Utilities/Utils.cs  |  76 +++++
 lang/cs/Org.Apache.REEF.Network/packages.config |  26 ++
 lang/cs/ReefDotNet.sln                          |  40 +--
 .../CLRBridgeClient/CLRBridgeClient.cs          |   2 +-
 .../CLRBridgeClient/CLRBridgeClient.csproj      |   8 +-
 .../reef-applications/Evaluator/Evaluator.cs    | 261 -----------------
 .../Evaluator/Evaluator.csproj                  | 124 ---------
 .../Evaluator/Properties/AssemblyInfo.cs        |  55 ----
 .../reef-applications/Evaluator/packages.config |  22 --
 .../HelloCLRBridge/HelloCLRBridge.csproj        |   8 +-
 .../handlers/HelloAllocatedEvaluatorHandler.cs  |   2 +-
 .../handlers/HelloSimpleEventHandlers.cs        |   2 +-
 .../handlers/HelloStartHandler.cs               |   2 +-
 .../Naming/Codec/NamingLookupRequestCodec.cs    |  41 ---
 .../Naming/Codec/NamingLookupResponseCodec.cs   |  55 ----
 .../Naming/Codec/NamingRegisterRequestCodec.cs  |  47 ----
 .../Naming/Codec/NamingRegisterResponseCodec.cs |  44 ---
 .../Codec/NamingUnregisterRequestCodec.cs       |  41 ---
 .../Naming/Contracts/AvroNamingAssignment.cs    |  62 -----
 .../Naming/Contracts/AvroNamingLookupRequest.cs |  51 ----
 .../Contracts/AvroNamingLookupResponse.cs       |  51 ----
 .../Contracts/AvroNamingRegisterRequest.cs      |  62 -----
 .../Contracts/AvroNamingUnRegisterRequest.cs    |  50 ----
 .../Network/Naming/Events/NamingEvent.cs        |  35 ---
 .../Naming/Events/NamingGetAllRequest.cs        |  29 --
 .../Naming/Events/NamingGetAllResponse.cs       |  38 ---
 .../Naming/Events/NamingLookupRequest.cs        |  36 ---
 .../Naming/Events/NamingLookupResponse.cs       |  39 ---
 .../Naming/Events/NamingRegisterRequest.cs      |  36 ---
 .../Naming/Events/NamingRegisterResponse.cs     |  34 ---
 .../Naming/Events/NamingUnregisterRequest.cs    |  34 ---
 .../Naming/Events/NamingUnregisterResponse.cs   |  34 ---
 .../REEF/reef-io/Network/Naming/INameServer.cs  |  69 -----
 .../REEF/reef-io/Network/Naming/NameClient.cs   | 279 -------------------
 .../reef-io/Network/Naming/NameLookupClient.cs  |  97 -------
 .../Network/Naming/NameRegisterClient.cs        |  67 -----
 .../REEF/reef-io/Network/Naming/NameServer.cs   | 196 -------------
 .../Network/Naming/NamingConfiguration.cs       |  50 ----
 .../Naming/NamingConfigurationOptions.cs        |  41 ---
 .../Observers/NamingGetAllRequestObserver.cs    |  47 ----
 .../Observers/NamingLookupRequestObserver.cs    |  50 ----
 .../Observers/NamingRegisterRequestObserver.cs  |  51 ----
 .../NamingUnregisterRequestObserver.cs          |  47 ----
 .../Source/REEF/reef-io/Network/Network.csproj  | 180 ------------
 .../NetworkService/Codec/ControlMessageCodec.cs |  43 ---
 .../NetworkService/Codec/NsMessageCodec.cs      |  85 ------
 .../NetworkService/Codec/NsMessageProto.cs      |  63 -----
 .../Network/NetworkService/ControlMessage.cs    |  39 ---
 .../Network/NetworkService/IConnection.cs       |  40 ---
 .../Network/NetworkService/INetworkService.cs   |  58 ----
 .../Network/NetworkService/NetworkService.cs    | 156 -----------
 .../NetworkServiceConfiguration.cs              |  57 ----
 .../NetworkService/NetworkServiceOptions.cs     |  33 ---
 .../Network/NetworkService/NsConnection.cs      | 139 ---------
 .../reef-io/Network/NetworkService/NsMessage.cs |  71 -----
 .../reef-io/Network/Properties/AssemblyInfo.cs  |  55 ----
 .../Utilities/BlockingCollectionExtensions.cs   |  78 ------
 .../REEF/reef-io/Network/Utilities/Utils.cs     |  76 -----
 .../Source/REEF/reef-io/Network/packages.config |  26 --
 lang/cs/Source/Tools/ReefAll/ReefAll.csproj     |  36 +--
 .../Bridge/TestSimpleEventHandlers.cs           |   2 +-
 .../Functional.Tests/Messaging/MessageDriver.cs |   2 +-
 .../Functional.Tests/Messaging/MessageTask.cs   |   2 +-
 .../BlockingCollectionExtensionTests.cs         |   2 +-
 .../Tests/ReefTests/IO.Tests/NameServerTests.cs |   4 +-
 .../ReefTests/IO.Tests/NetworkServiceTests.cs   |   4 +-
 lang/cs/Tests/ReefTests/ReefTests.csproj        |  16 +-
 pom.xml                                         |   5 +-
 117 files changed, 3550 insertions(+), 3541 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/b6c4e983/lang/cs/Org.Apache.REEF.Driver/bridge/ClrHandlerHelper.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/bridge/ClrHandlerHelper.cs 
b/lang/cs/Org.Apache.REEF.Driver/bridge/ClrHandlerHelper.cs
index c6dd02f..8d9020c 100644
--- a/lang/cs/Org.Apache.REEF.Driver/bridge/ClrHandlerHelper.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/bridge/ClrHandlerHelper.cs
@@ -43,7 +43,7 @@ namespace Org.Apache.REEF.Driver.Bridge
         {
             get
             {
-                return new[] { "Microsoft.Hadoop.Avro.dll", 
"Org.Apache.REEF.Driver.dll", "Org.Apache.REEF.Common.dll", 
"Org.Apache.REEF.Utilities.dll", "Org.Apache.REEF.IO.Network.dll", 
"Org.Apache.REEF.Tang.dll", "Org.Apache.REEF.Wake.dll", "Newtonsoft.Json.dll", 
"protobuf-net.dll" };
+                return new[] { "Microsoft.Hadoop.Avro.dll", 
"Org.Apache.REEF.Driver.dll", "Org.Apache.REEF.Common.dll", 
"Org.Apache.REEF.Utilities.dll", "Org.Apache.REEF.Network.dll", 
"Org.Apache.REEF.Tang.dll", "Org.Apache.REEF.Wake.dll", "Newtonsoft.Json.dll", 
"protobuf-net.dll" };
             }
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/b6c4e983/lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs 
b/lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs
new file mode 100644
index 0000000..39ebfc3
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs
@@ -0,0 +1,261 @@
+/**
+ * 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;
+using Org.Apache.REEF.Common.Context;
+using Org.Apache.REEF.Common.Evaluator.Context;
+using Org.Apache.REEF.Common.ProtoBuf.ReefProtocol;
+using Org.Apache.REEF.Driver.Bridge;
+using Org.Apache.REEF.Services;
+using Org.Apache.REEF.Tang.Formats;
+using Org.Apache.REEF.Tang.Implementations.InjectionPlan;
+using Org.Apache.REEF.Tang.Implementations.Tang;
+using Org.Apache.REEF.Tang.Interface;
+using Org.Apache.REEF.Tasks;
+using Org.Apache.REEF.Utilities;
+using Org.Apache.REEF.Utilities.Diagnostics;
+using Org.Apache.REEF.Utilities.Logging;
+using Org.Apache.REEF.Wake.Remote;
+using Org.Apache.REEF.Wake.Remote.Impl;
+using Org.Apache.REEF.Wake.Time.Runtime.Event;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Org.Apache.REEF.Evaluator
+{
+    public class Evaluator
+    {
+        private static Logger _logger;
+
+        private static int _heartbeatPeriodInMs = 
Constants.DefaultEvaluatorHeartbeatPeriodInMs;
+
+        private static int _heartbeatMaxRetry = 
Constants.DefaultEvaluatorHeartbeatMaxRetry;
+
+        private static IInjector _injector;
+
+        private static EvaluatorConfigurations _evaluatorConfig;
+
+        public static void Main(string[] args)
+        {
+            Console.WriteLine(string.Format(CultureInfo.InvariantCulture, 
"START: {0} Evaluator::InitInjector.", DateTime.Now));
+            Stopwatch timer = new Stopwatch();
+            InitInjector();
+            SetCustomTraceListners();
+            timer.Stop();
+            Console.WriteLine(string.Format(CultureInfo.InvariantCulture, 
"EXIT: {0} Evaluator::InitInjector. Duration: [{1}].", DateTime.Now, 
timer.Elapsed));
+
+            RuntimeClock clock;
+
+            using (_logger.LogScope("Evaluator::Main"))
+            {
+                string debugEnabledString = 
Environment.GetEnvironmentVariable("Org.Apache.REEF.EvaluatorDebug");
+                if (!string.IsNullOrWhiteSpace(debugEnabledString) &&
+                    debugEnabledString.Equals("enabled", 
StringComparison.OrdinalIgnoreCase))
+                {
+                    while (true)
+                    {
+                        if (Debugger.IsAttached)
+                        {
+                            break;
+                        }
+                        else
+                        {
+                            _logger.Log(Level.Info, "Evaluator in debug mode, 
waiting for debugger to be attached...");
+                            Thread.Sleep(2000);
+                        }
+                    }
+                }
+
+                AppDomain.CurrentDomain.UnhandledException += 
UnhandledExceptionHandler;
+
+                string heartbeatPeriodFromConfig = 
ConfigurationManager.AppSettings["EvaluatorHeartbeatPeriodInMs"];
+
+                int heartbeatPeriod = 0;
+
+                if (!string.IsNullOrWhiteSpace(heartbeatPeriodFromConfig) &&
+                    int.TryParse(heartbeatPeriodFromConfig, out 
heartbeatPeriod))
+                {
+                    _heartbeatPeriodInMs = heartbeatPeriod;
+                }
+                _logger.Log(Level.Verbose,
+                            "Evaluator heartbeat period set to be " + 
_heartbeatPeriodInMs + " milliSeconds.");
+
+                int maxHeartbeatRetry = 0;
+                string heartbeatMaxRetryFromConfig = 
ConfigurationManager.AppSettings["EvaluatorHeartbeatRetryMaxTimes"];
+
+                if (!string.IsNullOrWhiteSpace(heartbeatMaxRetryFromConfig) &&
+                    int.TryParse(heartbeatMaxRetryFromConfig, out 
maxHeartbeatRetry))
+                {
+                    _heartbeatMaxRetry = maxHeartbeatRetry;
+                }
+                _logger.Log(Level.Verbose, "Evaluator heatrbeat max retry set 
to be " + _heartbeatMaxRetry + " times.");
+
+                if (args.Count() < 2)
+                {
+                    var e = new InvalidOperationException("must supply at 
least the rId and evaluator config file");
+                    Exceptions.Throw(e, _logger);
+                }
+
+                // remote driver Id
+                string rId = args[0];
+
+                // evaluator configuraiton file
+                string evaluatorConfigurationPath = args[1];
+
+                ICodec<REEFMessage> reefMessageCodec = new REEFMessageCodec();
+
+                _evaluatorConfig = new 
EvaluatorConfigurations(evaluatorConfigurationPath);
+
+                string rootContextConfigString = 
_evaluatorConfig.RootContextConfiguration;
+                if (string.IsNullOrWhiteSpace(rootContextConfigString))
+                {
+                    Exceptions.Throw(new ArgumentException("empty or null 
rootContextConfigString"), _logger);
+                }
+                ContextConfiguration rootContextConfiguration = new 
ContextConfiguration(rootContextConfigString);
+
+                string taskConfig = _evaluatorConfig.TaskConfiguration;
+                Optional<TaskConfiguration> rootTaskConfig = 
string.IsNullOrEmpty(taskConfig)
+                                        ? Optional<TaskConfiguration>.Empty()
+                                        : Optional<TaskConfiguration>.Of(
+                                            new TaskConfiguration(taskConfig));
+                string rootServiceConfigString = 
_evaluatorConfig.RootServiceConfiguration;
+                Optional<ServiceConfiguration> rootServiceConfig = 
string.IsNullOrEmpty(rootServiceConfigString)
+                                        ? 
Optional<ServiceConfiguration>.Empty()
+                                        : Optional<ServiceConfiguration>.Of(
+                                            new ServiceConfiguration(
+                                                rootServiceConfigString));
+ 
+                // remoteManager used as client-only in evaluator
+                IRemoteManager<REEFMessage> remoteManager = new 
DefaultRemoteManager<REEFMessage>(reefMessageCodec);
+                IRemoteIdentifier remoteId = new 
SocketRemoteIdentifier(NetUtilities.ParseIpEndpoint(rId));
+
+                ConfigurationModule module = new 
ConfigurationModuleBuilder().Build();
+                IConfiguration clockConfiguraiton = module.Build();
+
+                clock =
+                    
TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance<RuntimeClock>();
+                    _logger.Log(Level.Info, "Application Id: " + 
_evaluatorConfig.ApplicationId);
+
+                EvaluatorSettings evaluatorSettings = new EvaluatorSettings(
+                    _evaluatorConfig.ApplicationId,
+                    _evaluatorConfig.EvaluatorId,
+                    _heartbeatPeriodInMs,
+                    _heartbeatMaxRetry,
+                    rootContextConfiguration,
+                    clock,
+                    remoteManager,
+                    _injector);
+
+                HeartBeatManager heartBeatManager = new 
HeartBeatManager(evaluatorSettings, remoteId);
+                ContextManager contextManager = new 
ContextManager(heartBeatManager, rootServiceConfig, rootTaskConfig);
+                EvaluatorRuntime evaluatorRuntime = new 
EvaluatorRuntime(contextManager, heartBeatManager);
+
+                // TODO: repalce with injectionFuture
+                heartBeatManager._evaluatorRuntime = evaluatorRuntime;
+                heartBeatManager._contextManager = contextManager;
+
+                SetRuntimeHanlders(evaluatorRuntime, clock);
+            }
+
+            Task evaluatorTask = Task.Run(new Action(clock.Run));
+            evaluatorTask.Wait();            
+        }
+
+        private static void InitInjector()
+        {
+            string clrRuntimeConfigurationFile = 
Path.Combine(Directory.GetCurrentDirectory(), "reef", "global",
+                                                                
Common.Constants.ClrBridgeRuntimeConfiguration);
+            if (!File.Exists(clrRuntimeConfigurationFile))
+            {
+                var e =
+                    new InvalidOperationException("Cannot find 
clrRuntimeConfiguration from " +
+                                                    
clrRuntimeConfigurationFile);
+                Exceptions.Throw(e, _logger);
+            }
+
+            try
+            {
+                IConfiguration clrBridgeConfiguration =
+                    new 
AvroConfigurationSerializer().FromFile(clrRuntimeConfigurationFile);
+                _injector = 
TangFactory.GetTang().NewInjector(clrBridgeConfiguration);
+            }
+            catch (Exception e)
+            {
+                Exceptions.Caught(e, Level.Error, "Cannot obtain injector from 
clr bridge configuration.", _logger);
+                Exceptions.Throw(
+                    new InvalidOperationException("Cannot obtain injector from 
clr bridge configuration.", e),
+                    _logger);
+            }
+        }
+
+        private static void SetCustomTraceListners()
+        {
+            ISet<TraceListener> customTraceListeners;
+            CustomTraceListeners listeners = null;
+            try
+            {
+                listeners = _injector.GetInstance<CustomTraceListeners>();
+                customTraceListeners = listeners.Listeners;
+            }
+            catch (Exception e)
+            {
+                Exceptions.Caught(e, Level.Error, _logger);
+                // custom trace listner not set properly, use empty set
+                customTraceListeners = new HashSet<TraceListener>();
+            }
+            foreach (TraceListener listener in customTraceListeners)
+            {
+                Logger.AddTraceListner(listener);
+            }
+            _logger = Logger.GetLogger(typeof(Evaluator));
+            CustomTraceLevel traceLevel = 
_injector.GetInstance<CustomTraceLevel>();
+            Logger.SetCustomLevel(traceLevel.TraceLevel);
+        }
+
+        private static void UnhandledExceptionHandler(object sender, 
UnhandledExceptionEventArgs e)
+        {
+            Exception ex = default(Exception);
+            ex = (Exception)e.ExceptionObject;
+            _logger.Log(Level.Error, "Unhandled exception caught in 
Evaluator.", ex);
+            Exceptions.Throw(new InvalidOperationException("Unhandled 
exception caught in Evaluator.", ex), _logger);
+        }
+
+        // set the handlers for runtimeclock manually
+        // we only need runtimestart and runtimestop handlers now
+        private static void SetRuntimeHanlders(EvaluatorRuntime 
evaluatorRuntime, RuntimeClock clock)
+        {
+            HashSet<IObserver<RuntimeStart>> runtimeStarts = new 
HashSet<IObserver<RuntimeStart>>();
+            runtimeStarts.Add(evaluatorRuntime);
+            InjectionFutureImpl<ISet<IObserver<RuntimeStart>>> 
injectRuntimeStart = new 
InjectionFutureImpl<ISet<IObserver<RuntimeStart>>>(runtimeStarts);
+            clock.InjectedRuntimeStartHandler = injectRuntimeStart;
+
+            HashSet<IObserver<RuntimeStop>> runtimeStops = new 
HashSet<IObserver<RuntimeStop>>();
+            runtimeStops.Add(evaluatorRuntime);
+            InjectionFutureImpl<ISet<IObserver<RuntimeStop>>> 
injectRuntimeStop = new 
InjectionFutureImpl<ISet<IObserver<RuntimeStop>>>(runtimeStops);
+            clock.InjectedRuntimeStopHandler = injectRuntimeStop;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/b6c4e983/lang/cs/Org.Apache.REEF.Evaluator/Org.Apache.REEF.Evaluator.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Evaluator/Org.Apache.REEF.Evaluator.csproj 
b/lang/cs/Org.Apache.REEF.Evaluator/Org.Apache.REEF.Evaluator.csproj
new file mode 100644
index 0000000..f5fc9de
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Evaluator/Org.Apache.REEF.Evaluator.csproj
@@ -0,0 +1,124 @@
+<?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>{1B983182-9C30-464C-948D-F87EB93A8240}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Org.Apache.REEF.Evaluator</RootNamespace>
+    <AssemblyName>Org.Apache.REEF.Evaluator</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <RestorePackages>true</RestorePackages>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == 
'*Undefined*'">..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <Import Project="$(SolutionDir)\Source\build.props" />
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' 
">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    
<OutputPath>$(BinDir)\$(Platform)\$(Configuration)\$(RootNamespace)</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    
<OutputPath>$(BinDir)\$(Platform)\$(Configuration)\$(RootNamespace)</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>$(BinDir)\$(Platform)\$(Configuration)\$(RootNamespace)</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    
<OutputPath>$(BinDir)\$(Platform)\$(Configuration)\$(RootNamespace)</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="protobuf-net">
+      
<HintPath>$(PackagesDir)\protobuf-net.$(ProtobufVersion)\lib\net40\protobuf-net.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Configuration" />
+    <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="Evaluator.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference 
Include="$(SolutionDir)\Org.Apache.REEF.Tang\Org.Apache.REEF.Tang.csproj">
+      <Project>{97dbb573-3994-417a-9f69-ffa25f00d2a6}</Project>
+      <Name>Org.Apache.REEF.Tang</Name>
+    </ProjectReference>
+    <ProjectReference 
Include="$(SolutionDir)\Org.Apache.REEF.Utilities\Org.Apache.REEF.Utilities.csproj">
+      <Project>{79e7f89a-1dfb-45e1-8d43-d71a954aeb98}</Project>
+      <Name>Org.Apache.REEF.Utilities</Name>
+    </ProjectReference>
+    <ProjectReference 
Include="$(SolutionDir)\Org.Apache.REEF.Common\Org.Apache.REEF.Common.csproj">
+      <Project>{545a0582-4105-44ce-b99c-b1379514a630}</Project>
+      <Name>Org.Apache.REEF.Common</Name>
+    </ProjectReference>
+    <ProjectReference 
Include="$(SolutionDir)\Org.Apache.REEF.Driver\Org.Apache.REEF.Driver.csproj">
+      <Project>{a6baa2a7-f52f-4329-884e-1bcf711d6805}</Project>
+      <Name>Org.Apache.REEF.Driver</Name>
+    </ProjectReference>
+    <ProjectReference 
Include="$(SolutionDir)\Org.Apache.REEF.Wake\Org.Apache.REEF.Wake.csproj">
+      <Project>{cdfb3464-4041-42b1-9271-83af24cd5008}</Project>
+      <Name>Org.Apache.REEF.Wake</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" 
Condition="Exists('$(SolutionDir)\.nuget\NuGet.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/b6c4e983/lang/cs/Org.Apache.REEF.Evaluator/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Evaluator/Properties/AssemblyInfo.cs 
b/lang/cs/Org.Apache.REEF.Evaluator/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..51ff356
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Evaluator/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("Evaluator")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Evaluator")]
+[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("a64dc535-9b1e-41a4-8303-117f8b28c8c0")]
+
+// 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/b6c4e983/lang/cs/Org.Apache.REEF.Evaluator/packages.config
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Evaluator/packages.config 
b/lang/cs/Org.Apache.REEF.Evaluator/packages.config
new file mode 100644
index 0000000..81b0ef5
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Evaluator/packages.config
@@ -0,0 +1,22 @@
+<?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.
+-->
+<packages>
+  <package id="protobuf-net" version="2.0.0.668" targetFramework="net45" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingLookupRequestCodec.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingLookupRequestCodec.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingLookupRequestCodec.cs
new file mode 100644
index 0000000..e411013
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.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.Network.Naming.Events;
+using Org.Apache.REEF.Utilities;
+using Org.Apache.REEF.Wake.Remote;
+using Org.Apache.REEF.Network.Naming.Contracts;
+
+namespace Org.Apache.REEF.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingLookupResponseCodec.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingLookupResponseCodec.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingLookupResponseCodec.cs
new file mode 100644
index 0000000..0ee44f2
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.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.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.Network.Naming.Contracts;
+
+namespace Org.Apache.REEF.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingRegisterRequestCodec.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingRegisterRequestCodec.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingRegisterRequestCodec.cs
new file mode 100644
index 0000000..ae07bac
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.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.Network.Naming.Events;
+using Org.Apache.REEF.Utilities;
+using Org.Apache.REEF.Wake.Remote;
+using Org.Apache.REEF.Network.Naming.Contracts;
+
+namespace Org.Apache.REEF.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingRegisterResponseCodec.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingRegisterResponseCodec.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingRegisterResponseCodec.cs
new file mode 100644
index 0000000..8749d96
--- /dev/null
+++ 
b/lang/cs/Org.Apache.REEF.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.Network.Naming.Events;
+using Org.Apache.REEF.Wake.Remote;
+
+namespace Org.Apache.REEF.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingUnregisterRequestCodec.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingUnregisterRequestCodec.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Codec/NamingUnregisterRequestCodec.cs
new file mode 100644
index 0000000..44fd08b
--- /dev/null
+++ 
b/lang/cs/Org.Apache.REEF.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.Network.Naming.Events;
+using Org.Apache.REEF.Utilities;
+using Org.Apache.REEF.Wake.Remote;
+using Org.Apache.REEF.Network.Naming.Contracts;
+
+namespace Org.Apache.REEF.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingAssignment.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingAssignment.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingAssignment.cs
new file mode 100644
index 0000000..9506c88
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.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.Network.Naming.Contracts
+{
+    /// <summary>
+    /// Used to serialize and deserialize Avro record 
Org.Apache.REEF.Network.Naming.Contracts.AvroNamingAssignment.
+    /// </summary>
+    [DataContract]
+    public class AvroNamingAssignment
+    {
+        private const string JsonSchema = 
@"{""type"":""record"",""name"":""Org.Apache.REEF.Network.Naming.Contracts.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingLookupRequest.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingLookupRequest.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingLookupRequest.cs
new file mode 100644
index 0000000..e367f2b
--- /dev/null
+++ 
b/lang/cs/Org.Apache.REEF.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.Network.Naming.Contracts
+{
+    /// <summary>
+    /// Used to serialize and deserialize Avro record 
Org.Apache.REEF.Network.Naming.Contracts.AvroNamingLookupRequest.
+    /// </summary>
+    [DataContract]
+    public class AvroNamingLookupRequest
+    {
+        private const string JsonSchema = 
@"{""type"":""record"",""name"":""Org.Apache.REEF.Network.Naming.Contracts.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingLookupResponse.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingLookupResponse.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingLookupResponse.cs
new file mode 100644
index 0000000..edda028
--- /dev/null
+++ 
b/lang/cs/Org.Apache.REEF.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.Network.Naming.Contracts
+{
+    /// <summary>
+    /// Used to serialize and deserialize Avro record 
Org.Apache.REEF.Network.Naming.Contracts.AvroNamingLookupResponse.
+    /// </summary>
+    [DataContract]
+    public class AvroNamingLookupResponse
+    {
+        private const string JsonSchema = 
@"{""type"":""record"",""name"":""Org.Apache.REEF.Network.Naming.Contracts.AvroNamingLookupResponse"",""fields"":[{""name"":""tuples"",""type"":{""type"":""array"",""items"":{""type"":""record"",""name"":""Org.Apache.REEF.Network.Naming.Contracts.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingRegisterRequest.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingRegisterRequest.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingRegisterRequest.cs
new file mode 100644
index 0000000..8d4b832
--- /dev/null
+++ 
b/lang/cs/Org.Apache.REEF.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.Network.Naming.Contracts
+{
+    /// <summary>
+    /// Used to serialize and deserialize Avro record 
Org.Apache.REEF.Network.Naming.Contracts.AvroNamingRegisterRequest.
+    /// </summary>
+    [DataContract]
+    public class AvroNamingRegisterRequest
+    {
+        private const string JsonSchema = 
@"{""type"":""record"",""name"":""Org.Apache.REEF.Network.Naming.Contracts.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingUnRegisterRequest.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingUnRegisterRequest.cs
 
b/lang/cs/Org.Apache.REEF.Network/Naming/Contracts/AvroNamingUnRegisterRequest.cs
new file mode 100644
index 0000000..cdf9749
--- /dev/null
+++ 
b/lang/cs/Org.Apache.REEF.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.Network.Naming.Contracts
+{
+    /// <summary>
+    /// Used to serialize and deserialize Avro record 
Org.Apache.REEF.Network.Naming.Contracts.AvroNamingUnRegisterRequest.
+    /// </summary>
+    [DataContract]
+    public class AvroNamingUnRegisterRequest
+    {
+        private const string JsonSchema = 
@"{""type"":""record"",""name"":""Org.Apache.REEF.Network.Naming.Contracts.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingEvent.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingEvent.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingEvent.cs
new file mode 100644
index 0000000..981e777
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.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.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingGetAllRequest.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingGetAllRequest.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingGetAllRequest.cs
new file mode 100644
index 0000000..d101bcb
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.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.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingGetAllResponse.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingGetAllResponse.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingGetAllResponse.cs
new file mode 100644
index 0000000..fa89afc
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.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.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingLookupRequest.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingLookupRequest.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingLookupRequest.cs
new file mode 100644
index 0000000..aad8659
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.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.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingLookupResponse.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingLookupResponse.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingLookupResponse.cs
new file mode 100644
index 0000000..8f9a05b
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.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.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingRegisterRequest.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingRegisterRequest.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingRegisterRequest.cs
new file mode 100644
index 0000000..49cbeb6
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.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.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingRegisterResponse.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingRegisterResponse.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingRegisterResponse.cs
new file mode 100644
index 0000000..d8a16c4
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.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.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/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingUnregisterRequest.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingUnregisterRequest.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingUnregisterRequest.cs
new file mode 100644
index 0000000..e571e18
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.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.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; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingUnregisterResponse.cs
----------------------------------------------------------------------
diff --git 
a/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingUnregisterResponse.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingUnregisterResponse.cs
new file mode 100644
index 0000000..7428fb5
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Network/Naming/Events/NamingUnregisterResponse.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.Network.Naming.Events
+{
+    /// <summary>
+    /// Response event for unregistering of an IPEndpoint with the Name Service
+    /// </summary>
+    internal class NamingUnregisterResponse : NamingEvent
+    {
+        public NamingUnregisterResponse(NamingUnregisterRequest request)
+        {
+            Request = request;
+        }
+
+        public NamingUnregisterRequest Request { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/INameServer.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Network/Naming/INameServer.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/INameServer.cs
new file mode 100644
index 0000000..c27abe6
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Network/Naming/INameServer.cs
@@ -0,0 +1,69 @@
+/**
+ * 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.Net;
+using Org.Apache.REEF.Common.io;
+using Org.Apache.REEF.Network.Naming.Events;
+using Org.Apache.REEF.Tang.Annotations;
+
+namespace Org.Apache.REEF.Network.Naming
+{
+    /// <summary>
+    /// Service that manages names and IPEndpoints for well known hosts.
+    /// Can register, unregister, and look up IPAddresses using a string 
identifier.
+    /// </summary>
+    [DefaultImplementation(typeof(NameServer))]
+    public interface INameServer : IDisposable
+    {
+        /// <summary>
+        /// Listening endpoint for the NameServer
+        /// </summary>
+        IPEndPoint LocalEndpoint { get; }
+
+        /// <summary>
+        /// Looks up the IPEndpoints for each string identifier
+        /// </summary>
+        /// <param name="ids">The IDs to look up</param>
+        /// <returns>A list of Name assignments representing the identifier
+        /// that was searched for and the mapped IPEndpoint</returns>
+        List<NameAssignment> Lookup(List<string> ids);
+
+        /// <summary>
+        /// Gets all of the registered identifier/endpoint pairs.
+        /// </summary>
+        /// <returns>A list of all of the registered identifiers and their
+        /// mapped IPEndpoints</returns>
+        List<NameAssignment> GetAll();
+
+        /// <summary>
+        /// Registers the string identifier with the given IPEndpoint
+        /// </summary>
+        /// <param name="id">The string ident</param>
+        /// <param name="endpoint">The mapped endpoint</param>
+        void Register(string id, IPEndPoint endpoint);
+
+        /// <summary>
+        /// Unregister the given identifier with the NameServer
+        /// </summary>
+        /// <param name="id">The identifier to unregister</param>
+        void Unregister(string id);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/b6c4e983/lang/cs/Org.Apache.REEF.Network/Naming/NameClient.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Network/Naming/NameClient.cs 
b/lang/cs/Org.Apache.REEF.Network/Naming/NameClient.cs
new file mode 100644
index 0000000..9b69cec
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Network/Naming/NameClient.cs
@@ -0,0 +1,279 @@
+/**
+ * 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.Network.Naming.Codec;
+using Org.Apache.REEF.Network.Naming.Events;
+using Org.Apache.REEF.Utilities.Diagnostics;
+using Org.Apache.REEF.Utilities.Logging;
+using Org.Apache.REEF.Tang.Annotations;
+using Org.Apache.REEF.Wake;
+using Org.Apache.REEF.Wake.Remote;
+using Org.Apache.REEF.Wake.Remote.Impl;
+using Org.Apache.REEF.Wake.RX;
+using Org.Apache.REEF.Wake.RX.Impl;
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Reactive;
+
+namespace Org.Apache.REEF.Network.Naming
+{
+    /// <summary>
+    /// Client for the Reef name service. 
+    /// Used to register, unregister, and lookup IP Addresses of known hosts.
+    /// </summary>
+    public class NameClient : INameClient
+    {
+        private static Logger _logger = Logger.GetLogger(typeof(NameClient));
+
+        private BlockingCollection<NamingLookupResponse> _lookupResponseQueue;
+        private BlockingCollection<NamingGetAllResponse> _getAllResponseQueue;
+        private BlockingCollection<NamingRegisterResponse> 
_registerResponseQueue;
+        private BlockingCollection<NamingUnregisterResponse> 
_unregisterResponseQueue;
+
+        private TransportClient<NamingEvent> _client;
+
+        private NameLookupClient _lookupClient;
+        private NameRegisterClient _registerClient;
+
+        private bool _disposed;
+
+        /// <summary>
+        /// Constructs a NameClient to register, lookup, and unregister 
IPEndpoints
+        /// with the NameServer.
+        /// </summary>
+        /// <param name="remoteAddress">The ip address of the 
NameServer</param>
+        /// <param name="remotePort">The port of the NameServer</param>
+        [Inject]
+        public NameClient(
+            [Parameter(typeof(NamingConfigurationOptions.NameServerAddress))] 
string remoteAddress, 
+            [Parameter(typeof(NamingConfigurationOptions.NameServerPort))] int 
remotePort)
+        {
+            IPEndPoint remoteEndpoint = new 
IPEndPoint(IPAddress.Parse(remoteAddress), remotePort);
+            Initialize(remoteEndpoint);
+            _disposed = false;
+        }
+
+        /// <summary>
+        /// Constructs a NameClient to register, lookup, and unregister 
IPEndpoints
+        /// with the NameServer.
+        /// </summary>
+        /// <param name="remoteEndpoint">The endpoint of the NameServer</param>
+        public NameClient(IPEndPoint remoteEndpoint) 
+        {
+            Initialize(remoteEndpoint);
+            _disposed = false;
+        }
+
+        /// <summary>
+        /// Synchronously registers the identifier with the NameService.  
+        /// Overwrites the previous mapping if the identifier has already 
+        /// been registered.
+        /// </summary>
+        /// <param name="id">The key used to map the remote endpoint</param>
+        /// <param name="endpoint">The endpoint to map</param>
+        public void Register(string id, IPEndPoint endpoint)
+        {
+            if (id == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("id"), _logger);
+            }
+            if (endpoint == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("endpoint"), 
_logger);
+            }
+
+            _logger.Log(Level.Info, "Registering id: " + id + ", and endpoint: 
" + endpoint);
+            _registerClient.Register(id, endpoint);
+        }
+
+        /// <summary>
+        /// Synchronously unregisters the remote identifier with the 
NameService
+        /// </summary>
+        /// <param name="id">The identifier to unregister</param>
+        public void Unregister(string id)
+        {
+            if (id == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("id"), _logger);
+            }
+
+            _logger.Log(Level.Info, "Unregistering id: " + id);
+            _registerClient.Unregister(id);
+        }
+
+        /// <summary>
+        /// Synchronously looks up the IPEndpoint for the registered 
identifier.
+        /// </summary>
+        /// <param name="id">The identifier to look up</param>
+        /// <returns>The mapped IPEndpoint for the identifier, or null if
+        /// the identifier has not been registered with the 
NameService</returns>
+        public IPEndPoint Lookup(string id)
+        {
+            if (id == null)
+            {
+                Exceptions.Throw(new ArgumentNullException("id"), _logger);
+            }
+
+            List<NameAssignment> assignments = Lookup(new List<string> { id });
+            if (assignments != null && assignments.Count > 0)
+            {
+                return assignments.First().Endpoint;
+            }
+
+            return null;
+        }
+
+        /// <summary>
+        /// Synchronously looks up the IPEndpoint for each of the registered 
identifiers in the list.
+        /// </summary>
+        /// <param name="ids">The list of identifiers to look up</param>
+        /// <returns>The list of NameAssignments representing a pair of 
identifer
+        /// and mapped IPEndpoint for that identifier.  If any of the 
requested identifiers
+        /// are not registered with the NameService, their corresponding 
NameAssignment
+        /// IPEndpoint value will be null.</returns>
+        public List<NameAssignment> Lookup(List<string> ids)
+        {
+            if (ids == null || ids.Count == 0)
+            {
+                Exceptions.Throw(new ArgumentNullException("ids cannot be null 
or empty"), _logger);
+            }
+
+            _logger.Log(Level.Verbose, "Looking up ids");
+            List<NameAssignment> assignments = _lookupClient.Lookup(ids);
+            if (assignments != null)
+            {
+                return assignments;
+            }
+            Exceptions.Throw(new WakeRuntimeException("NameClient failed to 
look up ids."), _logger);
+            return null;  //above line will throw exception. So null will 
never be returned.
+        }
+
+        /// <summary>
+        /// Restart the name client in case of failure.
+        /// </summary>
+        /// <param name="serverEndpoint">The new server endpoint to connect 
to</param>
+        public void Restart(IPEndPoint serverEndpoint)
+        {
+            _client.Dispose();
+            Initialize(serverEndpoint);
+        }
+
+        /// <summary>
+        /// Releases resources used by NameClient
+        /// </summary>
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+            {
+                return;
+            }
+            if (disposing)
+            {
+                _client.Dispose();
+            }
+            _disposed = true;
+        }
+
+        /// <summary>
+        /// Create a new transport client connected to the NameServer at the 
given remote endpoint.
+        /// </summary>
+        /// <param name="serverEndpoint">The NameServer endpoint to connect 
to.</param>
+        private void Initialize(IPEndPoint serverEndpoint)
+        {
+            _lookupResponseQueue = new 
BlockingCollection<NamingLookupResponse>();
+            _getAllResponseQueue = new 
BlockingCollection<NamingGetAllResponse>();
+            _registerResponseQueue = new 
BlockingCollection<NamingRegisterResponse>();
+            _unregisterResponseQueue = new 
BlockingCollection<NamingUnregisterResponse>();
+
+            IObserver<TransportEvent<NamingEvent>> clientHandler = 
CreateClientHandler();
+            ICodec<NamingEvent> codec = CreateClientCodec();
+            _client = new TransportClient<NamingEvent>(serverEndpoint, codec, 
clientHandler);
+
+            _lookupClient = new NameLookupClient(_client, 
_lookupResponseQueue, _getAllResponseQueue);
+            _registerClient = new NameRegisterClient(_client, 
_registerResponseQueue, _unregisterResponseQueue);
+        }
+
+        /// <summary>
+        /// Create handler to handle async responses from the NameServer.
+        /// </summary>
+        /// <returns>The client handler to manage responses from the 
NameServer</returns>
+        private IObserver<TransportEvent<NamingEvent>> CreateClientHandler()
+        {
+            PubSubSubject<NamingEvent> subject = new 
PubSubSubject<NamingEvent>();
+            subject.Subscribe(Observer.Create<NamingLookupResponse>(msg => 
HandleResponse(_lookupResponseQueue, msg)));
+            subject.Subscribe(Observer.Create<NamingGetAllResponse>(msg => 
HandleResponse(_getAllResponseQueue, msg)));
+            subject.Subscribe(Observer.Create<NamingRegisterResponse>(msg => 
HandleResponse(_registerResponseQueue, msg)));
+            subject.Subscribe(Observer.Create<NamingUnregisterResponse>(msg => 
HandleResponse(_unregisterResponseQueue, msg)));
+            return new ClientObserver(subject);
+        }
+
+        /// <summary>
+        /// Create the codec used to serialize/deserialize NamingEvent messages
+        /// </summary>
+        /// <returns>The serialization codec</returns>
+        private ICodec<NamingEvent> CreateClientCodec()
+        {
+            MultiCodec<NamingEvent> codec = new MultiCodec<NamingEvent>();
+            codec.Register(new NamingLookupRequestCodec(), 
"org.apache.reef.io.network.naming.serialization.NamingLookupRequest");
+            codec.Register(new NamingLookupResponseCodec(), 
"org.apache.reef.io.network.naming.serialization.NamingLookupResponse");
+            NamingRegisterRequestCodec requestCodec = new 
NamingRegisterRequestCodec();
+            codec.Register(requestCodec, 
"org.apache.reef.io.network.naming.serialization.NamingRegisterRequest");
+            codec.Register(new NamingRegisterResponseCodec(requestCodec), 
"org.apache.reef.io.network.naming.serialization.NamingRegisterResponse");
+            codec.Register(new NamingUnregisterRequestCodec(), 
"org.apache.reef.io.network.naming.serialization.NamingUnregisterRequest");
+            return codec;
+        }
+
+        private void HandleResponse<T>(BlockingCollection<T> queue, T message)
+        {
+            queue.Add(message);
+        }
+
+        /// <summary>
+        /// Helper class used to handle response events from the NameServer.
+        /// Delegates the event to the appropriate response queue depending on
+        /// its event type.
+        /// </summary>
+        private class ClientObserver : 
AbstractObserver<TransportEvent<NamingEvent>>
+        {
+            private IObserver<NamingEvent> _handler;
+
+            public ClientObserver(IObserver<NamingEvent> handler)
+            {
+                _handler = handler;
+            }
+
+            public override void OnNext(TransportEvent<NamingEvent> value)
+            {
+                NamingEvent message = value.Data;
+                message.Link = value.Link;
+                _handler.OnNext(message);
+            }
+        }
+    }
+}

Reply via email to