You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by se...@apache.org on 2015/04/29 02:01:15 UTC

incubator-reef git commit: [REEF-286] Improved logging in the Evaluator

Repository: incubator-reef
Updated Branches:
  refs/heads/master 60adf8c43 -> 2d37964c4


[REEF-286] Improved logging in the Evaluator

This improves logging in the .NET Evaluator. To do so, the following
changes were made:

 * Refactor `Evaluator.Main` into a series of smaller methods. Each of
   these throws specific exceptions about what went wrong.
 * Add a `try/catch` block around `Evaluator.Main` that catches all
   exceptions thrown and logs them.
 * The new method `Evaluator.Fail()` logs the contents of the current
   working directory of the Evaluator.
 * Use that same method for the app domain exception handler.

This also moves some of the configuration parsing logic from
`Evaluator.Main` to `EvaluatorConfigurations` to improve the legibility
of `Evaluator.Main`.

*Note:* This doesn't use `Exceptions.Throws`. Instead, all exceptions
are logged in `Evaluator.Fail`

JIRA:
  [REEF-286](https://issues.apache.org/jira/browse/REEF-286)

Pull Request:
  Closes #166


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

Branch: refs/heads/master
Commit: 2d37964c47dd46f99c431e0f57d62a21e06355e5
Parents: 60adf8c
Author: Markus Weimer <we...@apache.org>
Authored: Tue Apr 28 15:27:04 2015 -0700
Committer: Beysim Sezgin <be...@microsoft.com>
Committed: Tue Apr 28 16:58:56 2015 -0700

----------------------------------------------------------------------
 .../Evaluator/Utils/EvaluatorConfigurations.cs  |  61 +++-
 lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs  | 349 ++++++++++++-------
 .../Exceptions/ClockInstantiationException.cs   |  32 ++
 ...aluatorConfigurationFileNotFoundException.cs |  39 +++
 .../EvaluatorConfigurationParseException.cs     |  34 ++
 .../EvaluatorInjectorInstantiationException.cs  |  34 ++
 .../Exceptions/UnhandledException.cs            |  33 ++
 .../Org.Apache.REEF.Evaluator.csproj            |   5 +
 .../Evaluator/EvaluatorConfigurationsTests.cs   |   2 +-
 9 files changed, 452 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2d37964c/lang/cs/Org.Apache.REEF.Common/Runtime/Evaluator/Utils/EvaluatorConfigurations.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Common/Runtime/Evaluator/Utils/EvaluatorConfigurations.cs b/lang/cs/Org.Apache.REEF.Common/Runtime/Evaluator/Utils/EvaluatorConfigurations.cs
index 016aa78..d75d681 100644
--- a/lang/cs/Org.Apache.REEF.Common/Runtime/Evaluator/Utils/EvaluatorConfigurations.cs
+++ b/lang/cs/Org.Apache.REEF.Common/Runtime/Evaluator/Utils/EvaluatorConfigurations.cs
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -20,8 +20,12 @@
 using System;
 using System.IO;
 using System.Linq;
+using Org.Apache.REEF.Common.Runtime.Evaluator.Context;
+using Org.Apache.REEF.Common.Services;
+using Org.Apache.REEF.Common.Tasks;
 using Org.Apache.REEF.Tang.Formats;
 using Org.Apache.REEF.Tang.Formats.AvroConfigurationDataContract;
+using Org.Apache.REEF.Utilities;
 using Org.Apache.REEF.Utilities.Logging;
 
 namespace Org.Apache.REEF.Common.Runtime.Evaluator.Utils
@@ -62,7 +66,7 @@ namespace Org.Apache.REEF.Common.Runtime.Evaluator.Utils
             }
         }
 
-        public string TaskConfiguration
+        public string TaskConfigurationString
         {
             get
             {
@@ -71,6 +75,21 @@ namespace Org.Apache.REEF.Common.Runtime.Evaluator.Utils
             }
         }
 
+        /// <summary>
+        /// The TaskConfiguration submitted with the evaluator configuration, if any.
+        /// </summary>
+        public Optional<TaskConfiguration> TaskConfiguration
+        {
+            get
+            {
+                var taskConfig = TaskConfigurationString;
+                return string.IsNullOrEmpty(taskConfig)
+                    ? Optional<TaskConfiguration>.Empty()
+                    : Optional<TaskConfiguration>.Of(
+                        new TaskConfiguration(taskConfig));
+            }
+        } 
+
         public string EvaluatorId
         {
             get
@@ -89,7 +108,7 @@ namespace Org.Apache.REEF.Common.Runtime.Evaluator.Utils
             }
         }
 
-        public string RootContextConfiguration
+        public string RootContextConfigurationString
         {
             get
             {
@@ -97,8 +116,25 @@ namespace Org.Apache.REEF.Common.Runtime.Evaluator.Utils
                 return _rootContextConfiguration;
             }
         }
+        /// <summary>
+        /// The ContextConfiguration for the root context.
+        /// </summary>
+        /// <exception cref="ArgumentException">If the underlying string parameter isn't set.</exception>
+        public ContextConfiguration RootContextConfiguration
+        {
+            get
+            {
+                string rootContextConfigString = RootContextConfigurationString;
+                if (string.IsNullOrWhiteSpace(rootContextConfigString))
+                {
+                    Utilities.Diagnostics.Exceptions.Throw(
+                        new ArgumentException("empty or null rootContextConfigString"), LOGGER);
+                }
+                return new ContextConfiguration(rootContextConfigString);
+            }
+        }
 
-        public string RootServiceConfiguration
+        public string RootServiceConfigurationString
         {
             get
             {
@@ -107,6 +143,23 @@ namespace Org.Apache.REEF.Common.Runtime.Evaluator.Utils
             }
         }
 
+        /// <summary>
+        /// The ServiceConfiguration for the root context.
+        /// </summary>
+        /// <exception cref="ArgumentException">If the underlying string parameter isn't set.</exception>
+        public Optional<ServiceConfiguration> RootServiceConfiguration
+        {
+            get
+            {
+                var rootServiceConfigString = RootServiceConfigurationString;
+                return string.IsNullOrEmpty(rootServiceConfigString)
+                    ? Optional<ServiceConfiguration>.Empty()
+                    : Optional<ServiceConfiguration>.Of(
+                        new ServiceConfiguration(
+                            rootServiceConfigString));
+            }
+        } 
+
         private string GetSettingValue(string settingKey)
         {
             ConfigurationEntry configurationEntry =

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2d37964c/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
index 99af164..e09367e 100644
--- a/lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs
+++ b/lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -24,6 +24,7 @@ using System.Diagnostics;
 using System.Globalization;
 using System.IO;
 using System.Linq;
+using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
 using Org.Apache.REEF.Common.Protobuf.ReefProtocol;
@@ -33,12 +34,12 @@ using Org.Apache.REEF.Common.Runtime.Evaluator.Utils;
 using Org.Apache.REEF.Common.Services;
 using Org.Apache.REEF.Common.Tasks;
 using Org.Apache.REEF.Driver.Bridge;
+using Org.Apache.REEF.Evaluator.Exceptions;
 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.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;
@@ -47,9 +48,9 @@ using Org.Apache.REEF.Wake.Time.Runtime.Event;
 
 namespace Org.Apache.REEF.Evaluator
 {
-    public class Evaluator
+    public sealed class Evaluator
     {
-        private static Logger _logger;
+        private static Logger _logger = Logger.GetLogger(typeof(Evaluator));
 
         private static int _heartbeatPeriodInMs = Constants.DefaultEvaluatorHeartbeatPeriodInMs;
 
@@ -61,169 +62,231 @@ namespace Org.Apache.REEF.Evaluator
 
         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"))
+            
+            try
             {
-                string debugEnabledString = Environment.GetEnvironmentVariable("Org.Apache.REEF.EvaluatorDebug");
-                if (!string.IsNullOrWhiteSpace(debugEnabledString) &&
-                    debugEnabledString.Equals("enabled", StringComparison.OrdinalIgnoreCase))
+                Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "START: {0} Evaluator::InitInjector.",
+                    DateTime.Now));
+                Stopwatch timer = new Stopwatch();
+                InitInjector();
+                SetCustomTraceListners();  // _logger is reset by this.
+                timer.Stop();
+                Console.WriteLine(string.Format(CultureInfo.InvariantCulture,
+                    "EXIT: {0} Evaluator::InitInjector. Duration: [{1}].", DateTime.Now, timer.Elapsed));
+
+                
+                using (_logger.LogScope("Evaluator::Main"))
                 {
-                    while (true)
+                    // Wait for the debugger, if enabled
+                    AttachDebuggerIfEnabled();
+
+                    // Register our exception handler
+                    AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
+
+                    // Fetch some settings from the ConfigurationManager
+                    SetHeartbeatPeriod();
+                    SetHeartbeatMaxRetry();
+                    
+                    
+                    // Parse the command line
+                    if (args.Count() < 2)
                     {
-                        if (Debugger.IsAttached)
-                        {
-                            break;
-                        }
-                        else
-                        {
-                            _logger.Log(Level.Info, "Evaluator in debug mode, waiting for debugger to be attached...");
-                            Thread.Sleep(2000);
-                        }
+                        var e = new InvalidOperationException("must supply at least the rId and evaluator config file");
+                        Utilities.Diagnostics.Exceptions.Throw(e, _logger);
                     }
-                }
 
-                AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
+                    // remote driver Id
+                    string rId = args[0];
 
-                string heartbeatPeriodFromConfig = ConfigurationManager.AppSettings["EvaluatorHeartbeatPeriodInMs"];
+                    // evaluator configuraiton file
+                    string evaluatorConfigurationPath = args[1];
 
-                int heartbeatPeriod = 0;
+                    // Parse the evaluator configuration.
+                    _evaluatorConfig = new EvaluatorConfigurations(evaluatorConfigurationPath);
 
-                if (!string.IsNullOrWhiteSpace(heartbeatPeriodFromConfig) &&
-                    int.TryParse(heartbeatPeriodFromConfig, out heartbeatPeriod))
-                {
-                    _heartbeatPeriodInMs = heartbeatPeriod;
-                }
-                _logger.Log(Level.Verbose,
-                            "Evaluator heartbeat period set to be " + _heartbeatPeriodInMs + " milliSeconds.");
+                    ContextConfiguration rootContextConfiguration = _evaluatorConfig.RootContextConfiguration;
+                    Optional<TaskConfiguration> rootTaskConfig = _evaluatorConfig.TaskConfiguration;
+                    Optional<ServiceConfiguration> rootServiceConfig = _evaluatorConfig.RootServiceConfiguration;
 
-                int maxHeartbeatRetry = 0;
-                string heartbeatMaxRetryFromConfig = ConfigurationManager.AppSettings["EvaluatorHeartbeatRetryMaxTimes"];
+                    // remoteManager used as client-only in evaluator
+                    IRemoteManager<REEFMessage> remoteManager = new DefaultRemoteManager<REEFMessage>(new REEFMessageCodec());
+                    IRemoteIdentifier remoteId = new SocketRemoteIdentifier(NetUtilities.ParseIpEndpoint(rId));
 
-                if (!string.IsNullOrWhiteSpace(heartbeatMaxRetryFromConfig) &&
-                    int.TryParse(heartbeatMaxRetryFromConfig, out maxHeartbeatRetry))
-                {
-                    _heartbeatMaxRetry = maxHeartbeatRetry;
+
+                    RuntimeClock clock = InstantiateClock();
+                    _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: replace with injectionFuture
+                    heartBeatManager._evaluatorRuntime = evaluatorRuntime;
+                    heartBeatManager._contextManager = contextManager;
+
+                    SetRuntimeHandlers(evaluatorRuntime, clock);
+
+
+                    Task evaluatorTask = Task.Run(new Action(clock.Run));
+                    evaluatorTask.Wait();
                 }
-                _logger.Log(Level.Verbose, "Evaluator heatrbeat max retry set to be " + _heartbeatMaxRetry + " times.");
+            }
+            catch (Exception e)
+            {
+                Fail(e);
+            }
+        }
+
+        /// <summary>
+        /// Determines whether debugging is enabled.
+        /// </summary>
+        /// <returns>true, if debugging is enabled</returns>
+        private static Boolean IsDebuggingEnabled()
+        {
+            var debugEnabledString = Environment.GetEnvironmentVariable("Org.Apache.REEF.EvaluatorDebug");
+            return !string.IsNullOrWhiteSpace(debugEnabledString) &&
+                   debugEnabledString.Equals("enabled", StringComparison.OrdinalIgnoreCase);
+        }
 
-                if (args.Count() < 2)
+        /// <summary>
+        /// Waits for the debugger to be attached.
+        /// </summary>
+        private static void AttachDebuggerIfEnabled()
+        {
+            if (IsDebuggingEnabled())
+            {
+                while (true)
                 {
-                    var e = new InvalidOperationException("must supply at least the rId and evaluator config file");
-                    Exceptions.Throw(e, _logger);
+                    if (Debugger.IsAttached)
+                    {
+                        break;
+                    }
+                    else
+                    {
+                        _logger.Log(Level.Info,
+                            "Evaluator in debug mode, waiting for debugger to be attached...");
+                        Thread.Sleep(2000);
+                    }
                 }
+            }
+        }
 
-                // remote driver Id
-                string rId = args[0];
-
-                // evaluator configuraiton file
-                string evaluatorConfigurationPath = args[1];
+        /// <summary>
+        /// Sets the heartbeat period from the ConfigurationManager
+        /// </summary>
+        private static void SetHeartbeatPeriod()
+        {
+            var heartbeatPeriodFromConfig = ConfigurationManager.AppSettings["EvaluatorHeartbeatPeriodInMs"];
 
-                ICodec<REEFMessage> reefMessageCodec = new REEFMessageCodec();
+            var heartbeatPeriod = 0;
 
-                _evaluatorConfig = new EvaluatorConfigurations(evaluatorConfigurationPath);
+            if (!string.IsNullOrWhiteSpace(heartbeatPeriodFromConfig) &&
+                int.TryParse(heartbeatPeriodFromConfig, out heartbeatPeriod))
+            {
+                _heartbeatPeriodInMs = heartbeatPeriod;
+            }
+            _logger.Log(Level.Verbose,
+                "Evaluator heartbeat period set to be " + _heartbeatPeriodInMs + " milliSeconds.");
+        }
 
-                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);
+        /// <summary>
+        /// Sets the heartbeat retry count from the ConfigurationManager
+        /// </summary>
+        private static void SetHeartbeatMaxRetry()
+        {
+            var maxHeartbeatRetry = 0;
+            var heartbeatMaxRetryFromConfig =
+                ConfigurationManager.AppSettings["EvaluatorHeartbeatRetryMaxTimes"];
 
-                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);
+            if (!string.IsNullOrWhiteSpace(heartbeatMaxRetryFromConfig) &&
+                int.TryParse(heartbeatMaxRetryFromConfig, out maxHeartbeatRetry))
+            {
+                _heartbeatMaxRetry = maxHeartbeatRetry;
             }
-
-            Task evaluatorTask = Task.Run(new Action(clock.Run));
-            evaluatorTask.Wait();            
+            _logger.Log(Level.Verbose,
+                "Evaluator heatrbeat max retry set to be " + _heartbeatMaxRetry + " times.");
         }
 
+
+        /// <summary>
+        /// Instantiates the root injector of the Evaluator.
+        /// </summary>
+        /// <exception cref="EvaluatorInjectorInstantiationException">If the injector cannot be instantiated.</exception>
         private static void InitInjector()
         {
+            try
+            {
+                _injector = TangFactory.GetTang().NewInjector(ReadEvaluatorConfiguration());
+            }
+            catch (Exception e)
+            {
+                throw new EvaluatorInjectorInstantiationException(e);
+            }
+        }
+
+        /// <summary>
+        /// Reads the Evaluator Configuration.
+        /// </summary>
+        /// <exception cref="EvaluatorConfigurationFileNotFoundException">When the configuration file cannot be found.</exception>
+        /// <exception cref="EvaluatorConfigurationParseException">When the configuration file exists, but can't be deserialized.</exception>
+        /// <returns></returns>
+        private static IConfiguration ReadEvaluatorConfiguration()
+        {
             string clrRuntimeConfigurationFile = Path.Combine(Directory.GetCurrentDirectory(), "reef", "global",
-                                                                Common.Constants.ClrBridgeRuntimeConfiguration);
+                                                                 Common.Constants.ClrBridgeRuntimeConfiguration);
             if (!File.Exists(clrRuntimeConfigurationFile))
             {
-                var e =
-                    new InvalidOperationException("Cannot find clrRuntimeConfiguration from " +
-                                                    clrRuntimeConfigurationFile);
-                Exceptions.Throw(e, _logger);
+                throw new EvaluatorConfigurationFileNotFoundException(clrRuntimeConfigurationFile);
             }
-
+            
             try
             {
-                IConfiguration clrBridgeConfiguration =
-                    new AvroConfigurationSerializer().FromFile(clrRuntimeConfigurationFile);
-                _injector = TangFactory.GetTang().NewInjector(clrBridgeConfiguration);
+                return new AvroConfigurationSerializer().FromFile(clrRuntimeConfigurationFile);
             }
             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);
+                throw new EvaluatorConfigurationParseException(e);
+            }
+        }
+
+        /// <summary>
+        /// Instantiates the RuntimeClock
+        /// </summary>
+        /// <exception cref="ClockInstantiationException">When the clock can't be instantiated.</exception>
+        /// <returns></returns>
+        private static RuntimeClock InstantiateClock()
+        {
+            IConfiguration clockConfiguraiton = new ConfigurationModuleBuilder().Build().Build();
+            try
+            {
+                return TangFactory.GetTang().NewInjector(clockConfiguraiton).GetInstance<RuntimeClock>();
             }
+            catch (Exception exception)
+            {
+                throw new ClockInstantiationException("Unable to instantiate the clock", exception);
+            } 
         }
 
         private static void SetCustomTraceListners()
         {
             ISet<TraceListener> customTraceListeners;
-            CustomTraceListeners listeners = null;
             try
             {
-                listeners = _injector.GetInstance<CustomTraceListeners>();
-                customTraceListeners = listeners.Listeners;
+                customTraceListeners = _injector.GetInstance<CustomTraceListeners>().Listeners;
             }
             catch (Exception e)
             {
-                Exceptions.Caught(e, Level.Error, _logger);
+                Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, _logger);
                 // custom trace listner not set properly, use empty set
                 customTraceListeners = new HashSet<TraceListener>();
             }
@@ -238,25 +301,47 @@ namespace Org.Apache.REEF.Evaluator
 
         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);
+            Fail((Exception)e.ExceptionObject);
+        }
+
+        private static string GetDirectoryListing(string path, StringBuilder resultBuilder = null)
+        {
+            if (null == resultBuilder)
+            {
+                resultBuilder = new StringBuilder();
+            }
+
+            // First, add the files to the listing
+            var files = Directory.GetFiles(path).Select(e => Path.Combine(path, e));
+            resultBuilder.Append(string.Join(", ", files));
+            // Second, add the directories recursively
+            var dirs = Directory.GetDirectories(path).Select(e => Path.Combine(path, e));
+            foreach (var dir in dirs)
+            {
+                GetDirectoryListing(dir, resultBuilder);
+            }
+            return resultBuilder.ToString();
         }
 
         // set the handlers for runtimeclock manually
         // we only need runtimestart and runtimestop handlers now
-        private static void SetRuntimeHanlders(EvaluatorRuntime evaluatorRuntime, RuntimeClock clock)
+        private static void SetRuntimeHandlers(EvaluatorRuntime evaluatorRuntime, RuntimeClock clock)
         {
-            HashSet<IObserver<RuntimeStart>> runtimeStarts = new HashSet<IObserver<RuntimeStart>>();
-            runtimeStarts.Add(evaluatorRuntime);
+            ISet<IObserver<RuntimeStart>> runtimeStarts = new HashSet<IObserver<RuntimeStart>> {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);
+            ISet<IObserver<RuntimeStop>> runtimeStops = new HashSet<IObserver<RuntimeStop>> { evaluatorRuntime };
             InjectionFutureImpl<ISet<IObserver<RuntimeStop>>> injectRuntimeStop = new InjectionFutureImpl<ISet<IObserver<RuntimeStop>>>(runtimeStops);
             clock.InjectedRuntimeStopHandler = injectRuntimeStop;
         }
+
+        private static void Fail(Exception ex)
+        {
+            var message = "Unhandled exception caught in Evaluator. Current files in the working directory: " +
+                          GetDirectoryListing(Directory.GetCurrentDirectory());
+            _logger.Log(Level.Error, message, ex);
+            throw ex;
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2d37964c/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/ClockInstantiationException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/ClockInstantiationException.cs b/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/ClockInstantiationException.cs
new file mode 100644
index 0000000..e795629
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/ClockInstantiationException.cs
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+namespace Org.Apache.REEF.Evaluator.Exceptions
+{
+    /// <summary>
+    /// Thrown when the Evaluator cannot instantiate the Clock.
+    /// </summary>
+    internal sealed class ClockInstantiationException : Exception
+    {
+        internal ClockInstantiationException(string message, Exception innerException) : base(message, innerException)
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2d37964c/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/EvaluatorConfigurationFileNotFoundException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/EvaluatorConfigurationFileNotFoundException.cs b/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/EvaluatorConfigurationFileNotFoundException.cs
new file mode 100644
index 0000000..112cf68
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/EvaluatorConfigurationFileNotFoundException.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;
+using System.IO;
+
+namespace Org.Apache.REEF.Evaluator.Exceptions
+{
+    /// <summary>
+    /// Thrown when the Evaluator configuration file can't be found.
+    /// </summary>
+    internal sealed class EvaluatorConfigurationFileNotFoundException : FileNotFoundException
+    {
+        internal EvaluatorConfigurationFileNotFoundException(string fileName, Exception innerException)
+            : base("Unable to find the evaluator configuration file.", fileName, innerException)
+        {
+        }
+
+        internal EvaluatorConfigurationFileNotFoundException(string fileName)
+            : base("Unable to find the evaluator configuration file.", fileName, new FileNotFoundException())
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2d37964c/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/EvaluatorConfigurationParseException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/EvaluatorConfigurationParseException.cs b/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/EvaluatorConfigurationParseException.cs
new file mode 100644
index 0000000..e6be81d
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/EvaluatorConfigurationParseException.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.
+ */
+using System;
+using System.IO;
+
+namespace Org.Apache.REEF.Evaluator.Exceptions
+{
+    /// <summary>
+    /// Thrown when the Evaluator Configuration cannot be read.
+    /// </summary>
+    internal sealed class EvaluatorConfigurationParseException : IOException
+    {
+        internal EvaluatorConfigurationParseException(Exception innerException)
+            : base("Unable to read evaluator configuration file.", innerException)
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2d37964c/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/EvaluatorInjectorInstantiationException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/EvaluatorInjectorInstantiationException.cs b/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/EvaluatorInjectorInstantiationException.cs
new file mode 100644
index 0000000..ab250da
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/EvaluatorInjectorInstantiationException.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.
+ */
+
+using System;
+
+namespace Org.Apache.REEF.Evaluator.Exceptions
+{
+    /// <summary>
+    /// Thrown when the root injector for an Evaluator cannot be instantiated.
+    /// </summary>
+    internal sealed class EvaluatorInjectorInstantiationException : Exception
+    {
+        internal EvaluatorInjectorInstantiationException(Exception innerException)
+            : base("Unable to instantiate the Evaluator injector.", innerException)
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2d37964c/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/UnhandledException.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/UnhandledException.cs b/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/UnhandledException.cs
new file mode 100644
index 0000000..3a8dcf4
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Evaluator/Exceptions/UnhandledException.cs
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+using System;
+
+namespace Org.Apache.REEF.Evaluator.Exceptions
+{
+    /// <summary>
+    /// Thrown when the Evaluator's default Exception handler catches an Exception.
+    /// </summary>
+    internal sealed class UnhandledException : Exception
+    {
+        internal UnhandledException(string message, Exception innerException)
+            : base(message, innerException)
+        {
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2d37964c/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
index 1e23d5d..672b612 100644
--- a/lang/cs/Org.Apache.REEF.Evaluator/Org.Apache.REEF.Evaluator.csproj
+++ b/lang/cs/Org.Apache.REEF.Evaluator/Org.Apache.REEF.Evaluator.csproj
@@ -49,6 +49,11 @@ under the License.
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Evaluator.cs" />
+    <Compile Include="Exceptions\ClockInstantiationException.cs" />
+    <Compile Include="Exceptions\EvaluatorConfigurationFileNotFoundException.cs" />
+    <Compile Include="Exceptions\EvaluatorConfigurationParseException.cs" />
+    <Compile Include="Exceptions\EvaluatorInjectorInstantiationException.cs" />
+    <Compile Include="Exceptions\UnhandledException.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   <ItemGroup>

http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/2d37964c/lang/cs/Org.Apache.REEF.Tests/Evaluator/EvaluatorConfigurationsTests.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Tests/Evaluator/EvaluatorConfigurationsTests.cs b/lang/cs/Org.Apache.REEF.Tests/Evaluator/EvaluatorConfigurationsTests.cs
index 32d1fd9..ef9f564 100644
--- a/lang/cs/Org.Apache.REEF.Tests/Evaluator/EvaluatorConfigurationsTests.cs
+++ b/lang/cs/Org.Apache.REEF.Tests/Evaluator/EvaluatorConfigurationsTests.cs
@@ -35,7 +35,7 @@ namespace Org.Apache.REEF.Tests.Evaluator
 
             Assert.IsTrue(evaluatorConfigurations.ApplicationId.Equals("REEF_LOCAL_RUNTIME"));
 
-            string rootContextConfigString = evaluatorConfigurations.RootContextConfiguration;
+            string rootContextConfigString = evaluatorConfigurations.RootContextConfigurationString;
             Assert.IsFalse(string.IsNullOrWhiteSpace(rootContextConfigString));
         }
     }